public boolean run(String[] args) { if (sender != null) { if (sender instanceof Player) Message.debug("Command issued by player: " + sender.getName()); else if (sender instanceof ConsoleCommandSender) Message.debug("Command issued by CONSOLE"); else Message.debug("Command issued by GHOSTS and WIZARDS"); } if (!allowConsole && !(sender instanceof Player)) { Message.send("This command can only be run by a living player"); return false; } if (permission != null && (sender instanceof Player) && !sender.hasPermission(permission)) { Message.send("You do not have the permission to use this command"); return false; } return clazz.run(args); }
CommandManager(Class<?> clazz, String permission, boolean allowConsole, String... args) { try { this.clazz = (BaseCommand) clazz.newInstance(); } catch (InstantiationException e) { Message.log(Level.SEVERE, "Error while instantiating a command! InstantiationException"); return; } catch (IllegalAccessException e) { Message.log(Level.SEVERE, "Error while instantiating a command! IllegalAccessException"); return; } this.permission = permission; this.allowConsole = allowConsole; alias = new ArrayList<String>(); for (String arg : args) alias.add(arg); }