From 7d4be151599713d551a9f7e0f698937365c0e88b Mon Sep 17 00:00:00 2001 From: Bukkit/Spigot Date: Fri, 28 Jan 2011 14:24:54 +0000 Subject: [PATCH] Fixed only being able to use /reload once By: Dinnerbone --- .../org/bukkit/command/SimpleCommandMap.java | 47 +++++++++++++------ 1 file changed, 32 insertions(+), 15 deletions(-) diff --git a/paper-api/src/main/java/org/bukkit/command/SimpleCommandMap.java b/paper-api/src/main/java/org/bukkit/command/SimpleCommandMap.java index 79fe285b7d..729c32a0e7 100644 --- a/paper-api/src/main/java/org/bukkit/command/SimpleCommandMap.java +++ b/paper-api/src/main/java/org/bukkit/command/SimpleCommandMap.java @@ -14,24 +14,16 @@ import org.bukkit.plugin.PluginDescriptionFile; public final class SimpleCommandMap implements CommandMap { private final Map knownCommands = new HashMap(); + private final Server server; public SimpleCommandMap(final Server server) { + this.server = server; + setDefaultCommands(server); + } + + private void setDefaultCommands(final Server server) { register("bukkit", new VersionCommand("version", server)); - - register("reload", "bukkit", new Command("reload") { - @Override - public boolean execute(Player player, String currentAlias, String[] args) { - if (player.isOp()) { - server.reload(); - player.sendMessage(ChatColor.GREEN + "Reload complete."); - } else { - player.sendMessage(ChatColor.RED + "You do not have sufficient access" - + " to reload this server."); - } - - return true; - } - }); + register("bukkit", new ReloadCommand("reload", server)); } /** @@ -89,6 +81,7 @@ public final class SimpleCommandMap implements CommandMap { public void clearCommands() { synchronized (this) { knownCommands.clear(); + setDefaultCommands(server); } } @@ -189,4 +182,28 @@ public final class SimpleCommandMap implements CommandMap { return result.toString(); } } + + private static class ReloadCommand extends Command { + + private final Server server; + + public ReloadCommand(String name, Server server) { + super(name); + this.server = server; + this.tooltip = "Reloads the server configuration and plugins"; + this.usageMessage = "/reload"; + this.setAliases(Arrays.asList("rl")); + } + + @Override + public boolean execute(Player player, String currentAlias, String[] args) { + if (player.isOp()) { + server.reload(); + player.sendMessage(ChatColor.GREEN + "Reload complete."); + } else { + player.sendMessage(ChatColor.RED + "You do not have sufficient access" + " to reload this server."); + } + return true; + } + } } \ No newline at end of file