public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { if (sender instanceof Player) { if (!Permissions.has((Player) sender, "MyPet.admin", false)) { return true; } } if (args.length < 1) { sender.sendMessage(MyPetPlugin.getPlugin().getCommand("mypetadmin").getDescription()); return false; } String[] parameter = Arrays.copyOfRange(args, 1, args.length); CommandOption option = commandOptions.get(args[0].toLowerCase()); if (option != null) { return option.onCommandOption(sender, parameter); } return false; }
@Override public List<String> onTabComplete( CommandSender commandSender, Command command, String s, String[] strings) { if (commandSender instanceof Player && !Permissions.has((Player) commandSender, "MyPet.admin", false)) { return emptyList; } if (strings.length == 1) { if (optionsList.size() != commandOptions.keySet().size()) { optionsList = new ArrayList<>(commandOptions.keySet()); Collections.sort(optionsList); } return optionsList; } else if (strings.length >= 1) { CommandOption co = commandOptions.get(strings[0]); if (co != null) { if (co instanceof CommandOptionTabCompleter) { return ((CommandOptionTabCompleter) co).onTabComplete(commandSender, strings); } } } return emptyList; }