Replace deprecated restart function#236
Conversation
WalkthroughReplaced the restart call in a scheduled task from Bukkit.spigot().restart() to Bukkit.getServer().restart(). All other logic, including scheduling, logging, and player kick handling, remains unchanged. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Note Docstrings generation - SUCCESS |
Docstrings generation was requested by @JonasFranke. * #236 (comment) The following files were modified: * `src/main/java/de/j/stationofdoom/cmd/VoteRestartCMD.java`
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/main/java/de/j/stationofdoom/cmd/VoteRestartCMD.java (1)
41-47: Critical: Vote instruction message is never sent to players.The component created in this loop is never sent to any player. Players won't see the clickable message instructing them how to vote for the restart.
Apply this diff to send the message to all online players:
for (Player on : Bukkit.getOnlinePlayers()) { - Component.text(translations.getTranslation(player, "ClickHereToVote")) + on.sendMessage(Component.text(translations.getTranslation(on, "ClickHereToVote")) .color(NamedTextColor.GREEN) - .clickEvent(ClickEvent.runCommand("/voterestart")).hoverEvent(HoverEvent - .showText(Component.text(translations.getTranslation(player, "ClickToVote")) - .color(NamedTextColor.GREEN))); + .clickEvent(ClickEvent.runCommand("/voterestart")) + .hoverEvent(HoverEvent.showText(Component.text(translations.getTranslation(on, "ClickToVote")) + .color(NamedTextColor.GREEN)))); }Note: Also changed
playertoonin the translation calls for consistency with the rest of the code.
🧹 Nitpick comments (1)
src/main/java/de/j/stationofdoom/cmd/VoteRestartCMD.java (1)
29-29: Consider replacing assertion with explicit check.While
canUse()guards against non-Player senders, assertions can be disabled at runtime (-daflag), making this check unreliable. Consider using an explicit check with early return or exception instead.Example improvement:
- assert commandSourceStack.getSender() instanceof Player; - Player player = (Player) commandSourceStack.getSender(); + if (!(commandSourceStack.getSender() instanceof Player)) { + return; + } + Player player = (Player) commandSourceStack.getSender();
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/main/java/de/j/stationofdoom/cmd/VoteRestartCMD.java(1 hunks)
🔇 Additional comments (1)
src/main/java/de/j/stationofdoom/cmd/VoteRestartCMD.java (1)
78-78: LGTM! Correct replacement of deprecated method.The change from
Bukkit.spigot().restart()toBukkit.getServer().restart()correctly addresses the deprecation. Both methods have equivalent behavior, and this is the recommended replacement.
Docstrings generation was requested by @JonasFranke. * #236 (comment) The following files were modified: * `src/main/java/de/j/stationofdoom/cmd/VoteRestartCMD.java`
Replaces deprecated function in vote restart
Summary by CodeRabbit