use of com.palmergames.bukkit.towny.command.commandobjects.AcceptCommand in project Towny by TownyAdvanced.
the class Towny method registerSpecialCommands.
// https://www.spigotmc.org/threads/small-easy-register-command-without-plugin-yml.38036/
private void registerSpecialCommands() {
List<Command> commands = new ArrayList<>(4);
commands.add(new AcceptCommand(TownySettings.getAcceptCommand()));
commands.add(new DenyCommand(TownySettings.getDenyCommand()));
commands.add(new ConfirmCommand(TownySettings.getConfirmCommand()));
commands.add(new CancelCommand(TownySettings.getCancelCommand()));
try {
final Field bukkitCommandMap = Bukkit.getServer().getClass().getDeclaredField("commandMap");
bukkitCommandMap.setAccessible(true);
CommandMap commandMap = (CommandMap) bukkitCommandMap.get(Bukkit.getServer());
commandMap.registerAll("towny", commands);
} catch (NoSuchFieldException | IllegalAccessException e) {
throw new TownyInitException("An issue has occured while registering custom commands.", TownyInitException.TownyError.OTHER, e);
}
}
Aggregations