Allow Reloading of Command Aliases

Reload the aliases stored in commands.yml
This commit is contained in:
willies952002 2016-11-28 10:21:52 -05:00
parent 3e9512a6fc
commit 76de1e898e

View File

@ -2844,5 +2844,24 @@ public final class CraftServer implements Server {
DefaultPermissions.registerCorePermissions();
CraftDefaultPermissions.registerCorePermissions();
}
@Override
public boolean reloadCommandAliases() {
Set<String> removals = getCommandAliases().keySet().stream()
.map(key -> key.toLowerCase(java.util.Locale.ENGLISH))
.collect(java.util.stream.Collectors.toSet());
getCommandMap().getKnownCommands().keySet().removeIf(removals::contains);
File file = getCommandsConfigFile();
try {
commandsConfiguration.load(file);
} catch (FileNotFoundException ex) {
return false;
} catch (IOException | org.bukkit.configuration.InvalidConfigurationException ex) {
Bukkit.getLogger().log(Level.SEVERE, "Cannot load " + file, ex);
return false;
}
commandMap.registerServerAliases();
return true;
}
// Paper end
}