improve command reloading
This commit is contained in:
parent
945c0c9666
commit
ac197a73a1
@ -18,18 +18,16 @@ public interface VillagerOptimizerCommand extends CommandExecutor {
|
|||||||
|
|
||||||
HashSet<VillagerOptimizerCommand> commands = new HashSet<>();
|
HashSet<VillagerOptimizerCommand> commands = new HashSet<>();
|
||||||
static void reloadCommands() {
|
static void reloadCommands() {
|
||||||
|
VillagerOptimizer plugin = VillagerOptimizer.getInstance();
|
||||||
|
CommandMap commandMap = plugin.getServer().getCommandMap();
|
||||||
|
commands.forEach(command -> plugin.getCommand(command.label()).unregister(commandMap));
|
||||||
commands.clear();
|
commands.clear();
|
||||||
|
|
||||||
commands.add(new VillagerOptimizerCmd());
|
commands.add(new VillagerOptimizerCmd());
|
||||||
commands.add(new OptVillagersRadius());
|
commands.add(new OptVillagersRadius());
|
||||||
commands.add(new UnOptVillagersRadius());
|
commands.add(new UnOptVillagersRadius());
|
||||||
|
|
||||||
VillagerOptimizer plugin = VillagerOptimizer.getInstance();
|
commands.forEach(command -> plugin.getCommand(command.label()).setExecutor(command));
|
||||||
CommandMap commandMap = plugin.getServer().getCommandMap();
|
|
||||||
commands.forEach(command -> {
|
|
||||||
plugin.getCommand(command.label()).unregister(commandMap);
|
|
||||||
plugin.getCommand(command.label()).setExecutor(command);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
x
Reference in New Issue
Block a user