mirror of
https://github.com/PaperMC/Paper.git
synced 2025-03-10 05:39:15 +01:00
Fixed only being able to use /reload once
By: Dinnerbone <dinnerbone@dinnerbone.com>
This commit is contained in:
parent
14c7da2f6e
commit
7d4be15159
@ -14,24 +14,16 @@ import org.bukkit.plugin.PluginDescriptionFile;
|
|||||||
|
|
||||||
public final class SimpleCommandMap implements CommandMap {
|
public final class SimpleCommandMap implements CommandMap {
|
||||||
private final Map<String, Command> knownCommands = new HashMap<String, Command>();
|
private final Map<String, Command> knownCommands = new HashMap<String, Command>();
|
||||||
|
private final Server server;
|
||||||
|
|
||||||
public SimpleCommandMap(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("bukkit", new VersionCommand("version", server));
|
||||||
|
register("bukkit", new ReloadCommand("reload", 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;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -89,6 +81,7 @@ public final class SimpleCommandMap implements CommandMap {
|
|||||||
public void clearCommands() {
|
public void clearCommands() {
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
knownCommands.clear();
|
knownCommands.clear();
|
||||||
|
setDefaultCommands(server);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -189,4 +182,28 @@ public final class SimpleCommandMap implements CommandMap {
|
|||||||
return result.toString();
|
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 New Issue
Block a user