Search in sources :

Example 1 with ArenaTemplate

use of com.elmakers.mine.bukkit.arena.ArenaTemplate in project MagicPlugin by elBukkit.

the class ArenaCommandExecutor method onCommand.

@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    if (!command.getName().equalsIgnoreCase("marena")) {
        return false;
    }
    if (!sender.hasPermission("magic.commands.marena")) {
        sendNoPermission(sender);
        return true;
    }
    if (args.length == 0) {
        sender.sendMessage(ChatColor.YELLOW + "---------" + ChatColor.WHITE + "Help: MagicArenas " + ChatColor.YELLOW + "--------");
        sender.sendMessage("/marena add [name] <type> : Add a new arena");
        sender.sendMessage("/marena remove [name] : Remove an existing arena");
        sender.sendMessage("/marena start [name] : Manually start an arena");
        sender.sendMessage("/marena stop [name] : Manually stop an arena");
        sender.sendMessage("/marena describe [name] : List properties of an arena");
        sender.sendMessage("/marena join [name] <player> : Force a player to join an arena");
        sender.sendMessage("/marena leave [name] <player> : Force a player to leave an arena");
        sender.sendMessage("/marena configure [name] [property] <value> : Reconfigure an arena");
        sender.sendMessage("/marena stage [name] [command] <value> : Display or configure mob arena stages");
        sender.sendMessage("/marena import : Import arenas from MagicArenas");
        sender.sendMessage(ChatColor.YELLOW + "-----------------------------------------------");
        return true;
    }
    String subCommand = args[0];
    if (!sender.hasPermission("magic.commands.marena." + subCommand)) {
        sendNoPermission(sender);
        return true;
    }
    if (subCommand.equalsIgnoreCase("import")) {
        arenaController.importArenas(sender);
        return true;
    }
    if (subCommand.equalsIgnoreCase("describe") && args.length < 2) {
        Collection<Arena> arenas = arenaController.getArenas();
        sender.sendMessage(ChatColor.BLUE + "Arenas: " + ChatColor.DARK_AQUA + arenas.size());
        for (Arena arena : arenas) {
            String arenaMessage = ChatColor.AQUA + arena.getName() + ChatColor.GRAY + " (" + arena.getKey() + ")";
            if (arena.isStarted()) {
                arenaMessage = arenaMessage + ChatColor.GREEN + " ACTIVE";
            }
            int minPlayers = arena.getMinPlayers();
            int maxPlayers = arena.getMaxPlayers();
            int queuedPlayers = arena.getQueuedPlayers();
            int inGamePlayers = arena.getInGamePlayers();
            arenaMessage = arenaMessage + ChatColor.WHITE + " (" + ChatColor.GREEN + inGamePlayers + ChatColor.WHITE + ", " + ChatColor.YELLOW + queuedPlayers + ChatColor.WHITE + " / " + ChatColor.GRAY + minPlayers + "-" + maxPlayers + ChatColor.WHITE + ")";
            sender.sendMessage(arenaMessage);
        }
        return true;
    }
    if (subCommand.equalsIgnoreCase("leave")) {
        Player player = null;
        String playerName = null;
        if (args.length > 1) {
            playerName = args[1];
            player = Bukkit.getPlayer(playerName);
        } else if (sender instanceof Player) {
            player = (Player) sender;
            playerName = player.getName();
        }
        if (player == null) {
            if (playerName != null) {
                sender.sendMessage(ChatColor.RED + "Unknown player: " + playerName);
            } else {
                sender.sendMessage(ChatColor.RED + "You must specify a player name");
            }
            return true;
        }
        ArenaPlayer leftPlayer = arenaController.leave(player);
        if (leftPlayer != null) {
            sender.sendMessage(ChatColor.AQUA + leftPlayer.getDisplayName() + " has left " + leftPlayer.getArena().getName());
        } else {
            sender.sendMessage(ChatColor.AQUA + playerName + ChatColor.RED + " is not in an arena");
        }
        return true;
    }
    if (args.length < 2) {
        sender.sendMessage(ChatColor.RED + "You must provide an arena name");
        return true;
    }
    String arenaName = args[1];
    boolean isAllArenas = arenaName.equalsIgnoreCase("ALL");
    Arena arena = isAllArenas ? null : arenaController.getArena(arenaName);
    if (subCommand.equalsIgnoreCase("add")) {
        if (!(sender instanceof Player)) {
            sender.sendMessage(ChatColor.RED + "Must be used in-game");
            return true;
        }
        Player player = (Player) sender;
        Location location = player.getLocation();
        ArenaTemplate template = null;
        if (args.length > 2) {
            template = arenaController.getTemplate(args[2]);
            if (template == null) {
                sender.sendMessage(ChatColor.RED + "Unknown arena template: " + ChatColor.WHITE + args[2]);
                return true;
            }
        } else {
            template = arenaController.getTemplate(arenaName);
        }
        if (arena == null) {
            arena = arenaController.addArena(arenaName, template, location);
            player.sendMessage(ChatColor.AQUA + "Arena Created: " + arena.getName());
        } else {
            sender.sendMessage(ChatColor.AQUA + "Arena already exists!");
        }
        return true;
    }
    if (arena == null && !isAllArenas) {
        sender.sendMessage(ChatColor.RED + "Unknown arena: " + arenaName);
        return true;
    }
    if (subCommand.equalsIgnoreCase("reset")) {
        Player player = null;
        String playerName = null;
        if (args.length > 2) {
            playerName = args[2];
            player = Bukkit.getPlayer(playerName);
        } else {
            if (isAllArenas) {
                arenaController.reset();
                sender.sendMessage(ChatColor.AQUA + "All arenas" + ChatColor.GRAY + " have been " + ChatColor.RED + " reset");
            } else {
                arena.reset();
                sender.sendMessage(ChatColor.AQUA + arena.getName() + ChatColor.GRAY + " has been " + ChatColor.RED + " reset");
            }
        }
        if (player == null) {
            if (playerName != null) {
                sender.sendMessage(ChatColor.RED + "Unknown player: " + playerName);
            } else {
                sender.sendMessage(ChatColor.RED + "You must specify a player name");
            }
            return true;
        }
        if (isAllArenas) {
            arenaController.reset(player);
            sender.sendMessage(ChatColor.AQUA + playerName + ChatColor.GRAY + " has been " + ChatColor.RED + " reset from ALL arenas");
        } else {
            arena.reset(player);
            sender.sendMessage(ChatColor.AQUA + playerName + ChatColor.GRAY + " has been " + ChatColor.RED + " reset from " + ChatColor.GOLD + arena.getName());
        }
        return true;
    }
    if (isAllArenas) {
        sender.sendMessage(ChatColor.RED + "ALL not applicable here.");
        return true;
    }
    if (subCommand.equalsIgnoreCase("remove")) {
        arenaController.remove(arenaName);
        sender.sendMessage(ChatColor.RED + "Arena Removed: " + ChatColor.DARK_RED + arena.getName());
        return true;
    }
    if (subCommand.equalsIgnoreCase("start")) {
        arena.startCountdown();
        return true;
    }
    if (subCommand.equalsIgnoreCase("describe")) {
        arena.describe(sender);
        return true;
    }
    if (subCommand.equalsIgnoreCase("stop")) {
        if (arena.stop()) {
            sender.sendMessage(ChatColor.AQUA + "Match stopped!");
        } else {
            sender.sendMessage(ChatColor.AQUA + "Arena not active");
        }
        return true;
    }
    if (subCommand.equalsIgnoreCase("stats")) {
        if (args.length > 2) {
            String playerName = args[2];
            Player player = Bukkit.getPlayer(playerName);
            if (player == null) {
                sender.sendMessage(ChatColor.RED + "Unknown player: " + playerName);
                return true;
            }
            arena.describeStats(sender, player);
        } else {
            arena.describeLeaderboard(sender);
        }
        return true;
    }
    if (subCommand.equalsIgnoreCase("join")) {
        Player player = null;
        String playerName = null;
        if (args.length > 2) {
            playerName = args[2];
            player = Bukkit.getPlayer(playerName);
        } else if (sender instanceof Player) {
            player = (Player) sender;
        }
        if (player == null) {
            if (playerName != null) {
                sender.sendMessage(ChatColor.RED + "Unknown player: " + playerName);
            } else {
                sender.sendMessage(ChatColor.RED + "You must specify a player name");
            }
            return true;
        }
        arena.join(player);
        return true;
    }
    if (subCommand.equalsIgnoreCase("configure")) {
        if (args.length < 3) {
            sender.sendMessage(ChatColor.RED + "Must specify a property name: ");
            sender.sendMessage(ChatColor.YELLOW + StringUtils.join(ARENA_PROPERTIES, ','));
            return true;
        }
        String propertyName = args[2];
        String[] configureArgs;
        if (args.length > 3) {
            configureArgs = new String[args.length - 3];
            System.arraycopy(args, 3, configureArgs, 0, args.length - 3);
        } else {
            configureArgs = new String[0];
        }
        onConfigureArena(sender, arena, propertyName, configureArgs);
        return true;
    }
    if (subCommand.equalsIgnoreCase("stage")) {
        if (args.length < 3) {
            sender.sendMessage("TODO: Stage overview for arena");
            return true;
        }
        String stageCommand = args[2];
        args = Arrays.copyOfRange(args, 3, args.length);
        onArenaStage(sender, arena, stageCommand, args);
        return true;
    }
    sender.sendMessage(ChatColor.RED + "Not a valid option: " + subCommand);
    sender.sendMessage(ChatColor.AQUA + "Options: " + StringUtils.join(SUB_COMMANDS, ", "));
    return true;
}
Also used : Player(org.bukkit.entity.Player) ArenaPlayer(com.elmakers.mine.bukkit.arena.ArenaPlayer) ArenaTemplate(com.elmakers.mine.bukkit.arena.ArenaTemplate) Arena(com.elmakers.mine.bukkit.arena.Arena) ArenaPlayer(com.elmakers.mine.bukkit.arena.ArenaPlayer) Location(org.bukkit.Location)

