Unregister commands when reloading commands.yml

This commit is contained in:
Frank van der Heijden 2021-01-02 17:00:12 +01:00
parent 02905a84f9
commit fd990ce66d
No known key found for this signature in database
GPG key ID: 26DA56488D314D11

View file

@ -88,7 +88,13 @@ public class RCraftServer {
public static void reloadCommandsConfiguration() {
SimpleCommandMap commandMap = getCommandMap();
Map<String, Command> map = RCommandMap.getKnownCommands(commandMap);
Bukkit.getCommandAliases().keySet().forEach(map::remove);
for (String alias : Bukkit.getCommandAliases().keySet()) {
Command aliasCommand = map.remove(alias);
if (aliasCommand == null) continue;
aliasCommand.unregister(commandMap);
}
YamlConfiguration commands = YamlConfiguration.loadConfiguration(getCommandsConfigFile());
reflection.set(Bukkit.getServer(), "commandsConfiguration", commands);
@ -106,6 +112,7 @@ public class RCraftServer {
);
commandMap.registerServerAliases();
RCraftServer.syncCommands();
}
/**