mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-09 19:49:35 +01:00
Add getShutdownMessage() and stop command arguments. Adds BUKKIT-3031
By: feildmaster <admin@feildmaster.com>
This commit is contained in:
parent
f545b84e46
commit
fbc20e59c1
3 changed files with 23 additions and 2 deletions
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue