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