mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-30 16:19:03 +01:00
Fixed only being able to use /reload once
By: Dinnerbone <dinnerbone@dinnerbone.com>
This commit is contained in:
parent
14c7da2f6e
commit
7d4be15159
1 changed files with 32 additions and 15 deletions
|
@ -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) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue