Skip to content

Replace deprecated restart function#236

Merged
JonasFranke merged 1 commit intomasterfrom
dev/replaceDeprecatedFunctions
Oct 12, 2025
Merged

Replace deprecated restart function#236
JonasFranke merged 1 commit intomasterfrom
dev/replaceDeprecatedFunctions

Conversation

@JonasFranke
Copy link
Copy Markdown
Collaborator

@JonasFranke JonasFranke commented Oct 12, 2025

Replaces deprecated function in vote restart

Summary by CodeRabbit

  • Bug Fixes
    • Improved reliability of server restarts triggered by the vote-to-restart command.
    • Aligns the restart action with the current server API to reduce failed or stalled restarts.
    • Preserves existing timing, messaging, and player kick flow during the restart sequence, ensuring a consistent experience.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Oct 12, 2025

Walkthrough

Replaced 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

Cohort / File(s) Summary
Server restart invocation
src/main/java/de/j/stationofdoom/cmd/VoteRestartCMD.java
Switched restart method from Bukkit.spigot().restart() to Bukkit.getServer().restart(); no other control-flow changes.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

I thump my paws—restart’s in sight,
A subtle switch, still works just right.
From spigot burrow to server’s door,
The same warm warren as before.
I twitch, I nod—deploy complete,
Hop-safe restarts, fast and neat. 🐇✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title “Replace deprecated restart function” succinctly and accurately captures the core change of updating the server restart invocation from a deprecated method to a current one. It is concise, specific, and directly reflects the modification in VoteRestartCMD.java without including extraneous details. This phrasing allows reviewers to immediately understand the primary purpose of the pull request.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch dev/replaceDeprecatedFunctions

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Oct 12, 2025

Note

Docstrings generation - SUCCESS
Generated docstrings for this pull request at #237

coderabbitai bot added a commit that referenced this pull request Oct 12, 2025
Docstrings generation was requested by @JonasFranke.

* #236 (comment)

The following files were modified:

* `src/main/java/de/j/stationofdoom/cmd/VoteRestartCMD.java`
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 player to on in 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 (-da flag), 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

📥 Commits

Reviewing files that changed from the base of the PR and between 7860ad2 and ac1d91d.

📒 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() to Bukkit.getServer().restart() correctly addresses the deprecation. Both methods have equivalent behavior, and this is the recommended replacement.

@JonasFranke JonasFranke merged commit 704198f into master Oct 12, 2025
20 checks passed
@JonasFranke JonasFranke deleted the dev/replaceDeprecatedFunctions branch October 12, 2025 10:13
JonasFranke pushed a commit that referenced this pull request Oct 12, 2025
Docstrings generation was requested by @JonasFranke.

* #236 (comment)

The following files were modified:

* `src/main/java/de/j/stationofdoom/cmd/VoteRestartCMD.java`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant