@Override public void displayInfo(CommandSender player) { player.sendMessage( "usage: " + StringParser.colorVar(usesPowerups != null) + "(" + StringParser.colorVar(arena.getArenaConfig().getString(CFG.MODULES_POWERUPS_USAGE)) + ")"); }
@Override public void parseInfo(Arena arena, CommandSender player) { player.sendMessage(""); player.sendMessage( "§6ColoredTeams:§f " + StringParser.colorVar("hideName", arena.cfg.getBoolean("game.hideName")) + " || " + StringParser.colorVar("colorNick", arena.cfg.getBoolean("messages.colorNick")) + " || " + StringParser.colorVar("requireSpout", arena.cfg.getBoolean("colors.requireSpout"))); }
static boolean argCountValid( final CommandSender sender, final String[] args, final Integer[] validCounts) { for (final int i : validCounts) { if (i == args.length) { return true; } } Arena.pmsg( sender, Language.parse( MSG.ERROR_INVALID_ARGUMENT_COUNT, String.valueOf(args.length), StringParser.joinArray(validCounts, "|"))); return false; }
/** * take/reset an arena block * * @param blockColor the teamcolor to reset * @param paBlockLocation the location to take/reset */ void takeBlock(final String blockColor, final PABlockLocation paBlockLocation) { if (paBlockLocation == null) { return; } if ("WOOL".equals(arena.getArenaConfig().getString(CFG.GOAL_BLOCKDESTROY_BLOCKTYPE))) { paBlockLocation .toLocation() .getBlock() .setTypeIdAndData( Material.valueOf(arena.getArenaConfig().getString(CFG.GOAL_BLOCKDESTROY_BLOCKTYPE)) .getId(), StringParser.getColorDataFromENUM(blockColor), false); } else { paBlockLocation .toLocation() .getBlock() .setTypeId( Material.valueOf(arena.getArenaConfig().getString(CFG.GOAL_BLOCKDESTROY_BLOCKTYPE)) .getId()); } }
@Override public void commit(final Arena arena, final CommandSender sender, final String[] args) { if (!hasPerms(sender, arena)) { return; } if (!argCountValid(sender, arena, args, new Integer[] {1, 2, 3})) { return; } // args[0] // usage: /pa {arenaname} blacklist clear if (args.length < 2) { if ("clear".equalsIgnoreCase(args[0])) { arena.getArenaConfig().setManually(CFG.LISTS_WHITELIST.getNode(), null); arena.getArenaConfig().save(); arena.msg(sender, Language.parse(arena, MSG.WHITELIST_ALLCLEARED)); return; } arena.msg(sender, Language.parse(arena, MSG.WHITELIST_HELP)); return; } if (args.length == 2) { // usage: /pa {arenaname} blacklist [type] clear if (!SUBTYPES.contains(args[0].toLowerCase())) { arena.msg( sender, Language.parse( arena, MSG.ERROR_WHITELIST_UNKNOWN_TYPE, StringParser.joinSet(SUBTYPES, "|"))); return; } if (args[1].equalsIgnoreCase("clear")) { arena.getArenaConfig().setManually(CFG.LISTS_WHITELIST.getNode(), null); arena.getArenaConfig().save(); arena.msg(sender, Language.parse(arena, MSG.WHITELIST_ALLCLEARED)); return; } arena.msg(sender, Language.parse(arena, MSG.WHITELIST_HELP)); return; } if (!SUBTYPES.contains(args[0].toLowerCase())) { arena.msg( sender, Language.parse( arena, MSG.ERROR_WHITELIST_UNKNOWN_TYPE, StringParser.joinSet(SUBTYPES, "|"))); return; } if (!SUBCOMMANDS.contains(args[1].toLowerCase())) { arena.msg( sender, Language.parse( arena, MSG.ERROR_WHITELIST_UNKNOWN_SUBCOMMAND, StringParser.joinSet(SUBCOMMANDS, "|"))); return; } List<String> list = new ArrayList<String>(); list = arena .getArenaConfig() .getStringList(CFG.LISTS_WHITELIST.getNode() + '.' + args[0].toLowerCase(), list); if ("add".equalsIgnoreCase(args[1])) { list.add(args[2]); arena.msg(sender, Language.parse(arena, MSG.WHITELIST_ADDED, args[2], args[0].toLowerCase())); } else if ("show".equalsIgnoreCase(args[1])) { final StringBuilder output = new StringBuilder(Language.parse(arena, MSG.WHITELIST_SHOW, args[0].toLowerCase())); for (final String s : list) { output.append(": "); output.append(Material.getMaterial(Integer.parseInt(s)).name()); } if (list.size() < 1) { output.append(": ---------"); } arena.msg(sender, output.toString()); } else { list.remove(args[2]); arena.msg(sender, Language.parse(arena, MSG.WHITELIST_REMOVED, args[2], args[1])); } arena .getArenaConfig() .setManually(CFG.LISTS_WHITELIST.getNode() + '.' + args[0].toLowerCase(), list); arena.getArenaConfig().save(); }
@Override public void commit(final Arena arena, final CommandSender sender, final String[] args) { if (!hasPerms(sender, arena) || !arena.getArenaConfig().getBoolean(CFG.USES_INGAMECLASSSWITCH)) { return; } if (!argCountValid(sender, arena, args, new Integer[] {0, 1})) { return; } if (args.length < 1) { Set<String> classes = new TreeSet<String>(); for (ArenaClass ac : arena.getClasses()) { if (ac.getName().equals("custom")) { continue; } classes.add(ChatColor.GREEN + ac.getName() + ChatColor.WHITE); } arena.msg(sender, Language.parse(arena, MSG.CLASS_LIST, StringParser.joinSet(classes, ", "))); return; } if (!(sender instanceof Player)) { Arena.pmsg(sender, Language.parse(arena, MSG.ERROR_ONLY_PLAYERS)); return; } final ArenaPlayer aPlayer = ArenaPlayer.parsePlayer(sender.getName()); final ArenaClass aClass = arena.getClass(args[0]); if (aClass == null) { sender.sendMessage(Language.parse(arena, MSG.ERROR_CLASS_NOT_FOUND, args[0])); return; } if (arena.getArenaConfig().getBoolean(CFG.PERMS_EXPLICITCLASS) && !sender.hasPermission("pvparena.class." + aClass.getName())) { arena.msg(sender, Language.parse(arena, MSG.ERROR_NOPERM_CLASS, aClass.getName())); return; } if (ArenaModuleManager.cannotSelectClass(arena, (Player) sender, args[0])) { return; } PAClassSign.remove(arena.getSigns(), (Player) sender); PAClassSign oldSign = null; boolean error = false; for (PAClassSign sign : arena.getSigns()) { try { Sign s = (Sign) sign.getLocation().toLocation().getBlock().getState(); if (aPlayer.getArenaClass().getName().equals(s.getLine(0))) { oldSign = sign; } if (aClass.getName().equals(s.getLine(0))) { if (!sign.add((Player) sender)) { error = true; } } } catch (Exception e) { } } if (error) { if (oldSign != null) { oldSign.add((Player) sender); } arena.msg(sender, Language.parse(arena, MSG.ERROR_CLASS_FULL, aClass.getName())); return; } if (!arena.getArenaConfig().getBoolean(CFG.GENERAL_CLASSSWITCH_AFTER_RESPAWN) || !arena.isFightInProgress()) { InventoryManager.clearInventory(aPlayer.get()); if (aPlayer.getArenaClass() != null) { ArenaPlayer.givePlayerFightItems(arena, aPlayer.get()); arena.msg(sender, Language.parse(arena, MSG.CLASS_SELECTED, aClass.getName())); } aPlayer.setArenaClass(aClass); } else if (aPlayer.getArenaClass() != null) { arena.msg(sender, Language.parse(arena, MSG.CLASS_SELECTED_RESPAWN, aClass.getName())); aPlayer.setNextArenaClass(aClass); } }