Example 2 with ArenaTemplate

use of com.elmakers.mine.bukkit.arena.ArenaTemplate in project MagicPlugin by elBukkit.

the class ArenaCommandExecutor method onConfigureArena.

protected void onConfigureArena(CommandSender sender, Arena arena, String propertyName, String[] args) {
    if (propertyName.equalsIgnoreCase("randomize")) {
        String randomizeType = "spawn";
        if (args.length > 0) {
            randomizeType = args[0];
        }
        String vectorParameter = null;
        if (args.length > 1) {
            vectorParameter = args[1];
        }
        if (randomizeType.equalsIgnoreCase("spawn")) {
            if (vectorParameter == null || vectorParameter.isEmpty()) {
                sender.sendMessage(ChatColor.RED + "Cleared randomized spawn of " + arena.getName());
                arena.setRandomizeSpawn(null);
            } else {
                Vector vector = ConfigurationUtils.toVector(vectorParameter);
                sender.sendMessage(ChatColor.AQUA + "Set randomized spawn of " + arena.getName() + " to " + vector);
                arena.setRandomizeSpawn(vector);
            }
            return;
        }
        sender.sendMessage(ChatColor.RED + "Not a valid randomization option: " + randomizeType);
        sender.sendMessage(ChatColor.AQUA + "Options: " + StringUtils.join(ARENA_RANDOMIZE, ", "));
        return;
    }
    if (propertyName.equalsIgnoreCase("lobby") || propertyName.equalsIgnoreCase("spawn") || propertyName.equalsIgnoreCase("win") || propertyName.equalsIgnoreCase("lose") || propertyName.equalsIgnoreCase("center") || propertyName.equalsIgnoreCase("exit") || propertyName.equalsIgnoreCase("add") || propertyName.equalsIgnoreCase("remove")) {
        boolean isAdd = propertyName.equalsIgnoreCase("add");
        boolean isRemove = propertyName.equalsIgnoreCase("remove");
        if (isAdd || isRemove) {
            String subItem = "spawn";
            if (args.length > 0) {
                subItem = args[0];
            }
            if (subItem.equalsIgnoreCase("spawn")) {
                if (!(sender instanceof Player)) {
                    sender.sendMessage(ChatColor.RED + "Must be used in-game");
                    return;
                }
                Player player = (Player) sender;
                Location location = player.getLocation();
                if (isAdd) {
                    arena.addSpawn(location);
                    sender.sendMessage(ChatColor.AQUA + "You have added a spawn location!");
                } else {
                    Location removed = arena.removeSpawn(location);
                    if (removed != null) {
                        sender.sendMessage(ChatColor.AQUA + "You have removed a spawn location at: " + removed.toVector());
                    } else {
                        sender.sendMessage(ChatColor.RED + "No nearby spawn locations");
                    }
                }
                return;
            }
            if (subItem.equalsIgnoreCase("magic_block")) {
                if (args.length < 2) {
                    sender.sendMessage(ChatColor.RED + "Usage: " + ChatColor.WHITE + "/marena configure <arena> add magic_block <block name>");
                    return;
                }
                String blockKey = args[1];
                if (isAdd) {
                    MagicBlock magicBlock = controller.getMagicBlock(blockKey);
                    if (magicBlock == null) {
                        sender.sendMessage(ChatColor.RED + "Could not find magic block: " + ChatColor.WHITE + blockKey);
                        return;
                    }
                    magicBlock.disable();
                    arena.addMagicBlock(blockKey);
                    sender.sendMessage(ChatColor.AQUA + "You have added a magic block to this arena: " + ChatColor.DARK_AQUA + blockKey);
                } else {
                    boolean removed = arena.removeMagicBlock(blockKey);
                    if (removed) {
                        sender.sendMessage(ChatColor.AQUA + "You have removed the magic block: " + ChatColor.DARK_AQUA + blockKey);
                    } else {
                        sender.sendMessage(ChatColor.RED + "This arena doesn't have a magic block " + ChatColor.YELLOW + blockKey);
                    }
                }
                return;
            }
            sender.sendMessage(ChatColor.RED + "Not a valid add/remove option: " + subItem);
            sender.sendMessage(ChatColor.AQUA + "Options: " + StringUtils.join(ARENA_LISTS, ", "));
            return;
        }
        if (!(sender instanceof Player)) {
            sender.sendMessage(ChatColor.RED + "Must be used in-game");
            return;
        }
        Player player = (Player) sender;
        Location location = player.getLocation();
        if (propertyName.equalsIgnoreCase("lobby")) {
            arena.setLobby(location);
            sender.sendMessage(ChatColor.AQUA + "You have set the lobby!");
        } else if (propertyName.equalsIgnoreCase("spawn")) {
            arena.setSpawn(location);
            sender.sendMessage(ChatColor.AQUA + "You have set the spawn location!");
        } else if (propertyName.equalsIgnoreCase("exit")) {
            arena.setExit(location);
            sender.sendMessage(ChatColor.AQUA + "You have set the exit location!");
        } else if (propertyName.equalsIgnoreCase("center")) {
            arena.setCenter(location);
            sender.sendMessage(ChatColor.AQUA + "You have set the center location!");
        } else if (propertyName.equalsIgnoreCase("lose")) {
            arena.setLoseLocation(location);
            sender.sendMessage(ChatColor.AQUA + "You have set the spectating room!");
        } else if (propertyName.equalsIgnoreCase("win")) {
            arena.setWinLocation(location);
            sender.sendMessage(ChatColor.AQUA + "You have set the treasure room!");
        }
        return;
    }
    String propertyValue = null;
    if (args.length > 0) {
        propertyValue = StringUtils.join(args, " ");
    }
    if (propertyName.equalsIgnoreCase("name")) {
        if (propertyValue == null || propertyValue.isEmpty()) {
            sender.sendMessage(ChatColor.RED + "Cleared name of " + arena.getName());
        } else {
            sender.sendMessage(ChatColor.AQUA + "Changed name of " + arena.getName() + " to " + propertyValue);
        }
        arena.setName(propertyValue);
        return;
    }
    if (propertyName.equalsIgnoreCase("description")) {
        if (propertyValue == null || propertyValue.isEmpty()) {
            sender.sendMessage(ChatColor.RED + "Cleared description of " + arena.getName());
        } else {
            sender.sendMessage(ChatColor.AQUA + "Change description of " + arena.getName() + " to " + propertyValue);
        }
        arena.setDescription(propertyValue);
        return;
    }
    if (propertyName.equalsIgnoreCase("portal_death_message")) {
        if (propertyValue == null || propertyValue.isEmpty()) {
            sender.sendMessage(ChatColor.RED + "Cleared portal death message of " + arena.getName());
        } else {
            sender.sendMessage(ChatColor.AQUA + "Change portal death message of " + arena.getName() + " to " + propertyValue);
        }
        arena.setPortalDeathMessage(propertyValue);
        return;
    }
    if (propertyName.equalsIgnoreCase("sudden_death_effect")) {
        if (arena.setSuddenDeathEffect(propertyValue)) {
            sender.sendMessage(ChatColor.AQUA + "Set sudden death effects for " + arena.getName());
        } else {
            sender.sendMessage(ChatColor.RED + "Cleared sudden death effects for " + arena.getName());
        }
        return;
    }
    if (propertyName.equalsIgnoreCase("start_commands")) {
        arena.setStartCommands(propertyValue);
        if (propertyValue == null || propertyValue.isEmpty()) {
            sender.sendMessage(ChatColor.RED + "Cleared start commands for " + arena.getName());
        } else {
            sender.sendMessage(ChatColor.AQUA + "Set start commands for " + arena.getName());
        }
        return;
    }
    if (propertyName.equalsIgnoreCase("end_commands")) {
        arena.setEndCommands(propertyValue);
        if (propertyValue == null || propertyValue.isEmpty()) {
            sender.sendMessage(ChatColor.RED + "Cleared end commands for " + arena.getName());
        } else {
            sender.sendMessage(ChatColor.AQUA + "Set end commands for " + arena.getName());
        }
        return;
    }
    if (propertyName.equalsIgnoreCase("template")) {
        if (propertyValue == null) {
            arena.setTemplate(null);
            sender.sendMessage(ChatColor.YELLOW + "Cleared template for " + ChatColor.GOLD + arena.getName());
            return;
        }
        ArenaTemplate template = arenaController.getTemplate(propertyValue);
        if (template == null) {
            sender.sendMessage(ChatColor.RED + "Unknown arena tempalte " + ChatColor.YELLOW + propertyValue);
            return;
        }
        arena.setTemplate(template);
        sender.sendMessage(ChatColor.AQUA + "Set template to " + ChatColor.DARK_AQUA + propertyValue);
        return;
    }
    if (propertyName.equalsIgnoreCase("border")) {
        if (propertyValue == null || propertyValue.isEmpty()) {
            arena.setBorder(0, 0);
            sender.sendMessage(ChatColor.RED + "Cleared border for " + arena.getName());
        } else {
            int min = 0;
            int max = 0;
            try {
                if (propertyValue.contains("-")) {
                    String[] pieces = StringUtils.split(propertyValue, '-');
                    max = Integer.parseInt(pieces[0]);
                    min = Integer.parseInt(pieces[1]);
                    if (min > max) {
                        int temp = min;
                        min = max;
                        max = temp;
                    }
                } else {
                    max = Integer.parseInt(propertyValue);
                }
            } catch (Exception ignore) {
            }
            arena.setBorder(min, max);
            sender.sendMessage(ChatColor.AQUA + "Set border for " + arena.getName() + " to " + max + "-" + min);
        }
        return;
    }
    if (propertyValue == null) {
        sender.sendMessage(ChatColor.RED + "Must specify a property value");
        return;
    }
    if (propertyName.equalsIgnoreCase("op_check")) {
        boolean checkOn = propertyValue.equalsIgnoreCase("true");
        if (checkOn) {
            sender.sendMessage(ChatColor.RED + "Enabled OP check for " + arena.getName());
        } else {
            sender.sendMessage(ChatColor.AQUA + "Disabled OP check for " + arena.getName());
        }
        arena.setOpCheck(checkOn);
        return;
    }
    if (propertyName.equalsIgnoreCase("allow_interrupt")) {
        boolean checkOn = propertyValue.equalsIgnoreCase("true");
        if (checkOn) {
            sender.sendMessage(ChatColor.RED + "Allow joining mid-match for " + arena.getName());
        } else {
            sender.sendMessage(ChatColor.AQUA + "Don't allow joining mid-match for " + arena.getName());
        }
        arena.setAllowInterrupt(checkOn);
        return;
    }
    if (propertyName.equalsIgnoreCase("keep_inventory")) {
        boolean keepOn = propertyValue.equalsIgnoreCase("true");
        if (keepOn) {
            sender.sendMessage(ChatColor.GREEN + "Enabled keep inventory for " + arena.getName());
        } else {
            sender.sendMessage(ChatColor.RED + "Disabled keep inventory for " + arena.getName());
        }
        arena.setKeepInventory(keepOn);
        return;
    }
    if (propertyName.equalsIgnoreCase("item_wear")) {
        boolean wear = propertyValue.equalsIgnoreCase("true");
        if (wear) {
            sender.sendMessage(ChatColor.GREEN + "Enabled item wear for " + arena.getName());
        } else {
            sender.sendMessage(ChatColor.RED + "Disabled item wear for " + arena.getName());
        }
        arena.setItemWear(wear);
        return;
    }
    if (propertyName.equalsIgnoreCase("allow_consuming")) {
        boolean consume = propertyValue.equalsIgnoreCase("true");
        if (consume) {
            sender.sendMessage(ChatColor.GREEN + "Enabled consuming for " + arena.getName());
        } else {
            sender.sendMessage(ChatColor.RED + "Disabled consuming for " + arena.getName());
        }
        arena.setAllowConsuming(consume);
        return;
    }
    if (propertyName.equalsIgnoreCase("heal")) {
        boolean heal = propertyValue.equalsIgnoreCase("true");
        if (heal) {
            sender.sendMessage(ChatColor.GREEN + "Enabled healing for " + arena.getName());
        } else {
            sender.sendMessage(ChatColor.RED + "Disabled healing for " + arena.getName());
        }
        arena.setHeal(heal);
        return;
    }
    if (propertyName.equalsIgnoreCase("allow_melee")) {
        boolean allow = propertyValue.equalsIgnoreCase("true");
        if (allow) {
            sender.sendMessage(ChatColor.GREEN + "Enabled melee for " + arena.getName());
        } else {
            sender.sendMessage(ChatColor.RED + "Disabled melee for " + arena.getName());
        }
        arena.setAllowMelee(allow);
        return;
    }
    if (propertyName.equalsIgnoreCase("allow_projectiles")) {
        boolean allow = propertyValue.equalsIgnoreCase("true");
        if (allow) {
            sender.sendMessage(ChatColor.GREEN + "Enabled projectile weapons for " + arena.getName());
        } else {
            sender.sendMessage(ChatColor.RED + "Disabled projectile weapons for " + arena.getName());
        }
        arena.setAllowProjectiles(allow);
        return;
    }
    if (propertyName.equalsIgnoreCase("leaderboard_sign_type")) {
        try {
            Material signMaterial = Material.valueOf(propertyValue.toUpperCase());
            arena.setLeaderboardSignType(signMaterial);
            sender.sendMessage(ChatColor.RED + "Set leaderboard sign type to " + signMaterial.name().toLowerCase());
            arena.updateLeaderboard();
        } catch (Exception ex) {
            sender.sendMessage(ChatColor.RED + "Invalid sign type: " + propertyValue);
        }
        return;
    }
    if (propertyName.equalsIgnoreCase("keep_level")) {
        boolean keepOn = propertyValue.equalsIgnoreCase("true");
        if (keepOn) {
            sender.sendMessage(ChatColor.GREEN + "Enabled keep XP levels for " + arena.getName());
        } else {
            sender.sendMessage(ChatColor.RED + "Disabled keep XP levels for " + arena.getName());
        }
        arena.setKeepLevel(keepOn);
        return;
    }
    if (propertyName.equalsIgnoreCase("min") || propertyName.equalsIgnoreCase("max") || propertyName.equalsIgnoreCase("portal_damage") || propertyName.equalsIgnoreCase("portal_enter_damage") || propertyName.equalsIgnoreCase("leaderboard_games_required") || propertyName.equalsIgnoreCase("leaderboard_size") || propertyName.equalsIgnoreCase("leaderboard_record_size") || propertyName.equalsIgnoreCase("max_teleport_distance") || propertyName.equalsIgnoreCase("win_xp") || propertyName.equalsIgnoreCase("lose_xp") || propertyName.equalsIgnoreCase("draw_xp") || propertyName.equalsIgnoreCase("win_sp") || propertyName.equalsIgnoreCase("lose_sp") || propertyName.equalsIgnoreCase("draw_sp") || propertyName.equalsIgnoreCase("win_money") || propertyName.equalsIgnoreCase("lose_money") || propertyName.equalsIgnoreCase("draw_money") || propertyName.equalsIgnoreCase("countdown") || propertyName.equalsIgnoreCase("countdown_max") || propertyName.equalsIgnoreCase("announcer_range") || propertyName.equalsIgnoreCase("duration") || propertyName.equalsIgnoreCase("sudden_death")) {
        Integer intValue;
        try {
            intValue = Integer.parseInt(propertyValue);
        } catch (Exception ex) {
            intValue = null;
        }
        if (intValue == null) {
            sender.sendMessage(ChatColor.RED + "Not a valid integer: " + propertyValue);
            return;
        }
        if (propertyName.equalsIgnoreCase("duration")) {
            arena.setDuration(intValue * 1000);
            sender.sendMessage(ChatColor.AQUA + "Set duration of " + arena.getName() + " to " + intValue + " seconds");
            return;
        }
        if (propertyName.equalsIgnoreCase("sudden_death")) {
            arena.setSuddenDeath(intValue * 1000);
            sender.sendMessage(ChatColor.AQUA + "Set sudden death time of " + arena.getName() + " to " + intValue + " seconds before end");
            return;
        }
        if (propertyName.equalsIgnoreCase("countdown")) {
            arena.setCountdown(intValue);
            sender.sendMessage(ChatColor.AQUA + "Set countdown of " + arena.getName() + " to " + intValue + " seconds");
            return;
        }
        if (propertyName.equalsIgnoreCase("countdown_max")) {
            arena.setCountdownMax(intValue);
            sender.sendMessage(ChatColor.AQUA + "Set max countdown of " + arena.getName() + " to " + intValue + " seconds");
            return;
        }
        if (propertyName.equalsIgnoreCase("max_teleport_distance")) {
            arena.setMaxTeleportDistance(intValue);
            sender.sendMessage(ChatColor.AQUA + "Set max teleport distance of " + arena.getName() + " to " + intValue);
            return;
        }
        if (propertyName.equalsIgnoreCase("announcer_range")) {
            arena.setAnnouncerRange(intValue);
            sender.sendMessage(ChatColor.AQUA + "Set announcer range of " + arena.getName() + " to " + intValue);
            return;
        }
        if (propertyName.equalsIgnoreCase("leaderboard_games_required")) {
            arena.setLeaderboardGamesRequired(intValue);
            sender.sendMessage(ChatColor.AQUA + "Set # games required for leaderboard on " + arena.getName() + " to " + intValue);
            return;
        }
        if (propertyName.equalsIgnoreCase("leaderboard_size")) {
            arena.setLeaderboardSize(intValue);
            sender.sendMessage(ChatColor.AQUA + "Set leaderboard size of " + arena.getName() + " to " + intValue);
            return;
        }
        if (propertyName.equalsIgnoreCase("leaderboard_record_size")) {
            arena.setLeaderboardRecordSize(intValue);
            sender.sendMessage(ChatColor.AQUA + "Set leaderboard record size of " + arena.getName() + " to " + intValue);
            return;
        }
        if (propertyName.equalsIgnoreCase("min")) {
            arena.setMinPlayers(intValue);
            sender.sendMessage(ChatColor.AQUA + "Set min players of " + arena.getName() + " to " + intValue);
            return;
        }
        if (propertyName.equalsIgnoreCase("max")) {
            arena.setMaxPlayers(intValue);
            sender.sendMessage(ChatColor.AQUA + "Set max players of " + arena.getName() + " to " + intValue);
            return;
        }
        if (propertyName.equalsIgnoreCase("win_xp")) {
            arena.setWinXP(intValue);
            sender.sendMessage(ChatColor.AQUA + "Set winning XP of " + arena.getName() + " to " + intValue);
            return;
        }
        if (propertyName.equalsIgnoreCase("lose_xp")) {
            arena.setLoseXP(intValue);
            sender.sendMessage(ChatColor.AQUA + "Set losing XP of " + arena.getName() + " to " + intValue);
            return;
        }
        if (propertyName.equalsIgnoreCase("draw_xp")) {
            arena.setDrawXP(intValue);
            sender.sendMessage(ChatColor.AQUA + "Set draw XP of " + arena.getName() + " to " + intValue);
            return;
        }
        if (propertyName.equalsIgnoreCase("win_sp")) {
            arena.setWinSP(intValue);
            sender.sendMessage(ChatColor.AQUA + "Set winning SP of " + arena.getName() + " to " + intValue);
            return;
        }
        if (propertyName.equalsIgnoreCase("lose_sp")) {
            arena.setLoseSP(intValue);
            sender.sendMessage(ChatColor.AQUA + "Set losing SP of " + arena.getName() + " to " + intValue);
            return;
        }
        if (propertyName.equalsIgnoreCase("draw_sp")) {
            arena.setDrawSP(intValue);
            sender.sendMessage(ChatColor.AQUA + "Set draw SP of " + arena.getName() + " to " + intValue);
            return;
        }
        if (propertyName.equalsIgnoreCase("win_money")) {
            arena.setWinMoney(intValue);
            sender.sendMessage(ChatColor.AQUA + "Set winning money of " + arena.getName() + " to " + intValue);
            return;
        }
        if (propertyName.equalsIgnoreCase("lose_money")) {
            arena.setLoseMoney(intValue);
            sender.sendMessage(ChatColor.AQUA + "Set losing money of " + arena.getName() + " to " + intValue);
            return;
        }
        if (propertyName.equalsIgnoreCase("draw_money")) {
            arena.setDrawMoney(intValue);
            sender.sendMessage(ChatColor.AQUA + "Set draw money of " + arena.getName() + " to " + intValue);
            return;
        }
        if (propertyName.equalsIgnoreCase("portal_damage")) {
            arena.setPortalDamage(intValue);
            sender.sendMessage(ChatColor.AQUA + "Set portal damage of " + arena.getName() + " to " + intValue);
            return;
        }
        if (propertyName.equalsIgnoreCase("portal_enter_damage")) {
            arena.setPortalEnterDamage(intValue);
            sender.sendMessage(ChatColor.AQUA + "Set portal entry damage of " + arena.getName() + " to " + intValue);
            return;
        }
    }
    sender.sendMessage(ChatColor.RED + "Not a valid property: " + propertyName);
    sender.sendMessage(ChatColor.AQUA + "Options: " + StringUtils.join(ARENA_PROPERTIES, ", "));
}
Also used : MagicBlock(com.elmakers.mine.bukkit.api.block.magic.MagicBlock) Player(org.bukkit.entity.Player) ArenaPlayer(com.elmakers.mine.bukkit.arena.ArenaPlayer) Material(org.bukkit.Material) Vector(org.bukkit.util.Vector) ArenaTemplate(com.elmakers.mine.bukkit.arena.ArenaTemplate) Location(org.bukkit.Location)

Aggregations

ArenaPlayer (com.elmakers.mine.bukkit.arena.ArenaPlayer)2 ArenaTemplate (com.elmakers.mine.bukkit.arena.ArenaTemplate)2 Location (org.bukkit.Location)2 Player (org.bukkit.entity.Player)2 MagicBlock (com.elmakers.mine.bukkit.api.block.magic.MagicBlock)1 Arena (com.elmakers.mine.bukkit.arena.Arena)1 Material (org.bukkit.Material)1 Vector (org.bukkit.util.Vector)1