Search in sources :

Example 1 with EditingStage

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

the class ArenaCommandExecutor method onTabComplete.

@Override
public Collection<String> onTabComplete(CommandSender sender, String commandName, String[] args) {
    List<String> options = new ArrayList<>();
    if (args.length < 2) {
        options.addAll(Arrays.asList(SUB_COMMANDS));
    } else if (args.length == 2 && args[0].equalsIgnoreCase("leave")) {
        options.addAll(arenaController.getMagic().getPlayerNames());
    } else if (args.length == 2) {
        if (args[0].equalsIgnoreCase("add")) {
            Set<String> unusedTemplates = new HashSet<>(controller.getArenaTemplateKeys());
            unusedTemplates.removeAll(arenaController.getArenaKeys());
            options.addAll(unusedTemplates);
        } else {
            Collection<Arena> arenas = arenaController.getArenas();
            for (Arena arena : arenas) {
                options.add(arena.getKey());
            }
            if (args[0].equalsIgnoreCase("reset")) {
                options.add("ALL");
            }
        }
    } else if (args.length == 3 && args[0].equalsIgnoreCase("add")) {
        options.addAll(controller.getArenaTemplateKeys());
    } else if (args.length == 3 && args[0].equalsIgnoreCase("stage")) {
        options.addAll(Arrays.asList(STAGE_COMMANDS));
    } else if (args.length == 3 && args[0].equalsIgnoreCase("configure")) {
        options.addAll(Arrays.asList(ARENA_PROPERTIES));
    } else if (args.length == 4 && args[0].equalsIgnoreCase("configure") && (args[2].equalsIgnoreCase("add") || args[2].equalsIgnoreCase("remove"))) {
        options.addAll(Arrays.asList(ARENA_LISTS));
    } else if (args.length == 4 && args[0].equalsIgnoreCase("configure") && args[2].equalsIgnoreCase("randomize")) {
        options.addAll(Arrays.asList(ARENA_RANDOMIZE));
    } else if (args.length == 4 && args[0].equalsIgnoreCase("stage") && args[2].equalsIgnoreCase("configure")) {
        options.addAll(Arrays.asList(STAGE_PROPERTIES));
    } else if (args.length == 5 && args[0].equalsIgnoreCase("stage") && args[2].equalsIgnoreCase("configure") && (args[3].equalsIgnoreCase("add") || args[3].equalsIgnoreCase("remove"))) {
        options.addAll(Arrays.asList(STAGE_LISTS));
    } else if (args.length == 5 && args[0].equalsIgnoreCase("stage") && args[2].equalsIgnoreCase("configure") && args[3].equalsIgnoreCase("randomize")) {
        options.addAll(Arrays.asList(STAGE_RANDOMIZE));
    } else if (args.length == 4 && args[0].equalsIgnoreCase("configure") && (args[2].equalsIgnoreCase("keep_inventory") || args[2].equalsIgnoreCase("keep_level") || args[2].equalsIgnoreCase("item_wear") || args[2].equalsIgnoreCase("allow_consuming") || args[2].equalsIgnoreCase("op_check") || args[2].equalsIgnoreCase("allow_interrupt") || args[2].equalsIgnoreCase("allow_melee") || args[2].equalsIgnoreCase("allow_projectiles") || args[2].equalsIgnoreCase("heal"))) {
        options.addAll(Arrays.asList(BOOLEAN_PROPERTIES));
    } else if (args.length == 3 && args[0].equalsIgnoreCase("configure") && args[2].equalsIgnoreCase("template")) {
        for (String templateKey : arenaController.getArenaTemplateKeys()) {
            options.add(templateKey);
        }
    } else if (args.length == 4 && args[0].equalsIgnoreCase("configure") && (args[2].equalsIgnoreCase("add") || args[2].equalsIgnoreCase("remove")) && args[3].equalsIgnoreCase("magic_block")) {
        for (MagicBlock magicBlock : controller.getMagicBlocks()) {
            options.add(magicBlock.getName());
        }
    } else if (args.length == 4 && args[0].equalsIgnoreCase("configure") && args[2].equalsIgnoreCase("sudden_death_effect")) {
        for (PotionEffectType pt : PotionEffectType.values()) {
            if (pt == null)
                continue;
            String name = pt.getName();
            if (name == null)
                continue;
            options.add(name.toLowerCase());
        }
    } else if (args.length == 4 && args[0].equalsIgnoreCase("configure") && args[2].equalsIgnoreCase("spell_start")) {
        Collection<SpellTemplate> spells = arenaController.getMagic().getSpellTemplates();
        for (SpellTemplate spell : spells) {
            options.add(spell.getKey());
        }
    } else if (args.length == 3 && (args[0].equalsIgnoreCase("join") || args[0].equalsIgnoreCase("stats") || args[0].equalsIgnoreCase("reset"))) {
        options.addAll(arenaController.getMagic().getPlayerNames());
    } else if (args.length == 6 && args[0].equalsIgnoreCase("stage") && args[2].equalsIgnoreCase("configure") && args[3].equalsIgnoreCase("add") && args[4].equalsIgnoreCase("mob")) {
        options.addAll(arenaController.getMagic().getMobKeys());
        for (EntityType entityType : EntityType.values()) {
            if (entityType.isAlive() && entityType.isSpawnable()) {
                options.add(entityType.name().toLowerCase());
            }
        }
    } else if (args.length == 6 && args[0].equalsIgnoreCase("stage") && args[2].equalsIgnoreCase("configure") && args[3].equalsIgnoreCase("remove") && args[4].equalsIgnoreCase("mob")) {
        Arena arena = arenaController.getArena(args[1]);
        if (arena != null) {
            EditingStage stage = arena.getIfEditingStage();
            if (stage != null) {
                for (EntityData mob : stage.getSpawns()) {
                    String key = mob.getKey();
                    if (key != null && !key.isEmpty()) {
                        options.add(key);
                    }
                }
            }
        }
    } else if (args.length == 4 && args[0].equalsIgnoreCase("configure") && args[2].equalsIgnoreCase("leaderboard_sign_type")) {
        for (Material sign : arenaController.getMagic().getMaterialSetManager().getMaterialSet("signs").getMaterials()) {
            options.add(sign.name().toLowerCase());
        }
    }
    return options;
}
Also used : PotionEffectType(org.bukkit.potion.PotionEffectType) ArrayList(java.util.ArrayList) EntityData(com.elmakers.mine.bukkit.api.entity.EntityData) EditingStage(com.elmakers.mine.bukkit.arena.EditingStage) Material(org.bukkit.Material) Arena(com.elmakers.mine.bukkit.arena.Arena) EntityType(org.bukkit.entity.EntityType) MagicBlock(com.elmakers.mine.bukkit.api.block.magic.MagicBlock) Collection(java.util.Collection) HashSet(java.util.HashSet) SpellTemplate(com.elmakers.mine.bukkit.api.spell.SpellTemplate)

