public boolean onCommand(final CommandSender sender, final Command command, final String label, final String[] args) { if (args.length < 1) { sender.sendMessage(ChatColor.RED + "Usage: /" + label + " <playerName>"); return true; } final OfflinePlayer target = Bukkit.getOfflinePlayer(args[0]); if (!target.hasPlayedBefore() && !target.isOnline()) { sender.sendMessage(ChatColor.GOLD + "Player '" + ChatColor.WHITE + args[0] + ChatColor.GOLD + "' not found."); return true; } final UUID targetUUID = target.getUniqueId(); final FactionUser factionTarget = HCF.getPlugin().getUserManager().getUser(targetUUID); final Deathban deathban = factionTarget.getDeathban(); if (deathban == null || !deathban.isActive()) { sender.sendMessage(ChatColor.RED + target.getName() + " is not death-banned."); return true; } factionTarget.removeDeathban(); Command.broadcastCommandMessage(sender, ChatColor.LIGHT_PURPLE + "A staff has revived " + target.getName() + "."); return false; }
@Override public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) { if (args.length != 2) { return Collections.emptyList(); } List<String> results = new ArrayList<>(); Collection<FactionUser> factionUsers = plugin.getUserManager().getUsers().values(); for (FactionUser factionUser : factionUsers) { Deathban deathban = factionUser.getDeathban(); if (deathban == null || !deathban.isActive()) continue; OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(factionUser.getUserUUID()); String offlineName = offlinePlayer.getName(); if (offlineName != null) { results.add(offlinePlayer.getName()); } } return results; }
@Override public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) { if (args.length != 2 || !(sender instanceof Player)) { return Collections.emptyList(); } Player player = (Player) sender; PlayerFaction playerFaction = plugin.getFactionManager().getPlayerFaction(player); if (playerFaction == null) { return Collections.emptyList(); } List<String> results = new ArrayList<>(); for (Player target : Bukkit.getOnlinePlayers()) { if (!target.equals(player) && player.canSee(target) && !results.contains(target.getName())) { Faction targetFaction = plugin.getFactionManager().getPlayerFaction(target); if (targetFaction != null && playerFaction != targetFaction) { if (playerFaction.getRequestedRelations().get(targetFaction.getUniqueID()) != RELATION && playerFaction.getRelations().get(targetFaction.getUniqueID()) != RELATION) { results.add(targetFaction.getName()); } } } } return results; }
@Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { if (args.length == 0) return false; String recipeType = args[0]; List<? extends Recipe> recipes = recipesByTypeMapper.apply(recipeType); if (recipes == null) { sender.sendMessage(ChatColor.RED + "Unknown recipe type: " + recipeType); return true; } else if (recipes.isEmpty()) { sender.sendMessage(ChatColor.RED + "No recipes found for type: " + recipeType); return true; } return sender instanceof Player ? listPlayer((Player) sender, recipeType, recipes) : listSender(sender, recipeType, recipes); }
@Override public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) { if (args.length != 1) { return Collections.emptyList(); } List<String> results = new ArrayList<>(); for (FactionUser factionUser : plugin.getUserManager().getUsers().values()) { Deathban deathban = factionUser.getDeathban(); if (deathban != null && deathban.isActive()) { OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(factionUser.getUserUUID()); String name = offlinePlayer.getName(); if (name != null) { results.add(name); } } } return BukkitUtils.getCompletions(args, results); }
@Override public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { if (!sender.hasPermission("protocolsupport.admin")) { sender.sendMessage(ChatColor.DARK_RED + "You have no power here!"); return true; } if (args.length == 0) { sender.sendMessage(ChatColor.DARK_PURPLE + "ProtocolSupportPocketStuff"); sender.sendMessage(ChatColor.GRAY + "/psps reloadpacks"); return true; } SubCommand subcommand = subcommands.get(args[0]); if (subcommand == null) { return false; } String[] subcommandargs = Arrays.copyOfRange(args, 1, args.length); if (subcommandargs.length < subcommand.getMinArgs()) { sender.sendMessage(ChatColor.DARK_RED + "Not enough args"); return true; } return subcommand.handle(sender, subcommandargs); }
@Override public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) { if (command.getName().equals("luaplugins")) { if (!commandSender.hasPermission("lukkitplus.listpl")) { commandSender.sendMessage(ChatColor.RED + "Sorry, you don't have permission."); return true; } StringBuilder pluginSentence = new StringBuilder(); int index = 0; for (LuaPlugin plugin : Environment.PLUGINS) { if (index != (Environment.PLUGINS.size() - 1)) { pluginSentence.append(plugin.getName() + ", "); } else { pluginSentence.append(plugin.getName() + ""); } index++; } commandSender.sendMessage("Plugins: " + ChatColor.GREEN + pluginSentence.toString()); return true; } return false; }
public List<String> onTabComplete(final CommandSender sender, final Command command, final String label, final String[] args) { if (args.length != 1) { return Collections.emptyList(); } final List<String> results = new ArrayList<String>(); for (final FactionUser factionUser : this.plugin.getUserManager().getUsers().values()) { final Deathban deathban = factionUser.getDeathban(); if (deathban != null && deathban.isActive()) { final OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(factionUser.getUserUUID()); final String name = offlinePlayer.getName(); if (name == null) { continue; } results.add(name); } } return BukkitUtils.getCompletions(args, results); }
public static Map<String, MonitorRecord> getCommandTimingsByPlugin(Plugin plg) { Map<String, MonitorRecord> record = new HashMap<>(); if (plg == null) { return record; } try { SimpleCommandMap simpleCommandMap = Reflection.getField(SimplePluginManager.class, "commandMap", SimpleCommandMap.class).get(Bukkit.getPluginManager()); for (Command command : simpleCommandMap.getCommands()) { if (command instanceof PluginCommand) { PluginCommand pluginCommand = (PluginCommand) command; if (plg.equals(pluginCommand.getPlugin())) { FieldAccessor<CommandExecutor> commandField = Reflection.getField(PluginCommand.class, "executor", CommandExecutor.class); CommandExecutor executor = commandField.get(pluginCommand); if (executor instanceof CommandInjector) { CommandInjector commandInjector = (CommandInjector) executor; record = mergeRecordMap(record, commandInjector.getMonitorRecordMap()); } } } } } catch (Exception e) { e.printStackTrace(); } return record; }
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { Player p = (Player) sender; if(label.equalsIgnoreCase("stats")){ if (args.length == 0) { openStatsGUI(p); }else if(args.length == 1){ Player playerStat = (Player) Bukkit.getPlayer(args[0]); if(playerStat != null){ // openStatsGUIOtherPlayer(playerStat, p); }else{ p.sendMessage(ChatColor.RED + args[0] + " is not a valid player. You can only view stats of online players."); } } return false; } return false; }
@Override public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) { List<String> options = new ArrayList<>(); // Before completion: "/dragontemplate " if (args.length == 1) { options.add("list"); plugin.getDEDManager().getDragonTemplates().stream().map(DragonTemplate::getIdentifier).forEach(t -> options.add(t)); } // Before completion: "/dragontemplate <template> " else if (args.length == 2) { options.add("view"); options.add("edit"); } else if (args.length == 3) { // Before completion: "/dragontemplate <template> edit " if (args[1].equalsIgnoreCase("edit")) { options.add("addloot"); options.add("set"); } } return options; }
@Override public boolean onCommand(CommandSender sender, Command command, String alias, String[] args) { Plugin plugin = getServer().getPluginManager().getPlugin("MeerChat"); Player senderPlayer = getServer().getPlayer(sender.getName()); // If the command was completed by the user. if (senderPlayer != null) { senderPlayer.sendMessage("§o[MeerChat is being reloaded - " + new SimpleDateFormat("HH:mm:ss").format(Calendar.getInstance().getTime()) + "]§o"); restartPlugin(plugin); senderPlayer.sendMessage("§o[MeerChat has been reloaded - " + new SimpleDateFormat("HH:mm:ss").format(Calendar.getInstance().getTime()) + "]§o"); } // If the command was completed by the console. else { Bukkit.broadcastMessage("[Server] §o[MeerChat is being reloaded - " + new SimpleDateFormat("HH:mm:ss").format(Calendar.getInstance().getTime()) + "]§o"); restartPlugin(plugin); Bukkit.broadcastMessage("[Server] §o[MeerChat has been reloaded - " + new SimpleDateFormat("HH:mm:ss").format(Calendar.getInstance().getTime()) + "]§o"); } return true; }
@Override public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) { if(s.equalsIgnoreCase("spec")) { if(!(commandSender instanceof Player)) { commandSender.sendMessage(ChatColor.RED + "You must be a player to execute this command."); return false; } Player player = (Player) commandSender; ArcadiaAPI api = Arcadia.getPlugin(Arcadia.class).getAPI(); api.getGameManager().setSpectating(player, !api.getGameManager().isSpectating(player)); if(api.getGameManager().isSpectating(player)) { api.getTranslationManager().sendTranslation("command.spec.enabled", player); } else { api.getTranslationManager().sendTranslation("command.spec.disabled", player); } if(api.getGameManager().getCurrentGame() != null) { if(!api.getGameManager().getCurrentGame().spectatorCache.contains(player)) { api.getGameManager().getCurrentGame().spectatorCache.add(player); } } } return false; }
@Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { Player p = (Player)sender; if(p.hasPermission("automessagedisplayer.setrandom")||p.isOp()) { if(args.length >= 1) { Boolean randomEnabled = Boolean.parseBoolean(args[0]); plugin.getConfig().set(RANDOM_CONFIG, randomEnabled); if(randomEnabled) { p.sendMessage("�2Random enabled. Do /reload"); } else { p.sendMessage("�4Random disabled. Do /reload"); } plugin.saveConfig(); plugin.reloadConfig(); return true; } } return false; }
@Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { if (args.length < 2) { sender.sendMessage(ChatColor.RED + "Usage: " + getUsage(label)); return true; } Faction faction = plugin.getFactionManager().getFaction(args[1]); if (!(faction instanceof EventFaction)) { sender.sendMessage(ChatColor.RED + "There is not an event faction named '" + args[1] + "'."); return true; } if (plugin.getTimerManager().getEventTimer().tryContesting(((EventFaction) faction), sender)) { sender.sendMessage(ChatColor.YELLOW + "Successfully contested " + faction.getName() + '.'); } return true; }
@Override public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) { if (args.length != 3 || !(sender instanceof Player)) { return Collections.emptyList(); } Player player = (Player) sender; PlayerFaction playerFaction = plugin.getFactionManager().getPlayerFaction(player); if (playerFaction == null || playerFaction.getMember(player.getUniqueId()).getRole() == Role.MEMBER) { return Collections.emptyList(); } List<String> results = new ArrayList<>(); for (Claim claim : playerFaction.getClaims()) { results.addAll(claim.getSubclaims().stream().map(Subclaim::getName).collect(Collectors.toList())); } return results; }
@Override public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) { if (args.length != 2) { return Collections.emptyList(); } else if (args[1].isEmpty()) { return null; } else { List<String> results = new ArrayList<>(plugin.getFactionManager().getFactionNameMap().keySet()); Player senderPlayer = sender instanceof Player ? ((Player) sender) : null; for (Player player : Bukkit.getOnlinePlayers()) { // Make sure the player can see. if (senderPlayer == null || senderPlayer.canSee(player)) { results.add(player.getName()); } } return results; } }
@Override public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) { if (args.length != 2 || !(sender instanceof Player)) { return Collections.emptyList(); } Player player = (Player) sender; PlayerFaction playerFaction = plugin.getFactionManager().getPlayerFaction(player); if (playerFaction == null || (playerFaction.getMember(player.getUniqueId()).getRole() != Role.LEADER)) { return Collections.emptyList(); } List<String> results = new ArrayList<>(); Map<UUID, FactionMember> members = playerFaction.getMembers(); for (Map.Entry<UUID, FactionMember> entry : members.entrySet()) { if (entry.getValue().getRole() != Role.LEADER) { OfflinePlayer target = Bukkit.getOfflinePlayer(entry.getKey()); String targetName = target.getName(); if (targetName != null && !results.contains(targetName)) { results.add(targetName); } } } return results; }
@Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { if (args.length < 3) { sender.sendMessage(ChatColor.RED + "Usage: " + getUsage(label)); return true; } Integer amount = JavaUtils.tryParseInt(args[2]); if (amount == null) { sender.sendMessage(ChatColor.RED + "'" + args[2] + "' is not a number."); return true; } OfflinePlayer target = BukkitUtils.offlinePlayerWithNameOrUUID(args[1]); if (!target.hasPlayedBefore() && !target.isOnline()) { sender.sendMessage(String.format(BaseConstants.PLAYER_WITH_NAME_OR_UUID_NOT_FOUND, args[1])); return true; } plugin.getDeathbanManager().setLives(target.getUniqueId(), amount); sender.sendMessage(ChatColor.YELLOW + target.getName() + " now has " + ChatColor.GOLD + amount + ChatColor.YELLOW + " lives."); return true; }
@Override public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) { if (args.length != 2 || !(sender instanceof Player)) { return Collections.emptyList(); } Player player = (Player) sender; PlayerFaction playerFaction = plugin.getFactionManager().getPlayerFaction(player); if (playerFaction == null || (playerFaction.getMember(player.getUniqueId()).getRole() == Role.MEMBER)) { return Collections.emptyList(); } List<String> results = new ArrayList<>(); for (Player target : Bukkit.getOnlinePlayers()) { if (player.canSee(target) && !results.contains(target.getName())) { if (playerFaction != plugin.getFactionManager().getPlayerFaction(target.getUniqueId())) { results.add(target.getName()); } } } return results; }
@Override public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) { if (args.length != 2 || !(sender instanceof Player)) { return Collections.emptyList(); } else if (args[1].isEmpty()) { return null; } else { Player player = (Player) sender; List<String> results = new ArrayList<>(plugin.getFactionManager().getFactionNameMap().keySet()); for (Player target : Bukkit.getOnlinePlayers()) { if (player.canSee(target) && !results.contains(target.getName())) { results.add(target.getName()); } } return results; } }
@Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { sender.sendMessage(ChatColor.GRAY + "m--------------------"); sender.sendMessage(ChatColor.AQUA + "KoTH Help"); for (CommandArgument argument : kothExecutor.getArguments()) { if (argument != this) { String permission = argument.getPermission(); if (permission == null || sender.hasPermission(permission)) { sender.sendMessage(ChatColor.GRAY + argument.getUsage(label) + " - " + argument.getDescription() + '.'); } } } sender.sendMessage(ChatColor.GRAY + "/f show <kothName> - View information about a KOTH."); sender.sendMessage(ChatColor.GRAY + "m--------------------"); return true; }
@Override public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { Gamer g = Gamer.get(sender); MatchStats stats = Nexus.getMatchStats(); int kills = stats.getKills(g); int deaths = stats.getDeaths(g); int killstreak = stats.getKillstreak(g); double kd = stats.getKD(g); String line1 = "&fMatch: &cTDM &7on &a" + Nexus.getRotary().getCurrentMap().getTitle(); String line2 = "&fKD: " + (kd >= 1 ? ChatColor.GREEN : ChatColor.RED) + kd; String line3 = "&fKillstreak: &f" + killstreak; String line4 = "&fKills: &f" + kills; String line5 = "&fDeaths: &f" + deaths; Chat.player(g, line1 + "\n" + line2 + "\n" + line3 + "\n" + line4 + "\n" + line5); return true; }
@Override public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) { ArrayList<String> a = null; if (command.getName().equalsIgnoreCase("addmin")) { a = new ArrayList<String>(); if (args.length <= 1) { if ("troll".startsWith(args[0])) { a.add("troll"); } } else if (args.length == 2) { if ("fakechat".startsWith(args[1])) { a.add("fakechat"); } if ("noreload".startsWith(args[1])) { a.add("noreload"); } } } return a; }
@Override public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) { if (command.getName().equals("luaplugin")) { if (!commandSender.hasPermission("lukkitplus.pl")) { commandSender.sendMessage(ChatColor.RED + "Sorry, you don't have permission."); return true; } if (strings.length != 1) { commandSender.sendMessage(ChatColor.RED + "Usage: /luaplugin <name>"); return true; } LuaPlugin plugin = Environment.findByName(strings[0]); if (plugin == null) { commandSender.sendMessage(ChatColor.RED + "Plugin specified doesn't exist."); return true; } commandSender.sendMessage("Name: " + ChatColor.GREEN + plugin.getName()); commandSender.sendMessage("Version: " + ChatColor.GREEN + plugin.getVersion()); commandSender.sendMessage("Description: " + ChatColor.GREEN + plugin.getDescription()); return true; } return false; }
@Override public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { if (!(sender instanceof Player)) { sender.sendMessage("Admin commands are currently only available from ingame."); return true; } Player p = (Player) sender; if (!p.isOp()) return true; if (args.length == 0) { p.sendMessage(helpPage); return true; } if (cmd.getName().equalsIgnoreCase("supplydrop")) { if (args.length == 1) { if (args[0].equalsIgnoreCase("drop")) { main.getSupplyDropManager().deliverSupplyDrop(p.getWorld()); } } } return true; }
@Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { if (!sender.hasPermission("Core.staff")) { sender.sendMessage(ChatColor.RED + "No permission."); return true; } boolean newStatus = !SettingsYML.DIAMOND_ORE_ALERTS; SettingsYML.DIAMOND_ORE_ALERTS = newStatus; Bukkit.broadcastMessage(ChatColor.GOLD + "" + sender.getName() + ChatColor.YELLOW + " has " + (newStatus ? ChatColor.GREEN +"enabled" : ChatColor.RED + "disabled") + ChatColor.YELLOW + " found diamond ore notifications."); return true; }
@SuppressWarnings("unchecked") public CPManager(VanillaPlus instance) { super(String.class, CommandPlus.class); if(CPManager.instance != null || instance == null)return; register(CPChannelSet.class, "CHANNEL_SET"); register(CPChannelState.class, "CHANNEL_STATE"); register(CPChannelTalk.class, "CHANNEL_TALK"); register(CPCurrencyPay.class, "CURRENCY_PAY"); register(CPCurrencySet.class, "CURRENCY_SET"); register(CPGamemode.class, "GAMEMODE"); register(CPLang.class, Node.LANG.get()); register(CPMenuOpen.class, "MENU_OPEN"); register(CPMessageSend.class, "MESSAGE_SEND"); register(CPMessagePrivate.class, "MESSAGE_PRIVATE"); register(CPMulti.class, "MULTI"); register(CPNick.class, "NICK"); register(CPNode.class, Node.NODE.get()); register(CPOp.class, "OP"); register(CPProfil.class, "PROFIL"); register(CPReward.class, "REWARD"); register(CPTeleportLocation.class, "TELEPORT_LOCATION"); register(CPTeleportPlayer.class, "TELEPORT_PLAYER"); register(CPTOD.class, "TOD"); //TODO show top ( stat / money ) CPManager.instance = instance; commandMap = (Map<String, Command>) ReflectionUtils.getDeclaredField("knownCommands", ReflectionUtils.invoke(ReflectionUtils.getMethod("getCommandMap", ReflectionUtils.getBukkitClass("CraftServer")), Bukkit.getServer())); }
public CreateQuestCommand(Player player, Command command, String label, String[] args) { this.player = player; this.command = command; this.label = label; this.args = args; }
@Override public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) { List<String> options = new ArrayList<>(); if (args.length == 1) { options.add("help"); options.add("reload"); } return options; }
/** * Command executor * * @param commandSender Sender * @param command Command instance * @param s Command's name * @param strings Command's arguments * * @return {@code true} is successfully executed or {@code false} */ @Override public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) { if (game.getSurvivalGameLoop() != null && game.isGameStarted()) game.getSurvivalGameLoop().forceNextEvent(); else commandSender.sendMessage(ChatColor.RED + "Erreur: la partie n'a pas commencé !"); return true; }
public static void init() { config = YamlConfiguration.loadConfiguration( CONFIG_FILE ); config.options().header( HEADER ); config.options().copyDefaults( true ); commands = new HashMap<String, Command>(); version = getInt( "config-version", 7 ); set( "config-version", 7 ); readConfig( SpigotConfig.class, null ); }
@Override public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { if ("neverlag".equalsIgnoreCase(cmd.getName())) { if (args.length == 0) { // TODO 显示帮助信息 throw new UnsupportedOperationException(); } AbstractSubCommand executor = subCommandMap.get(args[0].toLowerCase()); if (executor == null) { sender.sendMessage(i18n.tr("subCommandNotFound")); return true; } if (!sender.hasPermission(executor.getPermission())) { sender.sendMessage(i18n.tr("noPermission")); return true; } if (executor.isPlayerRequired() && !(sender instanceof Player)) { // 如果命令要求玩家才能执行, 而发送者又不是玩家 sender.sendMessage(i18n.tr("playerOnly")); } String[] subCommandArgs = Arrays.copyOfRange(args, 1, args.length); if (executor.getMinimumArgCount() > 0 && subCommandArgs.length < executor.getMinimumArgCount()) { sender.sendMessage(executor.getUsage()); return true; } try { executor.onCommand(sender, subCommandArgs); } catch (MissingCommandArgumentException ex) { if (ex.getLocalizedMessage() == null) { sender.sendMessage(executor.getUsage()); } else { sender.sendMessage(ex.getLocalizedMessage()); } } } return true; }
@Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { if (!(sender instanceof Player)) { sender.sendMessage(ChatColor.RED + "This command is only executable by players."); return true; } Player player = (Player) sender; PlayerFaction playerFaction = plugin.getFactionManager().getPlayerFaction(player); if (playerFaction == null) { sender.sendMessage(ChatColor.RED + "You are not in a faction."); return true; } List<String> subclaimNames = new ArrayList<>(); for (Claim claim : playerFaction.getClaims()) { subclaimNames.addAll(claim.getSubclaims().stream().map(Subclaim::getName).collect(Collectors.toList())); } if (subclaimNames.isEmpty()) { sender.sendMessage(ChatColor.RED + "Your faction does not own any subclaims."); return true; } sender.sendMessage(ChatColor.YELLOW + "Factions' Subclaims (" + subclaimNames.size() + "): " + ChatColor.AQUA + StringUtils.join(subclaimNames, ", ")); return true; }
@Override public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { Gamer g = Gamer.get(sender); if (g.getVariable("arena") == null) { Chat.player(sender, "&cYou are not in an arena!"); return true; } Arena a = (Arena) g.getVariable("arena"); a.leave(g.getPlayer()); g.teleport(Walls.getLobby().getSpawn()); Chat.player(sender, "&aYou have left your current match."); return true; }
private static Map<String, Command> getKnownCommandMap() { try { //noinspection unchecked return (Map<String, Command>) KNOWN_COMMANDS_FIELD.get(getCommandMap()); } catch (Exception e) { throw new RuntimeException("Could not get known commands map", e); } }
@Override public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { if (args.length == 0) { sender.sendMessage(PREFIX + "You are running version " + KevsPermissions.getPluginDetails().getVersion() + " of KevsPermissions, developed by §e" + KevsPermissions.getPluginDetails().getAuthor() + "§7."); sender.sendMessage("§7GitHub: https://github.com/KevSlashNull/KevsPermissions"); return true; } if (!sender.hasPermission("kp.command")) { sender.sendMessage(PREFIX + "§cSorry, but you are lacking a permission."); return true; } if (args[0].equalsIgnoreCase("help")) { SubHelp.a(sender, label, args); return true; } else if (args[0].equalsIgnoreCase("groups")) { SubGroups.a(sender, label, args); return true; } else if (args[0].equalsIgnoreCase("group")) { SubGroup.a(sender, label, args); return true; } else if (args[0].equalsIgnoreCase("players")) { SubPlayers.a(sender, label, args); return true; } else if (args[0].equalsIgnoreCase("player")) { SubPlayer.a(sender, label, args); return true; } else if (args[0].equalsIgnoreCase("reload")) { SubReload.a(sender, label, args); return true; } else { error(sender); } return true; }
@Override public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) { if (args.length != 2) { return Collections.emptyList(); } return plugin.getFactionManager().getFactions().stream().filter(faction -> faction instanceof EventFaction).map(Faction::getName).collect(Collectors.toList()); }