Search in sources :

Example 1 with AcceptCommand

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);
    }
}
Also used : ArrayList(java.util.ArrayList) ConfirmCommand(com.palmergames.bukkit.towny.command.commandobjects.ConfirmCommand) TownyInitException(com.palmergames.bukkit.towny.exceptions.initialization.TownyInitException) Field(java.lang.reflect.Field) DenyCommand(com.palmergames.bukkit.towny.command.commandobjects.DenyCommand) CancelCommand(com.palmergames.bukkit.towny.command.commandobjects.CancelCommand) ResidentCommand(com.palmergames.bukkit.towny.command.ResidentCommand) DenyCommand(com.palmergames.bukkit.towny.command.commandobjects.DenyCommand) TownyAdminCommand(com.palmergames.bukkit.towny.command.TownyAdminCommand) TownCommand(com.palmergames.bukkit.towny.command.TownCommand) TownyCommand(com.palmergames.bukkit.towny.command.TownyCommand) InviteCommand(com.palmergames.bukkit.towny.command.InviteCommand) TownyWorldCommand(com.palmergames.bukkit.towny.command.TownyWorldCommand) Command(org.bukkit.command.Command) CancelCommand(com.palmergames.bukkit.towny.command.commandobjects.CancelCommand) PlotCommand(com.palmergames.bukkit.towny.command.PlotCommand) ConfirmCommand(com.palmergames.bukkit.towny.command.commandobjects.ConfirmCommand) NationCommand(com.palmergames.bukkit.towny.command.NationCommand) AcceptCommand(com.palmergames.bukkit.towny.command.commandobjects.AcceptCommand) AcceptCommand(com.palmergames.bukkit.towny.command.commandobjects.AcceptCommand) CommandMap(org.bukkit.command.CommandMap)

Aggregations

InviteCommand (com.palmergames.bukkit.towny.command.InviteCommand)1 NationCommand (com.palmergames.bukkit.towny.command.NationCommand)1 PlotCommand (com.palmergames.bukkit.towny.command.PlotCommand)1 ResidentCommand (com.palmergames.bukkit.towny.command.ResidentCommand)1 TownCommand (com.palmergames.bukkit.towny.command.TownCommand)1 TownyAdminCommand (com.palmergames.bukkit.towny.command.TownyAdminCommand)1 TownyCommand (com.palmergames.bukkit.towny.command.TownyCommand)1 TownyWorldCommand (com.palmergames.bukkit.towny.command.TownyWorldCommand)1 AcceptCommand (com.palmergames.bukkit.towny.command.commandobjects.AcceptCommand)1 CancelCommand (com.palmergames.bukkit.towny.command.commandobjects.CancelCommand)1 ConfirmCommand (com.palmergames.bukkit.towny.command.commandobjects.ConfirmCommand)1 DenyCommand (com.palmergames.bukkit.towny.command.commandobjects.DenyCommand)1 TownyInitException (com.palmergames.bukkit.towny.exceptions.initialization.TownyInitException)1 Field (java.lang.reflect.Field)1 ArrayList (java.util.ArrayList)1 Command (org.bukkit.command.Command)1 CommandMap (org.bukkit.command.CommandMap)1