Example 2 with EditingStage

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

the class ArenaCommandExecutor method onDescribeArenaStage.

protected void onDescribeArenaStage(CommandSender sender, Arena arena) {
    EditingStage stage = arena.getEditingStage();
    stage.describe(sender);
}
Also used : EditingStage(com.elmakers.mine.bukkit.arena.EditingStage)

Example 3 with EditingStage

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

the class ArenaCommandExecutor method showCurrentStage.

protected void showCurrentStage(CommandSender sender, Arena arena) {
    EditingStage stage = arena.getEditingStage();
    int stageNumber = arena.getEditingStageIndex() + 1;
    sender.sendMessage(ChatColor.AQUA + "Current stage is now " + ChatColor.GOLD + stage.getFullName() + ChatColor.GRAY + " (" + ChatColor.YELLOW + stageNumber + ChatColor.GRAY + ")");
}
Also used : EditingStage(com.elmakers.mine.bukkit.arena.EditingStage)

Example 4 with EditingStage

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

the class ArenaCommandExecutor method onRemoveArenaStage.

protected void onRemoveArenaStage(CommandSender sender, Arena arena) {
    int stageCount = arena.getStageCount();
    if (stageCount <= 1) {
        sender.sendMessage(ChatColor.RED + "Can't remove the last stage");
        return;
    }
    EditingStage stage = arena.getEditingStage();
    arena.removeStage();
    sender.sendMessage(ChatColor.AQUA + "Removed stage: " + ChatColor.DARK_AQUA + stage.getFullName());
    showCurrentStage(sender, arena);
}
Also used : EditingStage(com.elmakers.mine.bukkit.arena.EditingStage)

Example 5 with EditingStage

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

the class ArenaCommandExecutor method onNameArenaStage.

protected void onNameArenaStage(CommandSender sender, Arena arena, String[] args) {
    EditingStage stage = arena.getEditingStage();
    if (stage instanceof DefaultStage) {
        sender.sendMessage(ChatColor.RED + "Can't rename default stage");
        return;
    }
    if (args.length == 0) {
        stage.setName(null);
        sender.sendMessage("Cleared name of " + ChatColor.YELLOW + stage.getName());
        return;
    }
    String name = StringUtils.join(args, " ");
    stage.setName(name);
    sender.sendMessage("Set name to " + ChatColor.YELLOW + stage.getName());
}
Also used : EditingStage(com.elmakers.mine.bukkit.arena.EditingStage) DefaultStage(com.elmakers.mine.bukkit.arena.DefaultStage)

Aggregations

EditingStage (com.elmakers.mine.bukkit.arena.EditingStage)5 MagicBlock (com.elmakers.mine.bukkit.api.block.magic.MagicBlock)1 EntityData (com.elmakers.mine.bukkit.api.entity.EntityData)1 SpellTemplate (com.elmakers.mine.bukkit.api.spell.SpellTemplate)1 Arena (com.elmakers.mine.bukkit.arena.Arena)1 DefaultStage (com.elmakers.mine.bukkit.arena.DefaultStage)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 HashSet (java.util.HashSet)1 Material (org.bukkit.Material)1 EntityType (org.bukkit.entity.EntityType)1 PotionEffectType (org.bukkit.potion.PotionEffectType)1