From fbc20e59c18d1573a16962902fb5e294057f4eee Mon Sep 17 00:00:00 2001 From: Bukkit/Spigot Date: Wed, 5 Dec 2012 05:55:26 -0600 Subject: [PATCH] Add getShutdownMessage() and stop command arguments. Adds BUKKIT-3031 By: feildmaster --- paper-api/src/main/java/org/bukkit/Bukkit.java | 4 ++++ paper-api/src/main/java/org/bukkit/Server.java | 7 +++++++ .../org/bukkit/command/defaults/StopCommand.java | 14 ++++++++++++-- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/paper-api/src/main/java/org/bukkit/Bukkit.java b/paper-api/src/main/java/org/bukkit/Bukkit.java index 7e8478ae15..e2506bc150 100644 --- a/paper-api/src/main/java/org/bukkit/Bukkit.java +++ b/paper-api/src/main/java/org/bukkit/Bukkit.java @@ -383,6 +383,10 @@ public final class Bukkit { return server.getMotd(); } + public static String getShutdownMessage() { + return server.getShutdownMessage(); + } + public static WarningState getWarningState() { return server.getWarningState(); } diff --git a/paper-api/src/main/java/org/bukkit/Server.java b/paper-api/src/main/java/org/bukkit/Server.java index 881d47f1c8..a4f8ec29e5 100644 --- a/paper-api/src/main/java/org/bukkit/Server.java +++ b/paper-api/src/main/java/org/bukkit/Server.java @@ -666,6 +666,13 @@ public interface Server extends PluginMessageRecipient { */ String getMotd(); + /** + * Gets the default message that is displayed when the server is stopped + * + * @return the shutdown message + */ + String getShutdownMessage(); + /** * Gets the current warning state for the server * diff --git a/paper-api/src/main/java/org/bukkit/command/defaults/StopCommand.java b/paper-api/src/main/java/org/bukkit/command/defaults/StopCommand.java index 2c12e1e629..be70e63e4d 100644 --- a/paper-api/src/main/java/org/bukkit/command/defaults/StopCommand.java +++ b/paper-api/src/main/java/org/bukkit/command/defaults/StopCommand.java @@ -2,18 +2,21 @@ package org.bukkit.command.defaults; import java.util.List; +import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.Validate; + import org.bukkit.Bukkit; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; import com.google.common.collect.ImmutableList; public class StopCommand extends VanillaCommand { public StopCommand() { super("stop"); - this.description = "Stops the server"; - this.usageMessage = "/stop"; + this.description = "Stops the server with optional reason"; + this.usageMessage = "/stop [reason]"; this.setPermission("bukkit.command.stop"); } @@ -24,6 +27,13 @@ public class StopCommand extends VanillaCommand { Command.broadcastCommandMessage(sender, "Stopping the server.."); Bukkit.shutdown(); + String reason = this.createString(args, 0); + if (StringUtils.isNotEmpty(reason)) { + for (Player player : Bukkit.getOnlinePlayers()) { + player.kickPlayer(reason); + } + } + return true; }