diff options
author | Dinnerbone <dinnerbone@dinnerbone.com> | 2011-01-28 14:24:54 +0000 |
---|---|---|
committer | Dinnerbone <dinnerbone@dinnerbone.com> | 2011-01-28 14:24:54 +0000 |
commit | c565b51d2026ffc44a1f8b0fd4440a83d7f181fd (patch) | |
tree | d9f7f1cd2cf1ea75e320db338afea964a7e920cf /src | |
parent | 99549ef8cc1a0259f7bab605f722233dad0aeea8 (diff) | |
download | bukkit-c565b51d2026ffc44a1f8b0fd4440a83d7f181fd.tar bukkit-c565b51d2026ffc44a1f8b0fd4440a83d7f181fd.tar.gz bukkit-c565b51d2026ffc44a1f8b0fd4440a83d7f181fd.tar.lz bukkit-c565b51d2026ffc44a1f8b0fd4440a83d7f181fd.tar.xz bukkit-c565b51d2026ffc44a1f8b0fd4440a83d7f181fd.zip |
Fixed only being able to use /reload once
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/org/bukkit/command/SimpleCommandMap.java | 47 |
1 files changed, 32 insertions, 15 deletions
diff --git a/src/main/java/org/bukkit/command/SimpleCommandMap.java b/src/main/java/org/bukkit/command/SimpleCommandMap.java index 79fe285b..729c32a0 100644 --- a/src/main/java/org/bukkit/command/SimpleCommandMap.java +++ b/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<String, Command> knownCommands = new HashMap<String, Command>(); + private final Server server; public SimpleCommandMap(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."); - } + this.server = server; + setDefaultCommands(server); + } - return true; - } - }); + private void setDefaultCommands(final Server server) { + register("bukkit", new VersionCommand("version", server)); + 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 |