Search in sources :

Example 16 with Scoreboard

use of org.bukkit.scoreboard.Scoreboard in project Denizen-For-Bukkit by DenizenScript.

the class TeamCommand method execute.

@Override
public void execute(ScriptEntry scriptEntry) {
    ElementTag id = scriptEntry.getElement("id");
    ElementTag name = scriptEntry.getElement("name");
    ListTag add = scriptEntry.getObjectTag("add");
    ListTag remove = scriptEntry.getObjectTag("remove");
    ElementTag prefix = scriptEntry.getElement("prefix");
    ElementTag suffix = scriptEntry.getElement("suffix");
    ElementTag option = scriptEntry.getElement("option");
    ElementTag status = scriptEntry.getElement("status");
    ElementTag color = scriptEntry.getElement("color");
    if (scriptEntry.dbCallShouldDebug()) {
        Debug.report(scriptEntry, getName(), id, name, add, remove, prefix, suffix, color, option, status);
    }
    Scoreboard board;
    if (id.asString().equalsIgnoreCase("main")) {
        board = ScoreboardHelper.getMain();
    } else {
        if (ScoreboardHelper.hasScoreboard(id.asString())) {
            board = ScoreboardHelper.getScoreboard(id.asString());
        } else {
            board = ScoreboardHelper.createScoreboard(id.asString());
        }
    }
    Team team = board.getTeam(name.asString());
    if (team == null) {
        String low = CoreUtilities.toLowerCase(name.asString());
        team = board.getTeams().stream().filter(t -> CoreUtilities.toLowerCase(t.getName()).equals(low)).findFirst().orElse(null);
        if (team == null) {
            team = board.registerNewTeam(name.asString());
        }
    }
    if (add != null) {
        for (String string : add) {
            string = translateEntry(string, scriptEntry.context);
            if (!team.hasEntry(string)) {
                team.addEntry(string);
            }
        }
    }
    if (remove != null) {
        for (String string : remove) {
            string = translateEntry(string, scriptEntry.context);
            if (team.hasEntry(string)) {
                team.removeEntry(string);
            }
        }
    }
    if (option != null) {
        String optName = CoreUtilities.toLowerCase(option.asString());
        String statusName = CoreUtilities.toLowerCase(status.asString());
        if (optName.equals("friendly_fire")) {
            team.setAllowFriendlyFire(statusName.equals("always"));
        } else if (optName.equals("see_invisible")) {
            team.setCanSeeFriendlyInvisibles(statusName.equals("always"));
        } else {
            team.setOption(Team.Option.valueOf(optName.toUpperCase()), Team.OptionStatus.valueOf(statusName.toUpperCase()));
        }
    }
    if (prefix != null) {
        team.setPrefix(prefix.asString());
    }
    if (suffix != null) {
        team.setSuffix(suffix.asString());
    }
    if (color != null) {
        team.setColor(ChatColor.valueOf(color.asString().toUpperCase()));
    }
    if (team.getEntries().isEmpty()) {
        team.unregister();
    }
}
Also used : ListTag(com.denizenscript.denizencore.objects.core.ListTag) Team(org.bukkit.scoreboard.Team) PlayerTag(com.denizenscript.denizen.objects.PlayerTag) InvalidArgumentsException(com.denizenscript.denizencore.exceptions.InvalidArgumentsException) Argument(com.denizenscript.denizencore.objects.Argument) Scoreboard(org.bukkit.scoreboard.Scoreboard) ScoreboardHelper(com.denizenscript.denizen.utilities.ScoreboardHelper) TagContext(com.denizenscript.denizencore.tags.TagContext) EntityTag(com.denizenscript.denizen.objects.EntityTag) ScriptEntry(com.denizenscript.denizencore.scripts.ScriptEntry) ChatColor(org.bukkit.ChatColor) Debug(com.denizenscript.denizen.utilities.debugging.Debug) AbstractCommand(com.denizenscript.denizencore.scripts.commands.AbstractCommand) ElementTag(com.denizenscript.denizencore.objects.core.ElementTag) CoreUtilities(com.denizenscript.denizencore.utilities.CoreUtilities) Scoreboard(org.bukkit.scoreboard.Scoreboard) Team(org.bukkit.scoreboard.Team) ElementTag(com.denizenscript.denizencore.objects.core.ElementTag) ListTag(com.denizenscript.denizencore.objects.core.ListTag)

Example 17 with Scoreboard

use of org.bukkit.scoreboard.Scoreboard in project Denizen-For-Bukkit by DenizenScript.

the class ServerTagBase method serverTag.

public void serverTag(ReplaceableTagEvent event) {
    if (!event.matches("server", "global") || event.replaced()) {
        return;
    }
    if (event.matches("global")) {
        Deprecations.globalTagName.warn(event.getScriptEntry());
    }
    Attribute attribute = event.getAttributes().fulfill(1);
    if (attribute.startsWith("economy")) {
        if (Depends.economy == null) {
            attribute.echoError("No economy loaded! Have you installed Vault and a compatible economy plugin?");
            return;
        }
        attribute = attribute.fulfill(1);
        // -->
        if (attribute.startsWith("format") && attribute.hasParam()) {
            double amount = attribute.getDoubleParam();
            event.setReplacedObject(new ElementTag(Depends.economy.format(amount)).getObjectAttribute(attribute.fulfill(1)));
            return;
        }
        // -->
        if (attribute.startsWith("currency_name") && attribute.hasParam()) {
            double amount = attribute.getDoubleParam();
            event.setReplacedObject(new ElementTag(amount == 1 ? Depends.economy.currencyNameSingular() : Depends.economy.currencyNamePlural()).getObjectAttribute(attribute.fulfill(1)));
            return;
        }
        // -->
        if (attribute.startsWith("currency_plural")) {
            event.setReplacedObject(new ElementTag(Depends.economy.currencyNamePlural()).getObjectAttribute(attribute.fulfill(1)));
            return;
        }
        // -->
        if (attribute.startsWith("currency_singular")) {
            event.setReplacedObject(new ElementTag(Depends.economy.currencyNameSingular()).getObjectAttribute(attribute.fulfill(1)));
            return;
        }
        return;
    }
    // -->
    if (attribute.startsWith("slot_id") && attribute.hasParam()) {
        int slotId = SlotHelper.nameToIndex(attribute.getParam(), null);
        if (slotId != -1) {
            event.setReplacedObject(new ElementTag(slotId).getObjectAttribute(attribute.fulfill(1)));
        }
        return;
    }
    // -->
    if (attribute.startsWith("parse_bukkit_item") && attribute.hasParam()) {
        YamlConfiguration config = new YamlConfiguration();
        try {
            config.loadFromString(attribute.getParam());
            ItemStack item = config.getItemStack("item");
            if (item != null) {
                event.setReplacedObject(new ItemTag(item).getObjectAttribute(attribute.fulfill(1)));
            }
        } catch (Exception ex) {
            Debug.echoError(ex);
        }
        return;
    }
    // -->
    if (attribute.startsWith("recipe_ids") || attribute.startsWith("list_recipe_ids")) {
        listDeprecateWarn(attribute);
        String type = attribute.hasParam() ? CoreUtilities.toLowerCase(attribute.getParam()) : null;
        ListTag list = new ListTag();
        Iterator<Recipe> recipeIterator = Bukkit.recipeIterator();
        while (recipeIterator.hasNext()) {
            Recipe recipe = recipeIterator.next();
            if (Utilities.isRecipeOfType(recipe, type) && recipe instanceof Keyed) {
                list.add(((Keyed) recipe).getKey().toString());
            }
        }
        event.setReplacedObject(list.getObjectAttribute(attribute.fulfill(1)));
        return;
    }
    // -->
    if (attribute.startsWith("recipe_items") && attribute.hasParam()) {
        NamespacedKey key = Utilities.parseNamespacedKey(attribute.getParam());
        Recipe recipe = NMSHandler.getItemHelper().getRecipeById(key);
        if (recipe == null) {
            return;
        }
        ListTag result = new ListTag();
        Consumer<RecipeChoice> addChoice = (choice) -> {
            if (choice == null) {
                result.addObject(new ItemTag(Material.AIR));
            } else {
                if (choice instanceof RecipeChoice.ExactChoice) {
                    result.addObject(new ItemTag(choice.getItemStack()));
                } else {
                    result.add("material:" + choice.getItemStack().getType().name());
                }
            }
        };
        if (recipe instanceof ShapedRecipe) {
            for (String row : ((ShapedRecipe) recipe).getShape()) {
                for (char column : row.toCharArray()) {
                    addChoice.accept(((ShapedRecipe) recipe).getChoiceMap().get(column));
                }
            }
        } else if (recipe instanceof ShapelessRecipe) {
            for (RecipeChoice choice : ((ShapelessRecipe) recipe).getChoiceList()) {
                addChoice.accept(choice);
            }
        } else if (recipe instanceof CookingRecipe<?>) {
            addChoice.accept(((CookingRecipe) recipe).getInputChoice());
        }
        event.setReplacedObject(result.getObjectAttribute(attribute.fulfill(1)));
        return;
    }
    // -->
    if (attribute.startsWith("recipe_shape") && attribute.hasParam()) {
        NamespacedKey key = Utilities.parseNamespacedKey(attribute.getParam());
        Recipe recipe = NMSHandler.getItemHelper().getRecipeById(key);
        if (!(recipe instanceof ShapedRecipe)) {
            return;
        }
        String[] shape = ((ShapedRecipe) recipe).getShape();
        event.setReplacedObject(new ElementTag(shape[0].length() + "x" + shape.length).getObjectAttribute(attribute.fulfill(1)));
        return;
    }
    // -->
    if (attribute.startsWith("recipe_type") && attribute.hasParam()) {
        NamespacedKey key = Utilities.parseNamespacedKey(attribute.getParam());
        Recipe recipe = NMSHandler.getItemHelper().getRecipeById(key);
        if (recipe == null) {
            return;
        }
        event.setReplacedObject(new ElementTag(Utilities.getRecipeType(recipe)).getObjectAttribute(attribute.fulfill(1)));
        return;
    }
    // -->
    if (attribute.startsWith("recipe_result") && attribute.hasParam()) {
        NamespacedKey key = Utilities.parseNamespacedKey(attribute.getParam());
        Recipe recipe = NMSHandler.getItemHelper().getRecipeById(key);
        if (recipe == null) {
            return;
        }
        event.setReplacedObject(new ItemTag(recipe.getResult()).getObjectAttribute(attribute.fulfill(1)));
        return;
    }
    // -->
    if (attribute.startsWith("scoreboards")) {
        ListTag result = new ListTag();
        for (String board : ScoreboardHelper.scoreboardMap.keySet()) {
            result.addObject(new ElementTag(board));
        }
        event.setReplacedObject(result.getObjectAttribute(attribute.fulfill(1)));
        return;
    }
    if (attribute.startsWith("scoreboard")) {
        Scoreboard board;
        String name = "main";
        if (attribute.hasParam()) {
            name = attribute.getParam();
            board = ScoreboardHelper.getScoreboard(name);
        } else {
            board = ScoreboardHelper.getMain();
        }
        attribute = attribute.fulfill(1);
        // -->
        if (attribute.startsWith("exists")) {
            event.setReplacedObject(new ElementTag(board != null).getObjectAttribute(attribute.fulfill(1)));
            return;
        }
        if (board == null) {
            attribute.echoError("Scoreboard '" + name + "' does not exist.");
            return;
        }
        // -->
        if (attribute.startsWith("objectives")) {
            ListTag list = new ListTag();
            for (Objective objective : board.getObjectives()) {
                list.add(objective.getName());
            }
            event.setReplacedObject((list).getObjectAttribute(attribute.fulfill(1)));
        }
        if (attribute.startsWith("objective") && attribute.hasParam()) {
            Objective objective = board.getObjective(attribute.getParam());
            if (objective == null) {
                attribute.echoError("Scoreboard objective '" + attribute.getParam() + "' does not exist.");
                return;
            }
            attribute = attribute.fulfill(1);
            // -->
            if (attribute.startsWith("criteria")) {
                event.setReplacedObject(new ElementTag(objective.getCriteria()).getObjectAttribute(attribute.fulfill(1)));
            }
            // -->
            if (attribute.startsWith("display_name")) {
                event.setReplacedObject(new ElementTag(objective.getDisplayName()).getObjectAttribute(attribute.fulfill(1)));
            }
            // -->
            if (attribute.startsWith("display_slot")) {
                if (objective.getDisplaySlot() == null) {
                    return;
                }
                event.setReplacedObject(new ElementTag(objective.getDisplaySlot().name()).getObjectAttribute(attribute.fulfill(1)));
            }
        }
        // -->
        if (attribute.startsWith("team_names")) {
            ListTag result = new ListTag();
            for (Team team : board.getTeams()) {
                result.add(team.getName());
            }
            event.setReplacedObject(result.getObjectAttribute(attribute.fulfill(1)));
        }
        if (attribute.startsWith("team") && attribute.hasParam()) {
            Team team = board.getTeam(attribute.getParam());
            if (team == null) {
                attribute.echoError("Scoreboard team '" + attribute.getParam() + "' does not exist.");
                return;
            }
            attribute = attribute.fulfill(1);
            // -->
            if (attribute.startsWith("members")) {
                event.setReplacedObject(new ListTag(team.getEntries()).getObjectAttribute(attribute.fulfill(1)));
            }
            return;
        }
    }
    // -->
    if (attribute.startsWith("object_is_valid")) {
        ObjectTag o = ObjectFetcher.pickObjectFor(attribute.getParam(), new BukkitTagContext(null, null, null, false, null));
        event.setReplacedObject(new ElementTag(!(o == null || o instanceof ElementTag)).getObjectAttribute(attribute.fulfill(1)));
        return;
    }
    // -->
    if (attribute.startsWith("has_whitelist")) {
        event.setReplacedObject(new ElementTag(Bukkit.hasWhitelist()).getObjectAttribute(attribute.fulfill(1)));
        return;
    }
    // -->
    if (attribute.startsWith("whitelisted_players")) {
        ListTag result = new ListTag();
        for (OfflinePlayer player : Bukkit.getWhitelistedPlayers()) {
            result.addObject(new PlayerTag(player));
        }
        event.setReplacedObject(result.getObjectAttribute(attribute.fulfill(1)));
        return;
    }
    // -->
    if (attribute.startsWith("has_flag")) {
        event.setReplacedObject(DenizenCore.serverFlagMap.doHasFlagTag(attribute).getObjectAttribute(attribute.fulfill(1)));
        return;
    }
    // -->
    if (attribute.startsWith("flag_expiration")) {
        TimeTag exp = DenizenCore.serverFlagMap.doFlagExpirationTag(attribute);
        if (exp != null) {
            event.setReplacedObject(exp.getObjectAttribute(attribute.fulfill(1)));
        }
        return;
    }
    // -->
    if (attribute.startsWith("flag")) {
        ObjectTag flag = DenizenCore.serverFlagMap.doFlagTag(attribute);
        if (flag != null) {
            event.setReplacedObject(flag.getObjectAttribute(attribute.fulfill(1)));
        }
        return;
    }
    // -->
    if (attribute.startsWith("list_flags")) {
        event.setReplacedObject(DenizenCore.serverFlagMap.doListFlagsTag(attribute).getObjectAttribute(attribute.fulfill(1)));
        return;
    }
    // -->
    if (attribute.startsWith("flag_map")) {
        event.setReplacedObject(DenizenCore.serverFlagMap.doFlagMapTag(attribute).getObjectAttribute(attribute.fulfill(1)));
        return;
    }
    // -->
    if (attribute.startsWith("gamerules")) {
        ListTag allGameRules = new ListTag();
        for (GameRule rule : GameRule.values()) {
            allGameRules.add(rule.getName());
        }
        event.setReplacedObject(allGameRules.getObjectAttribute(attribute.fulfill(1)));
    }
    // -->
    if ((attribute.startsWith("traits") || attribute.startsWith("list_traits")) && Depends.citizens != null) {
        listDeprecateWarn(attribute);
        ListTag allTraits = new ListTag();
        for (TraitInfo trait : CitizensAPI.getTraitFactory().getRegisteredTraits()) {
            allTraits.add(trait.getTraitName());
        }
        event.setReplacedObject(allTraits.getObjectAttribute(attribute.fulfill(1)));
    }
    // -->
    if (attribute.startsWith("commands") || attribute.startsWith("list_commands")) {
        listDeprecateWarn(attribute);
        CommandScriptHelper.init();
        ListTag list = new ListTag(CommandScriptHelper.knownCommands.keySet());
        event.setReplacedObject(list.getObjectAttribute(attribute.fulfill(1)));
        return;
    }
    // -->
    if (attribute.startsWith("command_plugin")) {
        PluginCommand cmd = Bukkit.getPluginCommand(attribute.getParam());
        if (cmd != null) {
            event.setReplacedObject(new PluginTag(cmd.getPlugin()).getObjectAttribute(attribute.fulfill(1)));
        }
        return;
    }
    // -->
    if (attribute.startsWith("color_names")) {
        ListTag list = new ListTag();
        for (String color : ColorTag.colorsByName.keySet()) {
            list.add(color);
        }
        event.setReplacedObject(list.getObjectAttribute(attribute.fulfill(1)));
        return;
    }
    // -->
    if (attribute.startsWith("art_types")) {
        listDeprecateWarn(attribute);
        ListTag list = new ListTag();
        for (Art art : Art.values()) {
            list.add(art.name());
        }
        event.setReplacedObject(list.getObjectAttribute(attribute.fulfill(1)));
        return;
    }
    // -->
    if (attribute.startsWith("advancement_types") || attribute.startsWith("list_advancements")) {
        if (attribute.matches("list_advancements")) {
            Debug.echoError("list_advancements is deprecated: use advancement_types");
        }
        listDeprecateWarn(attribute);
        ListTag list = new ListTag();
        Bukkit.advancementIterator().forEachRemaining((adv) -> {
            list.add(adv.getKey().toString());
        });
        event.setReplacedObject(list.getObjectAttribute(attribute.fulfill(1)));
        return;
    }
    // -->
    if (attribute.startsWith("nbt_attribute_types") || attribute.startsWith("list_nbt_attribute_types")) {
        listDeprecateWarn(attribute);
        ListTag list = new ListTag();
        for (org.bukkit.attribute.Attribute attribType : org.bukkit.attribute.Attribute.values()) {
            list.add(attribType.name());
        }
        event.setReplacedObject(list.getObjectAttribute(attribute.fulfill(1)));
        return;
    }
    // -->
    if (attribute.startsWith("damage_causes") || attribute.startsWith("list_damage_causes")) {
        listDeprecateWarn(attribute);
        ListTag list = new ListTag();
        for (EntityDamageEvent.DamageCause damageCause : EntityDamageEvent.DamageCause.values()) {
            list.add(damageCause.name());
        }
        event.setReplacedObject(list.getObjectAttribute(attribute.fulfill(1)));
        return;
    }
    // -->
    if (attribute.startsWith("teleport_causes")) {
        ListTag list = new ListTag();
        for (PlayerTeleportEvent.TeleportCause teleportCause : PlayerTeleportEvent.TeleportCause.values()) {
            list.add(teleportCause.name());
        }
        event.setReplacedObject(list.getObjectAttribute(attribute.fulfill(1)));
        return;
    }
    // -->
    if (attribute.startsWith("biome_types") || attribute.startsWith("list_biome_types")) {
        listDeprecateWarn(attribute);
        ListTag allBiomes = new ListTag();
        for (Biome biome : Biome.values()) {
            if (biome != Biome.CUSTOM) {
                allBiomes.addObject(new BiomeTag(biome));
            }
        }
        event.setReplacedObject(allBiomes.getObjectAttribute(attribute.fulfill(1)));
    }
    if (attribute.startsWith("list_biomes")) {
        Deprecations.serverListBiomeNames.warn(attribute.context);
        ListTag allBiomes = new ListTag();
        for (Biome biome : Biome.values()) {
            allBiomes.add(biome.name());
        }
        event.setReplacedObject(allBiomes.getObjectAttribute(attribute.fulfill(1)));
    }
    // -->
    if (attribute.startsWith("enchantments")) {
        ListTag enchants = new ListTag();
        for (Enchantment ench : Enchantment.values()) {
            enchants.addObject(new EnchantmentTag(ench));
        }
        event.setReplacedObject(enchants.getObjectAttribute(attribute.fulfill(1)));
    }
    if (attribute.startsWith("enchantment_types") || attribute.startsWith("list_enchantments")) {
        Deprecations.echantmentTagUpdate.warn(attribute.context);
        if (attribute.matches("list_enchantments")) {
            Debug.echoError("list_enchantments is deprecated: use enchantment_types");
        }
        listDeprecateWarn(attribute);
        ListTag enchants = new ListTag();
        for (Enchantment e : Enchantment.values()) {
            enchants.add(e.getName());
        }
        event.setReplacedObject(enchants.getObjectAttribute(attribute.fulfill(1)));
    }
    if (attribute.startsWith("enchantment_keys") || attribute.startsWith("list_enchantment_keys")) {
        Deprecations.echantmentTagUpdate.warn(attribute.context);
        listDeprecateWarn(attribute);
        ListTag enchants = new ListTag();
        for (Enchantment e : Enchantment.values()) {
            enchants.add(e.getKey().getKey());
        }
        event.setReplacedObject(enchants.getObjectAttribute(attribute.fulfill(1)));
    }
    // -->
    if (attribute.startsWith("entity_types") || attribute.startsWith("list_entity_types")) {
        listDeprecateWarn(attribute);
        ListTag allEnt = new ListTag();
        for (EntityType entity : EntityType.values()) {
            if (entity != EntityType.UNKNOWN) {
                allEnt.add(entity.name());
            }
        }
        event.setReplacedObject(allEnt.getObjectAttribute(attribute.fulfill(1)));
    }
    // -->
    if (attribute.startsWith("material_types") || attribute.startsWith("list_material_types")) {
        listDeprecateWarn(attribute);
        ListTag allMats = new ListTag();
        for (Material mat : Material.values()) {
            allMats.addObject(new MaterialTag(mat));
        }
        event.setReplacedObject(allMats.getObjectAttribute(attribute.fulfill(1)));
    }
    if (attribute.startsWith("list_materials")) {
        Deprecations.serverListMaterialNames.warn(attribute.context);
        ListTag allMats = new ListTag();
        for (Material mat : Material.values()) {
            allMats.add(mat.name());
        }
        event.setReplacedObject(allMats.getObjectAttribute(attribute.fulfill(1)));
    }
    // -->
    if (attribute.startsWith("sound_types") || attribute.startsWith("list_sounds")) {
        if (attribute.matches("list_sounds")) {
            Debug.echoError("list_sounds is deprecated: use sound_types");
        }
        listDeprecateWarn(attribute);
        ListTag sounds = new ListTag();
        for (Sound s : Sound.values()) {
            sounds.add(s.toString());
        }
        event.setReplacedObject(sounds.getObjectAttribute(attribute.fulfill(1)));
    }
    // -->
    if (attribute.startsWith("particle_types") || attribute.startsWith("list_particles")) {
        if (attribute.matches("list_particles")) {
            Debug.echoError("list_particles is deprecated: use particle_types");
        }
        listDeprecateWarn(attribute);
        ListTag particleTypes = new ListTag();
        for (Particle particle : Particle.values()) {
            particleTypes.add(particle.toString());
        }
        event.setReplacedObject(particleTypes.getObjectAttribute(attribute.fulfill(1)));
    }
    // -->
    if (attribute.startsWith("effect_types") || attribute.startsWith("list_effects")) {
        if (attribute.matches("list_effects")) {
            Debug.echoError("list_effects is deprecated: use effect_types");
        }
        listDeprecateWarn(attribute);
        ListTag effectTypes = new ListTag();
        for (Effect effect : Effect.values()) {
            effectTypes.add(effect.toString());
        }
        event.setReplacedObject(effectTypes.getObjectAttribute(attribute.fulfill(1)));
    }
    // -->
    if (attribute.startsWith("pattern_types") || attribute.startsWith("list_patterns")) {
        if (attribute.matches("list_patterns")) {
            Debug.echoError("list_patterns is deprecated: use pattern_types");
        }
        listDeprecateWarn(attribute);
        ListTag allPatterns = new ListTag();
        for (PatternType pat : PatternType.values()) {
            allPatterns.add(pat.toString());
        }
        event.setReplacedObject(allPatterns.getObjectAttribute(attribute.fulfill(1)));
    }
    // -->
    if (attribute.startsWith("potion_effect_types") || attribute.startsWith("list_potion_effects")) {
        if (attribute.matches("list_potion_effects")) {
            Debug.echoError("list_potion_effects is deprecated: use potion_effect_types");
        }
        listDeprecateWarn(attribute);
        ListTag statuses = new ListTag();
        for (PotionEffectType effect : PotionEffectType.values()) {
            if (effect != null) {
                statuses.add(effect.getName());
            }
        }
        event.setReplacedObject(statuses.getObjectAttribute(attribute.fulfill(1)));
    }
    // -->
    if (attribute.startsWith("potion_types") || attribute.startsWith("list_potion_types")) {
        listDeprecateWarn(attribute);
        ListTag potionTypes = new ListTag();
        for (PotionType type : PotionType.values()) {
            potionTypes.add(type.toString());
        }
        event.setReplacedObject(potionTypes.getObjectAttribute(attribute.fulfill(1)));
    }
    // -->
    if (attribute.startsWith("tree_types") || attribute.startsWith("list_tree_types")) {
        listDeprecateWarn(attribute);
        ListTag allTrees = new ListTag();
        for (TreeType tree : TreeType.values()) {
            allTrees.add(tree.name());
        }
        event.setReplacedObject(allTrees.getObjectAttribute(attribute.fulfill(1)));
    }
    // -->
    if (attribute.startsWith("map_cursor_types") || attribute.startsWith("list_map_cursor_types")) {
        listDeprecateWarn(attribute);
        ListTag mapCursors = new ListTag();
        for (MapCursor.Type cursor : MapCursor.Type.values()) {
            mapCursors.add(cursor.toString());
        }
        event.setReplacedObject(mapCursors.getObjectAttribute(attribute.fulfill(1)));
    }
    // -->
    if (attribute.startsWith("world_types") || attribute.startsWith("list_world_types")) {
        listDeprecateWarn(attribute);
        ListTag worldTypes = new ListTag();
        for (WorldType world : WorldType.values()) {
            worldTypes.add(world.toString());
        }
        event.setReplacedObject(worldTypes.getObjectAttribute(attribute.fulfill(1)));
    }
    // -->
    if (attribute.startsWith("statistic_types") || attribute.startsWith("list_statistics")) {
        listDeprecateWarn(attribute);
        if (attribute.matches("list_statistics")) {
            Debug.echoError("list_statistics is deprecated: use statistic_types");
        }
        Statistic.Type type = null;
        if (attribute.hasParam()) {
            type = Statistic.Type.valueOf(attribute.getParam().toUpperCase());
        }
        ListTag statisticTypes = new ListTag();
        for (Statistic stat : Statistic.values()) {
            if (type == null || type == stat.getType()) {
                statisticTypes.add(stat.toString());
            }
        }
        event.setReplacedObject(statisticTypes.getObjectAttribute(attribute.fulfill(1)));
    }
    // -->
    if (attribute.startsWith("structure_types") || attribute.startsWith("list_structure_types")) {
        listDeprecateWarn(attribute);
        event.setReplacedObject(new ListTag(StructureType.getStructureTypes().keySet()).getObjectAttribute(attribute.fulfill(1)));
    }
    // -->
    if (attribute.startsWith("notes") || attribute.startsWith("list_notables") || attribute.startsWith("notables")) {
        listDeprecateWarn(attribute);
        ListTag allNotables = new ListTag();
        if (attribute.hasParam()) {
            String type = CoreUtilities.toLowerCase(attribute.getParam());
            for (Map.Entry<String, Class> typeClass : NoteManager.namesToTypes.entrySet()) {
                if (type.equals(CoreUtilities.toLowerCase(typeClass.getKey()))) {
                    for (Object notable : NoteManager.getAllType(typeClass.getValue())) {
                        allNotables.addObject((ObjectTag) notable);
                    }
                    break;
                }
            }
        } else {
            for (Notable notable : NoteManager.nameToObject.values()) {
                allNotables.addObject((ObjectTag) notable);
            }
        }
        event.setReplacedObject(allNotables.getObjectAttribute(attribute.fulfill(1)));
    }
    // -->
    if (attribute.startsWith("statistic_type") && attribute.hasParam()) {
        Statistic statistic;
        try {
            statistic = Statistic.valueOf(attribute.getParam().toUpperCase());
        } catch (IllegalArgumentException ex) {
            attribute.echoError("Statistic '" + attribute.getParam() + "' does not exist: " + ex.getMessage());
            return;
        }
        event.setReplacedObject(new ElementTag(statistic.getType().name()).getObjectAttribute(attribute.fulfill(1)));
    }
    if (attribute.startsWith("enchantment_max_level") && attribute.hasParam()) {
        Deprecations.echantmentTagUpdate.warn(attribute.context);
        EnchantmentTag ench = EnchantmentTag.valueOf(attribute.getParam(), attribute.context);
        if (ench == null) {
            attribute.echoError("Enchantment '" + attribute.getParam() + "' does not exist.");
            return;
        }
        event.setReplacedObject(new ElementTag(ench.enchantment.getMaxLevel()).getObjectAttribute(attribute.fulfill(1)));
    }
    if (attribute.startsWith("enchantment_start_level") && attribute.hasParam()) {
        Deprecations.echantmentTagUpdate.warn(attribute.context);
        EnchantmentTag ench = EnchantmentTag.valueOf(attribute.getParam(), attribute.context);
        if (ench == null) {
            attribute.echoError("Enchantment '" + attribute.getParam() + "' does not exist.");
            return;
        }
        event.setReplacedObject(new ElementTag(ench.enchantment.getStartLevel()).getObjectAttribute(attribute.fulfill(1)));
    }
    // -->
    if (attribute.startsWith("started_time")) {
        event.setReplacedObject(new TimeTag(DenizenCore.startTime).getObjectAttribute(attribute.fulfill(1)));
    }
    if (attribute.startsWith("start_time")) {
        Deprecations.timeTagRewrite.warn(attribute.context);
        event.setReplacedObject(new DurationTag(DenizenCore.startTime / 50).getObjectAttribute(attribute.fulfill(1)));
    }
    // -->
    if (attribute.startsWith("disk_free")) {
        File folder = Denizen.getInstance().getDataFolder();
        event.setReplacedObject(new ElementTag(folder.getUsableSpace()).getObjectAttribute(attribute.fulfill(1)));
    }
    // -->
    if (attribute.startsWith("disk_total")) {
        File folder = Denizen.getInstance().getDataFolder();
        event.setReplacedObject(new ElementTag(folder.getTotalSpace()).getObjectAttribute(attribute.fulfill(1)));
    }
    // -->
    if (attribute.startsWith("disk_usage")) {
        File folder = Denizen.getInstance().getDataFolder();
        event.setReplacedObject(new ElementTag(folder.getTotalSpace() - folder.getFreeSpace()).getObjectAttribute(attribute.fulfill(1)));
    }
    // -->
    if (attribute.startsWith("ram_allocated")) {
        event.setReplacedObject(new ElementTag(Runtime.getRuntime().totalMemory()).getObjectAttribute(attribute.fulfill(1)));
    }
    // -->
    if (attribute.startsWith("ram_max")) {
        event.setReplacedObject(new ElementTag(Runtime.getRuntime().maxMemory()).getObjectAttribute(attribute.fulfill(1)));
    }
    // -->
    if (attribute.startsWith("ram_free")) {
        event.setReplacedObject(new ElementTag(Runtime.getRuntime().freeMemory()).getObjectAttribute(attribute.fulfill(1)));
    }
    // -->
    if (attribute.startsWith("ram_usage")) {
        event.setReplacedObject(new ElementTag(Runtime.getRuntime().maxMemory() - Runtime.getRuntime().freeMemory()).getObjectAttribute(attribute.fulfill(1)));
    }
    // -->
    if (attribute.startsWith("available_processors")) {
        event.setReplacedObject(new ElementTag(Runtime.getRuntime().availableProcessors()).getObjectAttribute(attribute.fulfill(1)));
    }
    // -->
    if (attribute.startsWith("current_tick")) {
        event.setReplacedObject(new ElementTag(TickScriptEvent.instance.ticks).getObjectAttribute(attribute.fulfill(1)));
    }
    // -->
    if (attribute.startsWith("delta_time_since_start")) {
        event.setReplacedObject(new DurationTag(TickScriptEvent.instance.ticks).getObjectAttribute(attribute.fulfill(1)));
    }
    // -->
    if (attribute.startsWith("real_time_since_start")) {
        event.setReplacedObject(new DurationTag((System.currentTimeMillis() - serverStartTimeMillis) / 1000.0).getObjectAttribute(attribute.fulfill(1)));
    }
    // -->
    if (attribute.startsWith("current_time_millis")) {
        event.setReplacedObject(new ElementTag(System.currentTimeMillis()).getObjectAttribute(attribute.fulfill(1)));
    }
    // -->
    if (attribute.startsWith("selected_npc")) {
        NPC npc = ((Citizens) Bukkit.getPluginManager().getPlugin("Citizens")).getNPCSelector().getSelected(Bukkit.getConsoleSender());
        if (npc == null) {
            return;
        } else {
            event.setReplacedObject(new NPCTag(npc).getObjectAttribute(attribute.fulfill(1)));
        }
        return;
    }
    // -->
    if ((attribute.startsWith("npcs_named") || attribute.startsWith("list_npcs_named")) && Depends.citizens != null && attribute.hasParam()) {
        listDeprecateWarn(attribute);
        ListTag npcs = new ListTag();
        String name = attribute.getParam();
        for (NPC npc : CitizensAPI.getNPCRegistry()) {
            if (CoreUtilities.equalsIgnoreCase(npc.getName(), name)) {
                npcs.addObject(new NPCTag(npc));
            }
        }
        event.setReplacedObject(npcs.getObjectAttribute(attribute.fulfill(1)));
        return;
    }
    // -->
    if (attribute.startsWith("has_file") && attribute.hasParam()) {
        File f = new File(Denizen.getInstance().getDataFolder(), attribute.getParam());
        try {
            if (!Utilities.canReadFile(f)) {
                Debug.echoError("Cannot read from that file path due to security settings in Denizen/config.yml.");
                return;
            }
        } catch (Exception e) {
            Debug.echoError(e);
            return;
        }
        event.setReplacedObject(new ElementTag(f.exists()).getObjectAttribute(attribute.fulfill(1)));
        return;
    }
    // -->
    if (attribute.startsWith("list_files") && attribute.hasParam()) {
        File folder = new File(Denizen.getInstance().getDataFolder(), attribute.getParam());
        try {
            if (!Utilities.canReadFile(folder)) {
                Debug.echoError("Cannot read from that file path due to security settings in Denizen/config.yml.");
                return;
            }
            if (!folder.exists() || !folder.isDirectory()) {
                attribute.echoError("Invalid path specified. No directory exists at that path.");
                return;
            }
        } catch (Exception e) {
            Debug.echoError(e);
            return;
        }
        File[] files = folder.listFiles();
        if (files == null) {
            return;
        }
        ListTag list = new ListTag();
        for (File file : files) {
            list.add(file.getName());
        }
        event.setReplacedObject(list.getObjectAttribute(attribute.fulfill(1)));
        return;
    }
    // -->
    if (attribute.startsWith("has_permissions")) {
        event.setReplacedObject(new ElementTag(Depends.permissions != null && Depends.permissions.isEnabled()).getObjectAttribute(attribute.fulfill(1)));
        return;
    }
    // -->
    if (attribute.startsWith("has_economy")) {
        event.setReplacedObject(new ElementTag(Depends.economy != null && Depends.economy.isEnabled()).getObjectAttribute(attribute.fulfill(1)));
        return;
    }
    // -->
    if (attribute.startsWith("denizen_version")) {
        event.setReplacedObject(new ElementTag(Denizen.getInstance().getDescription().getVersion()).getObjectAttribute(attribute.fulfill(1)));
        return;
    }
    // -->
    if (attribute.startsWith("bukkit_version")) {
        event.setReplacedObject(new ElementTag(Bukkit.getBukkitVersion()).getObjectAttribute(attribute.fulfill(1)));
        return;
    }
    // -->
    if (attribute.startsWith("version")) {
        event.setReplacedObject(new ElementTag(Bukkit.getServer().getVersion()).getObjectAttribute(attribute.fulfill(1)));
        return;
    }
    // -->
    if (attribute.startsWith("java_version")) {
        event.setReplacedObject(new ElementTag(System.getProperty("java.version")).getObjectAttribute(attribute.fulfill(1)));
        return;
    }
    // -->
    if (attribute.startsWith("max_players")) {
        event.setReplacedObject(new ElementTag(Bukkit.getServer().getMaxPlayers()).getObjectAttribute(attribute.fulfill(1)));
        return;
    }
    // -->
    if (attribute.startsWith("sql_connections") || attribute.startsWith("list_sql_connections")) {
        listDeprecateWarn(attribute);
        ListTag list = new ListTag();
        for (Map.Entry<String, Connection> entry : SQLCommand.connections.entrySet()) {
            try {
                if (!entry.getValue().isClosed()) {
                    list.add(entry.getKey());
                } else {
                    SQLCommand.connections.remove(entry.getKey());
                }
            } catch (SQLException e) {
                Debug.echoError(attribute.getScriptEntry(), e);
            }
        }
        event.setReplacedObject(list.getObjectAttribute(attribute.fulfill(1)));
        return;
    }
    // -->
    if (attribute.startsWith("group_prefix")) {
        if (Depends.permissions == null) {
            attribute.echoError("No permission system loaded! Have you installed Vault and a compatible permissions plugin?");
            return;
        }
        String group = attribute.getParam();
        if (!Arrays.asList(Depends.permissions.getGroups()).contains(group)) {
            attribute.echoError("Invalid group! '" + (group != null ? group : "") + "' could not be found.");
            return;
        }
        // -->
        if (attribute.startsWith("world", 2)) {
            WorldTag world = attribute.contextAsType(2, WorldTag.class);
            if (world != null) {
                event.setReplacedObject(new ElementTag(Depends.chat.getGroupPrefix(world.getWorld(), group)).getObjectAttribute(attribute.fulfill(2)));
            }
            return;
        }
        // Prefix in default world
        event.setReplacedObject(new ElementTag(Depends.chat.getGroupPrefix(Bukkit.getWorlds().get(0), group)).getObjectAttribute(attribute.fulfill(1)));
        return;
    }
    // -->
    if (attribute.startsWith("group_suffix")) {
        if (Depends.permissions == null) {
            attribute.echoError("No permission system loaded! Have you installed Vault and a compatible permissions plugin?");
            return;
        }
        String group = attribute.getParam();
        if (!Arrays.asList(Depends.permissions.getGroups()).contains(group)) {
            attribute.echoError("Invalid group! '" + (group != null ? group : "") + "' could not be found.");
            return;
        }
        // -->
        if (attribute.startsWith("world", 2)) {
            WorldTag world = attribute.contextAsType(2, WorldTag.class);
            if (world != null) {
                event.setReplacedObject(new ElementTag(Depends.chat.getGroupSuffix(world.getWorld(), group)).getObjectAttribute(attribute.fulfill(2)));
            }
            return;
        }
        // Suffix in default world
        event.setReplacedObject(new ElementTag(Depends.chat.getGroupSuffix(Bukkit.getWorlds().get(0), group)).getObjectAttribute(attribute.fulfill(1)));
        return;
    }
    // -->
    if (attribute.startsWith("permission_groups") || attribute.startsWith("list_permission_groups")) {
        if (Depends.permissions == null) {
            attribute.echoError("No permission system loaded! Have you installed Vault and a compatible permissions plugin?");
            return;
        }
        listDeprecateWarn(attribute);
        event.setReplacedObject(new ListTag(Arrays.asList(Depends.permissions.getGroups())).getObjectAttribute(attribute.fulfill(1)));
        return;
    }
    if (attribute.startsWith("list_plugin_names")) {
        Deprecations.serverPluginNamesTag.warn(attribute.context);
        ListTag plugins = new ListTag();
        for (Plugin plugin : Bukkit.getServer().getPluginManager().getPlugins()) {
            plugins.add(plugin.getName());
        }
        event.setReplacedObject(plugins.getObjectAttribute(attribute.fulfill(1)));
        return;
    }
    // -->
    if (attribute.startsWith("scripts") || attribute.startsWith("list_scripts")) {
        listDeprecateWarn(attribute);
        ListTag scripts = new ListTag();
        for (ScriptContainer script : ScriptRegistry.scriptContainers.values()) {
            scripts.addObject(new ScriptTag(script));
        }
        event.setReplacedObject(scripts.getObjectAttribute(attribute.fulfill(1)));
        return;
    }
    // -->
    if (attribute.startsWith("match_player") && attribute.hasParam()) {
        Player matchPlayer = null;
        String matchInput = CoreUtilities.toLowerCase(attribute.getParam());
        if (matchInput.isEmpty()) {
            return;
        }
        for (Player player : Bukkit.getOnlinePlayers()) {
            String nameLow = CoreUtilities.toLowerCase(player.getName());
            if (nameLow.equals(matchInput)) {
                matchPlayer = player;
                break;
            } else if (nameLow.contains(matchInput)) {
                if (matchPlayer == null || nameLow.startsWith(matchInput)) {
                    matchPlayer = player;
                }
            }
        }
        if (matchPlayer != null) {
            event.setReplacedObject(new PlayerTag(matchPlayer).getObjectAttribute(attribute.fulfill(1)));
        }
        return;
    }
    // -->
    if (attribute.startsWith("match_offline_player") && attribute.hasParam()) {
        PlayerTag matchPlayer = null;
        String matchInput = CoreUtilities.toLowerCase(attribute.getParam());
        if (matchInput.isEmpty()) {
            return;
        }
        for (Map.Entry<String, UUID> entry : PlayerTag.getAllPlayers().entrySet()) {
            String nameLow = CoreUtilities.toLowerCase(entry.getKey());
            if (nameLow.equals(matchInput)) {
                matchPlayer = new PlayerTag(entry.getValue());
                break;
            } else if (nameLow.contains(matchInput)) {
                PlayerTag newMatch = new PlayerTag(entry.getValue());
                if (matchPlayer == null) {
                    matchPlayer = newMatch;
                } else if (newMatch.isOnline() && !matchPlayer.isOnline()) {
                    matchPlayer = newMatch;
                } else if (nameLow.startsWith(matchInput) && (newMatch.isOnline() == matchPlayer.isOnline())) {
                    matchPlayer = newMatch;
                }
            }
        }
        if (matchPlayer != null) {
            event.setReplacedObject(matchPlayer.getObjectAttribute(attribute.fulfill(1)));
        }
        return;
    }
    // -->
    if ((attribute.startsWith("npcs_assigned") || attribute.startsWith("list_npcs_assigned")) && Depends.citizens != null && attribute.hasParam()) {
        listDeprecateWarn(attribute);
        ScriptTag script = attribute.paramAsType(ScriptTag.class);
        if (script == null || !(script.getContainer() instanceof AssignmentScriptContainer)) {
            attribute.echoError("Invalid script specified.");
        } else {
            AssignmentScriptContainer container = (AssignmentScriptContainer) script.getContainer();
            ListTag npcs = new ListTag();
            for (NPC npc : CitizensAPI.getNPCRegistry()) {
                if (npc.hasTrait(AssignmentTrait.class) && npc.getOrAddTrait(AssignmentTrait.class).isAssigned(container)) {
                    npcs.addObject(new NPCTag(npc));
                }
            }
            event.setReplacedObject(npcs.getObjectAttribute(attribute.fulfill(1)));
            return;
        }
    }
    // -->
    if ((attribute.startsWith("online_players_flagged") || attribute.startsWith("list_online_players_flagged")) && attribute.hasParam()) {
        listDeprecateWarn(attribute);
        String flag = attribute.getParam();
        ListTag players = new ListTag();
        for (Player player : Bukkit.getOnlinePlayers()) {
            PlayerTag plTag = new PlayerTag(player);
            if (plTag.getFlagTracker().hasFlag(flag)) {
                players.addObject(plTag);
            }
        }
        event.setReplacedObject(players.getObjectAttribute(attribute.fulfill(1)));
        return;
    }
    // -->
    if ((attribute.startsWith("players_flagged") || attribute.startsWith("list_players_flagged")) && attribute.hasParam()) {
        listDeprecateWarn(attribute);
        String flag = attribute.getParam();
        ListTag players = new ListTag();
        for (Map.Entry<String, UUID> entry : PlayerTag.getAllPlayers().entrySet()) {
            PlayerTag plTag = new PlayerTag(entry.getValue());
            if (plTag.getFlagTracker().hasFlag(flag)) {
                players.addObject(plTag);
            }
        }
        event.setReplacedObject(players.getObjectAttribute(attribute.fulfill(1)));
        return;
    }
    // -->
    if ((attribute.startsWith("spawned_npcs_flagged") || attribute.startsWith("list_spawned_npcs_flagged")) && Depends.citizens != null && attribute.hasParam()) {
        listDeprecateWarn(attribute);
        String flag = attribute.getParam();
        ListTag npcs = new ListTag();
        for (NPC npc : CitizensAPI.getNPCRegistry()) {
            NPCTag dNpc = new NPCTag(npc);
            if (dNpc.isSpawned() && dNpc.hasFlag(flag)) {
                npcs.addObject(dNpc);
            }
        }
        event.setReplacedObject(npcs.getObjectAttribute(attribute.fulfill(1)));
        return;
    }
    // -->
    if ((attribute.startsWith("npcs_flagged") || attribute.startsWith("list_npcs_flagged")) && Depends.citizens != null && attribute.hasParam()) {
        listDeprecateWarn(attribute);
        String flag = attribute.getParam();
        ListTag npcs = new ListTag();
        for (NPC npc : CitizensAPI.getNPCRegistry()) {
            NPCTag dNpc = new NPCTag(npc);
            if (dNpc.hasFlag(flag)) {
                npcs.addObject(dNpc);
            }
        }
        event.setReplacedObject(npcs.getObjectAttribute(attribute.fulfill(1)));
        return;
    }
    // -->
    if (attribute.startsWith("npc_registries") && Depends.citizens != null) {
        ListTag result = new ListTag();
        for (NPCRegistry registry : CitizensAPI.getNPCRegistries()) {
            result.add(registry.getName());
        }
        event.setReplacedObject(result.getObjectAttribute(attribute.fulfill(1)));
        return;
    }
    // -->
    if ((attribute.startsWith("npcs") || attribute.startsWith("list_npcs")) && Depends.citizens != null) {
        listDeprecateWarn(attribute);
        ListTag npcs = new ListTag();
        NPCRegistry registry = CitizensAPI.getNPCRegistry();
        if (attribute.hasParam()) {
            registry = NPCTag.getRegistryByName(attribute.getParam());
            if (registry == null) {
                attribute.echoError("NPC Registry '" + attribute.getParam() + "' does not exist.");
                return;
            }
        }
        for (NPC npc : registry) {
            npcs.addObject(new NPCTag(npc));
        }
        event.setReplacedObject(npcs.getObjectAttribute(attribute.fulfill(1)));
        return;
    }
    // -->
    if (attribute.startsWith("worlds") || attribute.startsWith("list_worlds")) {
        listDeprecateWarn(attribute);
        ListTag worlds = new ListTag();
        for (World world : Bukkit.getWorlds()) {
            worlds.addObject(WorldTag.mirrorBukkitWorld(world));
        }
        event.setReplacedObject(worlds.getObjectAttribute(attribute.fulfill(1)));
        return;
    }
    // -->
    if (attribute.startsWith("plugins") || attribute.startsWith("list_plugins")) {
        listDeprecateWarn(attribute);
        ListTag plugins = new ListTag();
        for (Plugin plugin : Bukkit.getServer().getPluginManager().getPlugins()) {
            plugins.addObject(new PluginTag(plugin));
        }
        event.setReplacedObject(plugins.getObjectAttribute(attribute.fulfill(1)));
        return;
    }
    // -->
    if (attribute.startsWith("players") || attribute.startsWith("list_players")) {
        listDeprecateWarn(attribute);
        ListTag players = new ListTag();
        for (OfflinePlayer player : Bukkit.getOfflinePlayers()) {
            players.addObject(PlayerTag.mirrorBukkitPlayer(player));
        }
        event.setReplacedObject(players.getObjectAttribute(attribute.fulfill(1)));
        return;
    }
    // -->
    if (attribute.startsWith("online_players") || attribute.startsWith("list_online_players")) {
        listDeprecateWarn(attribute);
        ListTag players = new ListTag();
        for (Player player : Bukkit.getOnlinePlayers()) {
            players.addObject(PlayerTag.mirrorBukkitPlayer(player));
        }
        event.setReplacedObject(players.getObjectAttribute(attribute.fulfill(1)));
        return;
    }
    // -->
    if (attribute.startsWith("offline_players") || attribute.startsWith("list_offline_players")) {
        listDeprecateWarn(attribute);
        ListTag players = new ListTag();
        for (OfflinePlayer player : Bukkit.getOfflinePlayers()) {
            if (!player.isOnline()) {
                players.addObject(PlayerTag.mirrorBukkitPlayer(player));
            }
        }
        event.setReplacedObject(players.getObjectAttribute(attribute.fulfill(1)));
        return;
    }
    // -->
    if (attribute.startsWith("banned_players") || attribute.startsWith("list_banned_players")) {
        listDeprecateWarn(attribute);
        ListTag banned = new ListTag();
        for (OfflinePlayer player : Bukkit.getBannedPlayers()) {
            banned.addObject(PlayerTag.mirrorBukkitPlayer(player));
        }
        event.setReplacedObject(banned.getObjectAttribute(attribute.fulfill(1)));
        return;
    }
    // -->
    if (attribute.startsWith("banned_addresses") || attribute.startsWith("list_banned_addresses")) {
        listDeprecateWarn(attribute);
        ListTag list = new ListTag();
        list.addAll(Bukkit.getIPBans());
        event.setReplacedObject(list.getObjectAttribute(attribute.fulfill(1)));
        return;
    }
    // -->
    if (attribute.startsWith("is_banned") && attribute.hasParam()) {
        // BanList contains an isBanned method that doesn't check expiration time
        BanEntry ban = Bukkit.getBanList(BanList.Type.IP).getBanEntry(attribute.getParam());
        if (ban == null) {
            event.setReplacedObject(new ElementTag(false).getObjectAttribute(attribute.fulfill(1)));
        } else if (ban.getExpiration() == null) {
            event.setReplacedObject(new ElementTag(true).getObjectAttribute(attribute.fulfill(1)));
        } else {
            event.setReplacedObject(new ElementTag(ban.getExpiration().after(new Date())).getObjectAttribute(attribute.fulfill(1)));
        }
        return;
    }
    if (attribute.startsWith("ban_info") && attribute.hasParam()) {
        BanEntry ban = Bukkit.getBanList(BanList.Type.IP).getBanEntry(attribute.getParam());
        attribute.fulfill(1);
        if (ban == null || (ban.getExpiration() != null && ban.getExpiration().before(new Date()))) {
            return;
        }
        // -->
        if (attribute.startsWith("expiration_time") && ban.getExpiration() != null) {
            event.setReplacedObject(new TimeTag(ban.getExpiration().getTime()).getObjectAttribute(attribute.fulfill(1)));
        } else if (attribute.startsWith("expiration") && ban.getExpiration() != null) {
            Deprecations.timeTagRewrite.warn(attribute.context);
            event.setReplacedObject(new DurationTag(ban.getExpiration().getTime() / 50).getObjectAttribute(attribute.fulfill(1)));
        } else // -->
        if (attribute.startsWith("reason")) {
            event.setReplacedObject(new ElementTag(ban.getReason()).getObjectAttribute(attribute.fulfill(1)));
        } else // -->
        if (attribute.startsWith("created_time")) {
            event.setReplacedObject(new TimeTag(ban.getCreated().getTime()).getObjectAttribute(attribute.fulfill(1)));
        } else if (attribute.startsWith("created")) {
            Deprecations.timeTagRewrite.warn(attribute.context);
            event.setReplacedObject(new DurationTag(ban.getCreated().getTime() / 50).getObjectAttribute(attribute.fulfill(1)));
        } else // -->
        if (attribute.startsWith("source")) {
            event.setReplacedObject(new ElementTag(ban.getSource()).getObjectAttribute(attribute.fulfill(1)));
        }
        return;
    }
    // -->
    if (attribute.startsWith("ops") || attribute.startsWith("list_ops")) {
        listDeprecateWarn(attribute);
        ListTag players = new ListTag();
        for (OfflinePlayer player : Bukkit.getOperators()) {
            players.addObject(PlayerTag.mirrorBukkitPlayer(player));
        }
        event.setReplacedObject(players.getObjectAttribute(attribute.fulfill(1)));
        return;
    }
    // -->
    if (attribute.startsWith("online_ops") || attribute.startsWith("list_online_ops")) {
        listDeprecateWarn(attribute);
        ListTag players = new ListTag();
        for (OfflinePlayer player : Bukkit.getOperators()) {
            if (player.isOnline()) {
                players.addObject(PlayerTag.mirrorBukkitPlayer(player));
            }
        }
        event.setReplacedObject(players.getObjectAttribute(attribute.fulfill(1)));
        return;
    }
    // -->
    if (attribute.startsWith("offline_ops") || attribute.startsWith("list_offline_ops")) {
        listDeprecateWarn(attribute);
        ListTag players = new ListTag();
        for (OfflinePlayer player : Bukkit.getOfflinePlayers()) {
            if (player.isOp() && !player.isOnline()) {
                players.addObject(PlayerTag.mirrorBukkitPlayer(player));
            }
        }
        event.setReplacedObject(players.getObjectAttribute(attribute.fulfill(1)));
        return;
    }
    // -->
    if (attribute.startsWith("motd")) {
        event.setReplacedObject(new ElementTag(Bukkit.getServer().getMotd()).getObjectAttribute(attribute.fulfill(1)));
        return;
    }
    // -->
    if (attribute.startsWith("view_distance")) {
        event.setReplacedObject(new ElementTag(Bukkit.getServer().getViewDistance()).getObjectAttribute(attribute.fulfill(1)));
        return;
    } else if (attribute.startsWith("entity_is_spawned") && attribute.hasParam()) {
        Deprecations.isValidTag.warn(attribute.context);
        EntityTag ent = EntityTag.valueOf(attribute.getParam(), new BukkitTagContext(null, null, null, false, null));
        event.setReplacedObject(new ElementTag((ent != null && ent.isUnique() && ent.isSpawnedOrValidForTag()) ? "true" : "false").getObjectAttribute(attribute.fulfill(1)));
    } else if (attribute.startsWith("player_is_valid") && attribute.hasParam()) {
        Deprecations.isValidTag.warn(attribute.context);
        event.setReplacedObject(new ElementTag(PlayerTag.playerNameIsValid(attribute.getParam())).getObjectAttribute(attribute.fulfill(1)));
    } else if (attribute.startsWith("npc_is_valid") && attribute.hasParam()) {
        Deprecations.isValidTag.warn(attribute.context);
        NPCTag npc = NPCTag.valueOf(attribute.getParam(), new BukkitTagContext(null, null, null, false, null));
        event.setReplacedObject(new ElementTag((npc != null && npc.isValid())).getObjectAttribute(attribute.fulfill(1)));
    } else // -->
    if (attribute.startsWith("current_bossbars")) {
        ListTag dl = new ListTag(BossBarCommand.bossBarMap.keySet());
        event.setReplacedObject(dl.getObjectAttribute(attribute.fulfill(1)));
    } else // -->
    if (attribute.startsWith("bossbar_viewers") && attribute.hasParam()) {
        BossBar bar = BossBarCommand.bossBarMap.get(CoreUtilities.toLowerCase(attribute.getParam()));
        if (bar != null) {
            ListTag list = new ListTag();
            for (Player player : bar.getPlayers()) {
                list.addObject(new PlayerTag(player));
            }
            event.setReplacedObject(list.getObjectAttribute(attribute.fulfill(1)));
        }
    } else // -->
    if (attribute.startsWith("recent_tps")) {
        ListTag list = new ListTag();
        for (double tps : NMSHandler.getInstance().getRecentTps()) {
            list.addObject(new ElementTag(tps));
        }
        event.setReplacedObject(list.getObjectAttribute(attribute.fulfill(1)));
    } else // -->
    if (attribute.startsWith("port")) {
        event.setReplacedObject(new ElementTag(NMSHandler.getInstance().getPort()).getObjectAttribute(attribute.fulfill(1)));
    } else // -->
    if (attribute.startsWith("debug_enabled")) {
        event.setReplacedObject(new ElementTag(com.denizenscript.denizen.utilities.debugging.Debug.showDebug).getObjectAttribute(attribute.fulfill(1)));
    } else // -->
    if (attribute.startsWith("last_reload")) {
        event.setReplacedObject(new TimeTag(DenizenCore.lastReloadTime).getObjectAttribute(attribute.fulfill(1)));
    } else // -->
    if (attribute.startsWith("idle_timeout")) {
        event.setReplacedObject(new DurationTag(Bukkit.getIdleTimeout() * 60).getObjectAttribute(attribute.fulfill(1)));
    } else // -->
    if (attribute.startsWith("vanilla_tags")) {
        event.setReplacedObject(new ListTag(VanillaTagHelper.tagsByKey.keySet()).getObjectAttribute(attribute.fulfill(1)));
    } else // -->
    if (attribute.startsWith("vanilla_tagged_materials")) {
        if (!attribute.hasParam()) {
            return;
        }
        HashSet<Material> materials = VanillaTagHelper.tagsByKey.get(CoreUtilities.toLowerCase(attribute.getParam()));
        if (materials == null) {
            return;
        }
        ListTag list = new ListTag();
        for (Material material : materials) {
            list.addObject(new MaterialTag(material));
        }
        event.setReplacedObject(list.getObjectAttribute(attribute.fulfill(1)));
    } else // -->
    if ((attribute.matches("plugins_handling_event") || attribute.matches("list_plugins_handling_event")) && attribute.hasParam()) {
        listDeprecateWarn(attribute);
        String eventName = attribute.getParam();
        if (CoreUtilities.contains(eventName, '.')) {
            try {
                Class clazz = Class.forName(eventName, false, ServerTagBase.class.getClassLoader());
                ListTag result = getHandlerPluginList(clazz);
                if (result != null) {
                    event.setReplacedObject(result.getObjectAttribute(attribute.fulfill(1)));
                }
            } catch (ClassNotFoundException ex) {
                if (!attribute.hasAlternative()) {
                    Debug.echoError(ex);
                }
            }
        } else {
            ScriptEvent scriptEvent = ScriptEvent.eventLookup.get(CoreUtilities.toLowerCase(eventName));
            if (scriptEvent instanceof Listener) {
                Plugin plugin = Denizen.getInstance();
                for (Class eventClass : plugin.getPluginLoader().createRegisteredListeners((Listener) scriptEvent, plugin).keySet()) {
                    ListTag result = getHandlerPluginList(eventClass);
                    // Return results for the first valid match.
                    if (result != null && result.size() > 0) {
                        event.setReplacedObject(result.getObjectAttribute(attribute.fulfill(1)));
                        return;
                    }
                }
                event.setReplacedObject(new ListTag().getObjectAttribute(attribute.fulfill(1)));
            }
        }
    } else // -->
    if (attribute.startsWith("generate_loot_table") && attribute.hasParam()) {
        MapTag map = attribute.paramAsType(MapTag.class);
        ObjectTag idObj = map.getObject("id");
        ObjectTag locationObj = map.getObject("location");
        if (idObj == null || locationObj == null) {
            return;
        }
        NamespacedKey key = NamespacedKey.fromString(CoreUtilities.toLowerCase(idObj.toString()));
        if (key == null) {
            return;
        }
        LootTable table = Bukkit.getLootTable(key);
        LootContext.Builder context = new LootContext.Builder(locationObj.asType(LocationTag.class, attribute.context));
        ObjectTag killer = map.getObject("killer");
        ObjectTag luck = map.getObject("luck");
        ObjectTag bonus = map.getObject("loot_bonus");
        ObjectTag entity = map.getObject("entity");
        if (entity != null) {
            context = context.lootedEntity(entity.asType(EntityTag.class, attribute.context).getBukkitEntity());
        }
        if (killer != null) {
            context = context.killer((HumanEntity) killer.asType(EntityTag.class, attribute.context).getLivingEntity());
        }
        if (luck != null) {
            context = context.luck(luck.asElement().asFloat());
        }
        if (bonus != null) {
            context = context.lootingModifier(bonus.asElement().asInt());
        }
        Collection<ItemStack> items;
        try {
            items = table.populateLoot(CoreUtilities.getRandom(), context.build());
        } catch (Throwable ex) {
            attribute.echoError("Loot table failed to generate: " + ex.getMessage());
            if (Debug.verbose) {
                attribute.echoError(ex);
            }
            return;
        }
        ListTag result = new ListTag();
        for (ItemStack item : items) {
            if (item != null && item.getType() != Material.AIR) {
                result.addObject(new ItemTag(item));
            }
        }
        event.setReplacedObject(result.getObjectAttribute(attribute.fulfill(1)));
    } else // -->
    if (attribute.startsWith("stack_trace")) {
        String trace = com.denizenscript.denizen.utilities.debugging.Debug.getFullExceptionMessage(new RuntimeException("TRACE"), false);
        event.setReplacedObject(new ElementTag(trace).getObjectAttribute(attribute.fulfill(1)));
    }
}
Also used : Plugin(org.bukkit.plugin.Plugin) PatternType(org.bukkit.block.banner.PatternType) Utilities(com.denizenscript.denizen.utilities.Utilities) AssignmentScriptContainer(com.denizenscript.denizen.scripts.containers.core.AssignmentScriptContainer) Connection(java.sql.Connection) TagManager(com.denizenscript.denizencore.tags.TagManager) Enchantment(org.bukkit.enchantments.Enchantment) NMSHandler(com.denizenscript.denizen.nms.NMSHandler) SQLCommand(com.denizenscript.denizencore.scripts.commands.core.SQLCommand) CommandScriptHelper(com.denizenscript.denizen.scripts.containers.core.CommandScriptHelper) TagRunnable(com.denizenscript.denizencore.tags.TagRunnable) Event(org.bukkit.event.Event) BossBarCommand(com.denizenscript.denizen.scripts.commands.server.BossBarCommand) Player(org.bukkit.entity.Player) NoteManager(com.denizenscript.denizencore.objects.notable.NoteManager) Biome(org.bukkit.block.Biome) Objective(org.bukkit.scoreboard.Objective) org.bukkit(org.bukkit) org.bukkit.inventory(org.bukkit.inventory) Scoreboard(org.bukkit.scoreboard.Scoreboard) CitizensAPI(net.citizensnpcs.api.CitizensAPI) VanillaTagHelper(com.denizenscript.denizen.utilities.VanillaTagHelper) BukkitTagContext(com.denizenscript.denizen.tags.BukkitTagContext) PotionType(org.bukkit.potion.PotionType) EntityType(org.bukkit.entity.EntityType) PluginCommand(org.bukkit.command.PluginCommand) BukkitScriptEvent(com.denizenscript.denizen.events.BukkitScriptEvent) Settings(com.denizenscript.denizen.utilities.Settings) MapCursor(org.bukkit.map.MapCursor) SlotHelper(com.denizenscript.denizen.utilities.inventory.SlotHelper) Deprecations(com.denizenscript.denizencore.utilities.Deprecations) PotionEffectType(org.bukkit.potion.PotionEffectType) HandlerList(org.bukkit.event.HandlerList) Citizens(net.citizensnpcs.Citizens) java.util(java.util) ScriptContainer(com.denizenscript.denizencore.scripts.containers.ScriptContainer) ReplaceableTagEvent(com.denizenscript.denizencore.tags.ReplaceableTagEvent) NPCRegistry(net.citizensnpcs.api.npc.NPCRegistry) Debug(com.denizenscript.denizencore.utilities.debugging.Debug) NPC(net.citizensnpcs.api.npc.NPC) LootContext(org.bukkit.loot.LootContext) DenizenCore(com.denizenscript.denizencore.DenizenCore) FutureWarning(com.denizenscript.denizencore.utilities.debugging.FutureWarning) SQLException(java.sql.SQLException) CommandContext(net.citizensnpcs.api.command.CommandContext) TickScriptEvent(com.denizenscript.denizencore.events.core.TickScriptEvent) ScriptRegistry(com.denizenscript.denizencore.scripts.ScriptRegistry) Attribute(com.denizenscript.denizencore.tags.Attribute) EntityDamageEvent(org.bukkit.event.entity.EntityDamageEvent) Listener(org.bukkit.event.Listener) HumanEntity(org.bukkit.entity.HumanEntity) AssignmentTrait(com.denizenscript.denizen.npc.traits.AssignmentTrait) LootTable(org.bukkit.loot.LootTable) Team(org.bukkit.scoreboard.Team) ScriptEvent(com.denizenscript.denizencore.events.ScriptEvent) com.denizenscript.denizencore.objects.core(com.denizenscript.denizencore.objects.core) Depends(com.denizenscript.denizen.utilities.depends.Depends) Notable(com.denizenscript.denizencore.objects.notable.Notable) File(java.io.File) com.denizenscript.denizen.objects(com.denizenscript.denizen.objects) Denizen(com.denizenscript.denizen.Denizen) RegisteredListener(org.bukkit.plugin.RegisteredListener) Consumer(java.util.function.Consumer) TraitInfo(net.citizensnpcs.api.trait.TraitInfo) BossBar(org.bukkit.boss.BossBar) PlayerTeleportEvent(org.bukkit.event.player.PlayerTeleportEvent) YamlConfiguration(org.bukkit.configuration.file.YamlConfiguration) ScoreboardHelper(com.denizenscript.denizen.utilities.ScoreboardHelper) com.denizenscript.denizencore.objects(com.denizenscript.denizencore.objects) CoreUtilities(com.denizenscript.denizencore.utilities.CoreUtilities) BossBar(org.bukkit.boss.BossBar) TraitInfo(net.citizensnpcs.api.trait.TraitInfo) HumanEntity(org.bukkit.entity.HumanEntity) PatternType(org.bukkit.block.banner.PatternType) PotionEffectType(org.bukkit.potion.PotionEffectType) MapCursor(org.bukkit.map.MapCursor) PotionType(org.bukkit.potion.PotionType) Attribute(com.denizenscript.denizencore.tags.Attribute) YamlConfiguration(org.bukkit.configuration.file.YamlConfiguration) Biome(org.bukkit.block.Biome) Team(org.bukkit.scoreboard.Team) EntityDamageEvent(org.bukkit.event.entity.EntityDamageEvent) NPCRegistry(net.citizensnpcs.api.npc.NPCRegistry) LootTable(org.bukkit.loot.LootTable) Connection(java.sql.Connection) AssignmentTrait(com.denizenscript.denizen.npc.traits.AssignmentTrait) BukkitScriptEvent(com.denizenscript.denizen.events.BukkitScriptEvent) TickScriptEvent(com.denizenscript.denizencore.events.core.TickScriptEvent) ScriptEvent(com.denizenscript.denizencore.events.ScriptEvent) AssignmentScriptContainer(com.denizenscript.denizen.scripts.containers.core.AssignmentScriptContainer) Player(org.bukkit.entity.Player) LootContext(org.bukkit.loot.LootContext) PlayerTeleportEvent(org.bukkit.event.player.PlayerTeleportEvent) Notable(com.denizenscript.denizencore.objects.notable.Notable) EntityType(org.bukkit.entity.EntityType) Objective(org.bukkit.scoreboard.Objective) AssignmentScriptContainer(com.denizenscript.denizen.scripts.containers.core.AssignmentScriptContainer) ScriptContainer(com.denizenscript.denizencore.scripts.containers.ScriptContainer) BukkitTagContext(com.denizenscript.denizen.tags.BukkitTagContext) Enchantment(org.bukkit.enchantments.Enchantment) File(java.io.File) NPC(net.citizensnpcs.api.npc.NPC) Listener(org.bukkit.event.Listener) RegisteredListener(org.bukkit.plugin.RegisteredListener) SQLException(java.sql.SQLException) Scoreboard(org.bukkit.scoreboard.Scoreboard) PluginCommand(org.bukkit.command.PluginCommand) SQLException(java.sql.SQLException) Plugin(org.bukkit.plugin.Plugin)

Example 18 with Scoreboard

use of org.bukkit.scoreboard.Scoreboard in project acidisland by tastybento.

the class PluginConfig method loadPluginConfig.

/**
 * Loads the various settings from the config.yml file into the plugin
 * @param plugin - ASkyBlock plugin object - askyblock
 * @return true if plugin config is loaded correctly
 */
public static boolean loadPluginConfig(ASkyBlock plugin) {
    try {
        plugin.getConfig();
    } catch (final Exception e) {
        e.printStackTrace();
    }
    // The order in this file should match the order in config.yml so that it is easy to check that everything is covered
    // ********************** Island settings **************************
    Settings.islandDistance = plugin.getConfig().getInt("island.distance", 200);
    if (Settings.islandDistance < 50) {
        Settings.islandDistance = 50;
        plugin.getLogger().info("Setting minimum island distance to 50");
    }
    if (Settings.islandDistance % 2 != 0) {
        plugin.getLogger().warning("Island distance should be even!");
    }
    Settings.islandProtectionRange = plugin.getConfig().getInt("island.protectionRange", 100);
    if (Settings.islandProtectionRange > Settings.islandDistance) {
        plugin.getLogger().warning("Protection range cannot be > island distance. Setting them to be equal.");
        Settings.islandProtectionRange = Settings.islandDistance;
    }
    if (Settings.islandProtectionRange <= 0) {
        plugin.getLogger().warning("Protection range of 0 in config.yml: To disable protection, the range should");
        plugin.getLogger().warning("equal the island distance and then you should allow all island protection flags");
        plugin.getLogger().warning("in config.yml. Protection range will be set to island distance (" + Settings.islandDistance + ")");
        Settings.islandProtectionRange = Settings.islandDistance;
    }
    if (Settings.islandProtectionRange % 2 != 0) {
        Settings.islandProtectionRange--;
        plugin.getLogger().warning("Protection range must be even, using " + Settings.islandProtectionRange);
    }
    // xoffset and zoffset are not public and only used for IslandWorld compatibility
    Settings.islandXOffset = plugin.getConfig().getInt("island.xoffset", 0);
    if (Settings.islandXOffset < 0) {
        Settings.islandXOffset = 0;
        plugin.getLogger().info("Setting minimum island X Offset to 0");
    } else if (Settings.islandXOffset > Settings.islandDistance) {
        Settings.islandXOffset = Settings.islandDistance;
        plugin.getLogger().info("Setting maximum island X Offset to " + Settings.islandDistance);
    }
    Settings.islandZOffset = plugin.getConfig().getInt("island.zoffset", 0);
    if (Settings.islandZOffset < 0) {
        Settings.islandZOffset = 0;
        plugin.getLogger().info("Setting minimum island Z Offset to 0");
    } else if (Settings.islandZOffset > Settings.islandDistance) {
        Settings.islandZOffset = Settings.islandDistance;
        plugin.getLogger().info("Setting maximum island Z Offset to " + Settings.islandDistance);
    }
    // This is the origin of new islands
    long x = plugin.getConfig().getLong("island.startx", 0);
    // Check this is a multiple of island distance
    long z = plugin.getConfig().getLong("island.startz", 0);
    Settings.islandStartX = Math.round((double) x / Settings.islandDistance) * Settings.islandDistance + Settings.islandXOffset;
    Settings.islandStartZ = Math.round((double) z / Settings.islandDistance) * Settings.islandDistance + Settings.islandZOffset;
    // ASkyBlock and AcidIsland difference
    if (Settings.GAMETYPE.equals(Settings.GameType.ACIDISLAND)) {
        Settings.islandHeight = plugin.getConfig().getInt("island.islandlevel", 50) - 5;
        // The island's center is actually 5 below sea level
        Settings.seaHeight = plugin.getConfig().getInt("island.sealevel", 50);
    } else {
        // ASkyBlock
        Settings.islandHeight = plugin.getConfig().getInt("island.islandlevel", 120) - 5;
        // The island's center is actually 5 below sea level
        Settings.seaHeight = plugin.getConfig().getInt("island.sealevel", 0);
    }
    if (Settings.islandHeight < 0) {
        Settings.islandHeight = 0;
    }
    if (Settings.seaHeight < 0) {
        Settings.seaHeight = 0;
    }
    // Island reset settings
    Settings.resetLimit = plugin.getConfig().getInt("island.resetlimit", 2);
    if (Settings.resetWait < 0) {
        Settings.resetWait = -1;
    }
    Settings.resetWait = plugin.getConfig().getInt("island.resetwait", 300);
    if (Settings.resetWait < 0) {
        Settings.resetWait = 0;
    }
    // Seconds to wait for a confirmation of reset
    Settings.resetConfirmWait = plugin.getConfig().getInt("island.resetconfirmwait", 10);
    if (Settings.resetConfirmWait < 0) {
        Settings.resetConfirmWait = 0;
    }
    // Timeout required between duplicate team join/leaves
    Settings.inviteWait = plugin.getConfig().getInt("island.invitewait", 60);
    if (Settings.inviteWait < 0) {
        Settings.inviteWait = 0;
    }
    // Invite timeout before accept/reject timesout
    Settings.inviteTimeout = plugin.getConfig().getInt("island.invitetimeout", 60);
    // Convert to ticks
    Settings.inviteTimeout *= 20;
    // Max team size
    Settings.maxTeamSize = plugin.getConfig().getInt("island.maxteamsize", 4);
    // Deprecated settings - use permission askyblock.team.maxsize.<number> instead
    /*
        Settings.maxTeamSizeVIP = plugin.getConfig().getInt("island.vipteamsize", 0);
        Settings.maxTeamSizeVIP2 = plugin.getConfig().getInt("island.vip2teamsize", 0);
        if (Settings.maxTeamSizeVIP > 0 || Settings.maxTeamSizeVIP2 > 0) {
            plugin.getLogger().warning(Settings.PERMPREFIX + "team.vip and " + Settings.PERMPREFIX + "team.vip2 are deprecated!");
            plugin.getLogger().warning("Use permission " + Settings.PERMPREFIX + "team.maxsize.<number> instead.");
        }
         */
    // Island level cool down time
    Settings.levelWait = plugin.getConfig().getInt("island.levelwait", 60);
    if (Settings.levelWait < 0) {
        Settings.levelWait = 0;
    }
    // Get chest items
    String chestItems = plugin.getConfig().getString("island.chestItems", "");
    if (!chestItems.isEmpty()) {
        final String[] chestItemString = chestItems.split(" ");
        // plugin.getLogger().info("DEBUG: chest items = " + chestItemString);
        final ItemStack[] tempChest = new ItemStack[chestItemString.length];
        for (int i = 0; i < tempChest.length; i++) {
            String[] amountdata = chestItemString[i].split(":");
            try {
                if (amountdata.length == 3 && amountdata[0].equalsIgnoreCase("MONSTER_EGG")) {
                    try {
                        EntityType type = EntityType.valueOf(amountdata[1].toUpperCase());
                        if (Bukkit.getServer().getVersion().contains("(MC: 1.8") || Bukkit.getServer().getVersion().contains("(MC: 1.7")) {
                            tempChest[i] = new SpawnEgg(type).toItemStack(Integer.parseInt(amountdata[2]));
                        } else {
                            try {
                                tempChest[i] = new SpawnEgg1_9(type).toItemStack(Integer.parseInt(amountdata[2]));
                            } catch (Exception ex) {
                                tempChest[i] = new ItemStack(Material.MONSTER_EGG);
                                plugin.getLogger().severe("Monster eggs not supported with this server version.");
                            }
                        }
                    } catch (Exception e) {
                        plugin.getLogger().severe("Spawn eggs must be described by name. Try one of these (not all are possible):");
                        for (EntityType type : EntityType.values()) {
                            if (type.isSpawnable() && type.isAlive()) {
                                plugin.getLogger().severe(type.toString());
                            }
                        }
                    }
                } else if (amountdata[0].equals("POTION")) {
                    // amountdata.length);
                    if (amountdata.length == 6) {
                        tempChest[i] = Challenges.getPotion(amountdata, Integer.parseInt(amountdata[5]), "config.yml");
                    } else {
                        plugin.getLogger().severe("Problem loading chest item from config.yml so skipping it: " + chestItemString[i]);
                        plugin.getLogger().severe("Potions for the chest must be fully defined as POTION:NAME:<LEVEL>:<EXTENDED>:<SPLASH/LINGER>:QTY");
                    }
                } else {
                    Material mat;
                    if (StringUtils.isNumeric(amountdata[0])) {
                        mat = Material.getMaterial(Integer.parseInt(amountdata[0]));
                    } else {
                        mat = Material.getMaterial(amountdata[0].toUpperCase());
                    }
                    if (amountdata.length == 2) {
                        tempChest[i] = new ItemStack(mat, Integer.parseInt(amountdata[1]));
                    } else if (amountdata.length == 3) {
                        tempChest[i] = new ItemStack(mat, Integer.parseInt(amountdata[2]), Short.parseShort(amountdata[1]));
                    }
                }
            } catch (java.lang.IllegalArgumentException ex) {
                ex.printStackTrace();
                plugin.getLogger().severe("Problem loading chest item from config.yml so skipping it: " + chestItemString[i]);
                plugin.getLogger().severe("Error is : " + ex.getMessage());
                plugin.getLogger().info("Potential potion types are: ");
                for (PotionType c : PotionType.values()) plugin.getLogger().info(c.name());
            } catch (Exception e) {
                e.printStackTrace();
                plugin.getLogger().severe("Problem loading chest item from config.yml so skipping it: " + chestItemString[i]);
                plugin.getLogger().info("Potential material types are: ");
                for (Material c : Material.values()) plugin.getLogger().info(c.name());
            // e.printStackTrace();
            }
        }
        Settings.chestItems = tempChest;
    } else {
        // Nothing in the chest
        Settings.chestItems = new ItemStack[0];
    }
    // Defaul companion
    String companion = plugin.getConfig().getString("island.companion", "COW").toUpperCase();
    Settings.islandCompanion = null;
    if (!companion.equalsIgnoreCase("NOTHING")) {
        String commaList = "NOTHING, ";
        for (EntityType type : EntityType.values()) {
            if (companion.equalsIgnoreCase(type.toString())) {
                Settings.islandCompanion = type;
                break;
            }
            commaList += ", " + type.toString();
        }
        if (Settings.islandCompanion == null) {
            plugin.getLogger().warning("Island companion is not recognized. Pick from " + commaList);
        }
    }
    // Companion names
    List<String> companionNames = plugin.getConfig().getStringList("island.companionnames");
    Settings.companionNames = new ArrayList<String>();
    for (String name : companionNames) {
        Settings.companionNames.add(ChatColor.translateAlternateColorCodes('&', name));
    }
    // Island name length
    Settings.minNameLength = plugin.getConfig().getInt("island.minnamelength", 1);
    Settings.maxNameLength = plugin.getConfig().getInt("island.maxnamelength", 20);
    if (Settings.minNameLength < 0) {
        Settings.minNameLength = 0;
    }
    if (Settings.maxNameLength < 1) {
        Settings.maxNameLength = 1;
    }
    if (Settings.minNameLength > Settings.maxNameLength) {
        Settings.minNameLength = Settings.maxNameLength;
    }
    // Flymode expiration while flying oustide island boundaries
    Settings.flyTimeOutside = plugin.getConfig().getInt("island.flytimeoutside", 0);
    if (Settings.flyTimeOutside < 0) {
        Settings.flyTimeOutside = 0;
    }
    // Temporary Permissions while inside island
    Settings.temporaryPermissions = plugin.getConfig().getStringList("island.islandtemporaryperms");
    // System settings
    Settings.allowEndermanGriefing = plugin.getConfig().getBoolean("island.allowendermangriefing", true);
    Settings.endermanDeathDrop = plugin.getConfig().getBoolean("island.endermandeathdrop", true);
    Settings.allowCreeperDamage = plugin.getConfig().getBoolean("island.allowcreeperdamage", true);
    Settings.allowCreeperGriefing = plugin.getConfig().getBoolean("island.allowcreepergriefing", false);
    Settings.allowTNTDamage = plugin.getConfig().getBoolean("island.allowtntdamage", false);
    Settings.allowFireExtinguish = plugin.getConfig().getBoolean("island.allowfireextinguish", false);
    Settings.allowChestDamage = plugin.getConfig().getBoolean("island.allowchestdamage", false);
    Settings.allowVisitorKeepInvOnDeath = plugin.getConfig().getBoolean("island.allowvisitorkeepinvondeath", false);
    Settings.allowPistonPush = plugin.getConfig().getBoolean("island.allowpistonpush", true);
    Settings.allowMobDamageToItemFrames = plugin.getConfig().getBoolean("island.allowitemframedamage", false);
    // Clean up blocks around edges when deleting islands - this is a hidden setting not in the config.yml
    // Add if admins complain about slow cleaning.
    Settings.cleanRate = plugin.getConfig().getInt("island.cleanrate", 2);
    if (Settings.cleanRate < 1) {
        Settings.cleanRate = 1;
    }
    // ******** General Settings **********
    // Load world name
    Settings.worldName = plugin.getConfig().getString("general.worldName");
    // Check if the world name matches island.yml info
    File islandFile = new File(plugin.getDataFolder(), "islands.yml");
    if (islandFile.exists()) {
        YamlConfiguration islandYaml = new YamlConfiguration();
        try {
            islandYaml.load(islandFile);
            if (!islandYaml.contains(Settings.worldName)) {
                // Bad news, stop everything and tell the admin
                plugin.getLogger().severe("+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+");
                plugin.getLogger().severe("More set up is required. Go to config.yml and edit it.");
                plugin.getLogger().severe("");
                plugin.getLogger().severe("Check island world name is same as world in islands.yml.");
                plugin.getLogger().severe("If you are resetting and changing world, delete island.yml and restart.");
                plugin.getLogger().severe("");
                plugin.getLogger().severe("+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+");
                return false;
            }
        } catch (Exception e) {
        }
    }
    // Get the default language
    Settings.defaultLanguage = plugin.getConfig().getString("general.defaultlanguage", "en-US");
    // Load languages
    HashMap<String, ASLocale> availableLocales = new HashMap<String, ASLocale>();
    FileLister fl = new FileLister(plugin);
    try {
        int index = 1;
        for (String code : fl.list()) {
            // plugin.getLogger().info("DEBUG: lang file = " + code);
            availableLocales.put(code, new ASLocale(plugin, code, index++));
        }
    } catch (IOException e1) {
        plugin.getLogger().severe("Could not add locales!");
    }
    if (!availableLocales.containsKey(Settings.defaultLanguage)) {
        plugin.getLogger().severe("'" + Settings.defaultLanguage + ".yml' not found in /locale folder. Using /locale/en-US.yml");
        Settings.defaultLanguage = "en-US";
        availableLocales.put(Settings.defaultLanguage, new ASLocale(plugin, Settings.defaultLanguage, 0));
    }
    plugin.setAvailableLocales(availableLocales);
    // Check for updates
    Settings.updateCheck = plugin.getConfig().getBoolean("general.checkupdates", true);
    // Silence command feedback
    Settings.silenceCommandFeedback = plugin.getConfig().getBoolean("general.silencecommandfeedback", true);
    // Action bar settings
    Settings.showInActionBar = plugin.getConfig().getBoolean("general.showinactionbar", true);
    // Max Islands
    Settings.maxIslands = plugin.getConfig().getInt("general.maxIslands", 0);
    // Use control panel
    Settings.useControlPanel = plugin.getConfig().getBoolean("general.usecontrolpanel", false);
    // Create nether or not
    Settings.createNether = plugin.getConfig().getBoolean("general.createnether", true);
    if (!Settings.createNether) {
        plugin.getLogger().info("The Nether is disabled");
    }
    // Use the island nether
    Settings.newNether = plugin.getConfig().getBoolean("general.newnether", true);
    // Nether trees
    Settings.netherTrees = plugin.getConfig().getBoolean("general.nethertrees", true);
    // Nether roof option
    Settings.netherRoof = plugin.getConfig().getBoolean("general.netherroof", true);
    // Nether spawn protection radius
    Settings.netherSpawnRadius = plugin.getConfig().getInt("general.netherspawnradius", 25);
    if (Settings.netherSpawnRadius < 0) {
        Settings.netherSpawnRadius = 0;
    } else if (Settings.netherSpawnRadius > 100) {
        Settings.netherSpawnRadius = 100;
    }
    // Nether roof option
    Settings.netherRoof = plugin.getConfig().getBoolean("general.netherroof", true);
    // Run level calc at login
    Settings.loginLevel = plugin.getConfig().getBoolean("general.loginlevel", false);
    // Island reset commands
    Settings.resetCommands = plugin.getConfig().getStringList("general.resetcommands");
    Settings.leaveCommands = plugin.getConfig().getStringList("general.leavecommands");
    Settings.startCommands = plugin.getConfig().getStringList("general.startcommands");
    Settings.teamStartCommands = plugin.getConfig().getStringList("general.teamstartcommands");
    Settings.visitorCommandBlockList = plugin.getConfig().getStringList("general.visitorbannedcommands");
    // How long a player has to wait after deactivating PVP until they can activate PVP again
    Settings.pvpRestartCooldown = plugin.getConfig().getLong("general.pvpcooldown", 60);
    // Invincible visitors
    Settings.invincibleVisitors = plugin.getConfig().getBoolean("general.invinciblevisitors", false);
    if (Settings.invincibleVisitors) {
        Settings.visitorDamagePrevention = new HashSet<DamageCause>();
        List<String> damageSettings = plugin.getConfig().getStringList("general.invinciblevisitorsoptions");
        for (DamageCause cause : DamageCause.values()) {
            if (damageSettings.contains(cause.toString())) {
                Settings.visitorDamagePrevention.add(cause);
            }
        }
    }
    // ASkyBlock and AcidIsland difference
    if (Settings.GAMETYPE.equals(Settings.GameType.ACIDISLAND)) {
        Settings.acidDamage = plugin.getConfig().getDouble("general.aciddamage", 5D);
        if (Settings.acidDamage > 100D) {
            Settings.acidDamage = 100D;
        } else if (Settings.acidDamage < 0D) {
            Settings.acidDamage = 0D;
        }
        Settings.mobAcidDamage = plugin.getConfig().getDouble("general.mobaciddamage", 10D);
        if (Settings.mobAcidDamage > 100D) {
            Settings.mobAcidDamage = 100D;
        } else if (Settings.mobAcidDamage < 0D) {
            Settings.mobAcidDamage = 0D;
        }
        Settings.rainDamage = plugin.getConfig().getDouble("general.raindamage", 0.5D);
        if (Settings.rainDamage > 100D) {
            Settings.rainDamage = 100D;
        } else if (Settings.rainDamage < 0D) {
            Settings.rainDamage = 0D;
        }
    } else {
        Settings.acidDamage = plugin.getConfig().getDouble("general.aciddamage", 0D);
        if (Settings.acidDamage > 100D) {
            Settings.acidDamage = 100D;
        } else if (Settings.acidDamage < 0D) {
            Settings.acidDamage = 0D;
        }
        Settings.mobAcidDamage = plugin.getConfig().getDouble("general.mobaciddamage", 0D);
        if (Settings.mobAcidDamage > 100D) {
            Settings.mobAcidDamage = 100D;
        } else if (Settings.mobAcidDamage < 0D) {
            Settings.mobAcidDamage = 0D;
        }
        Settings.rainDamage = plugin.getConfig().getDouble("general.raindamage", 0D);
        if (Settings.rainDamage > 100D) {
            Settings.rainDamage = 100D;
        } else if (Settings.rainDamage < 0D) {
            Settings.rainDamage = 0D;
        }
    }
    Settings.animalAcidDamage = plugin.getConfig().getDouble("general.animaldamage", 0D);
    if (Settings.animalAcidDamage > 100D) {
        Settings.animalAcidDamage = 100D;
    } else if (Settings.animalAcidDamage < 0D) {
        Settings.animalAcidDamage = 0D;
    }
    Settings.damageChickens = plugin.getConfig().getBoolean("general.damagechickens", false);
    // Destroy items in acid timer
    Settings.acidItemDestroyTime = plugin.getConfig().getLong("general.itemdestroyafter", 0L) * 20L;
    Settings.damageOps = plugin.getConfig().getBoolean("general.damageops", false);
    // Helmet and full armor acid protection options
    Settings.helmetProtection = plugin.getConfig().getBoolean("general.helmetprotection", true);
    Settings.fullArmorProtection = plugin.getConfig().getBoolean("general.fullarmorprotection", false);
    // Damage Type
    List<String> acidDamageType = plugin.getConfig().getStringList("general.damagetype");
    Settings.acidDamageType.clear();
    if (acidDamageType != null) {
        for (String effect : acidDamageType) {
            PotionEffectType newPotionType = PotionEffectType.getByName(effect);
            if (newPotionType != null) {
                // Check if it is a valid addition
                if (newPotionType.equals(PotionEffectType.BLINDNESS) || newPotionType.equals(PotionEffectType.CONFUSION) || newPotionType.equals(PotionEffectType.HUNGER) || newPotionType.equals(PotionEffectType.POISON) || newPotionType.equals(PotionEffectType.SLOW) || newPotionType.equals(PotionEffectType.SLOW_DIGGING) || newPotionType.equals(PotionEffectType.WEAKNESS)) {
                    Settings.acidDamageType.add(newPotionType);
                }
            } else {
                plugin.getLogger().warning("Could not interpret acid damage modifier: " + effect + " - skipping");
                plugin.getLogger().warning("Types can be : SLOW, SLOW_DIGGING, CONFUSION,");
                plugin.getLogger().warning("BLINDNESS, HUNGER, WEAKNESS and POISON");
            }
        }
    }
    Settings.logInRemoveMobs = plugin.getConfig().getBoolean("general.loginremovemobs", true);
    Settings.islandRemoveMobs = plugin.getConfig().getBoolean("general.islandremovemobs", false);
    List<String> mobWhiteList = plugin.getConfig().getStringList("general.mobwhitelist");
    Settings.mobWhiteList.clear();
    for (String mobName : mobWhiteList) {
        boolean mobFound = false;
        for (EntityType type : EntityType.values()) {
            if (mobName.toUpperCase().equals(type.toString())) {
                try {
                    Settings.mobWhiteList.add(EntityType.valueOf(mobName.toUpperCase()));
                } catch (Exception e) {
                    plugin.getLogger().severe("Error in config.yml, mobwhitelist value '" + mobName + "' is invalid.");
                }
                mobFound = true;
                break;
            }
        }
        if (!mobFound) {
            plugin.getLogger().severe("Error in config.yml, mobwhitelist value '" + mobName + "' is invalid.");
            plugin.getLogger().severe("Possible values are : ");
            for (EntityType e : EntityType.values()) {
                if (e.isAlive()) {
                    plugin.getLogger().severe(e.name());
                }
            }
        }
    }
    Settings.monsterSpawnLimit = plugin.getConfig().getInt("general.monsterspawnlimit", 100);
    if (Settings.monsterSpawnLimit < -1) {
        Settings.monsterSpawnLimit = -1;
    }
    Settings.animalSpawnLimit = plugin.getConfig().getInt("general.animalspawnlimit", 15);
    if (Settings.animalSpawnLimit < -1) {
        Settings.animalSpawnLimit = -1;
    }
    Settings.breedingLimit = plugin.getConfig().getInt("general.breedinglimit", 0);
    Settings.waterAnimalSpawnLimit = plugin.getConfig().getInt("general.wateranimalspawnlimit", 15);
    if (Settings.waterAnimalSpawnLimit < -1) {
        Settings.waterAnimalSpawnLimit = -1;
    }
    Settings.villagerLimit = plugin.getConfig().getInt("general.villagerlimit", 0);
    Settings.limitedBlocks = new HashMap<String, Integer>();
    Settings.entityLimits = new HashMap<EntityType, Integer>();
    Settings.saveEntities = plugin.getConfig().getBoolean("general.saveentitylimits");
    Settings.coopsCanCreateWarps = plugin.getConfig().getBoolean("general.coopscancreatewarps");
    Settings.deleteProtectedOnly = plugin.getConfig().getBoolean("general.deleteprotectedonly", true);
    plugin.getLogger().info("Loading entity limits");
    ConfigurationSection entityLimits = plugin.getConfig().getConfigurationSection("general.entitylimits");
    if (entityLimits != null) {
        for (String entity : entityLimits.getKeys(false)) {
            int limit = entityLimits.getInt(entity.toUpperCase(), -1);
            // Check if this is an entity
            for (EntityType type : EntityType.values()) {
                // plugin.getLogger().info("DEBUG: is " + entity + " = " + type.name() + "?");
                if (type.name().equals(entity.toUpperCase())) {
                    // plugin.getLogger().info("DEBUG: yes");
                    Settings.entityLimits.put(type, limit);
                    if (limit > 0) {
                        plugin.getLogger().info(entity.toUpperCase() + " will be limited to " + limit);
                    }
                    break;
                }
            }
            if (Material.getMaterial(entity.toUpperCase()) != null && limit > -1) {
                Settings.limitedBlocks.put(entity.toUpperCase(), limit);
                plugin.getLogger().info(entity.toUpperCase() + " will be limited to " + limit);
                if (entity.equalsIgnoreCase("REDSTONE_COMPARATOR")) {
                    // Player can only ever place a redstone comparator in the OFF state
                    Settings.limitedBlocks.put("REDSTONE_COMPARATOR_OFF", limit);
                } else if (entity.equalsIgnoreCase("BANNER")) {
                    // To simplify banners, the banner is allowed and automatically made wall and standing banner
                    Settings.limitedBlocks.put("WALL_BANNER", limit);
                    Settings.limitedBlocks.put("STANDING_BANNER", limit);
                } else if (entity.equalsIgnoreCase("SIGN")) {
                    // To simplify signs, the sign is allowed and automatically made wall and standing signs
                    Settings.limitedBlocks.put("WALL_SIGN", limit);
                    Settings.limitedBlocks.put("SIGN_POST", limit);
                }
            }
        }
    }
    // Level to purge
    Settings.abandonedIslandLevel = plugin.getConfig().getInt("general.abandonedislandlevel", 10);
    if (Settings.abandonedIslandLevel < 0) {
        Settings.abandonedIslandLevel = 0;
    }
    Settings.maxPurge = plugin.getConfig().getInt("general.maxpurge", 500);
    if (Settings.maxPurge < 0) {
        Settings.maxPurge = 0;
    }
    // Use economy or not
    // In future expand to include internal economy
    Settings.useEconomy = plugin.getConfig().getBoolean("general.useeconomy", true);
    // Reset money when an island is started
    Settings.resetMoney = plugin.getConfig().getBoolean("general.resetmoney", true);
    // Use the minishop or not
    Settings.useMinishop = plugin.getConfig().getBoolean("general.useminishop", true);
    // Starting money - default $0
    Settings.startingMoney = plugin.getConfig().getDouble("general.startingmoney", 0D);
    // Things to reset when an island is reset
    Settings.resetChallenges = plugin.getConfig().getBoolean("general.resetchallenges", true);
    Settings.clearInventory = plugin.getConfig().getBoolean("general.resetinventory", true);
    // Kicked players keep inventory
    Settings.kickedKeepInv = plugin.getConfig().getBoolean("general.kickedkeepinv", false);
    // Leavers lose resets
    Settings.leaversLoseReset = plugin.getConfig().getBoolean("general.leaversloseresets", true);
    // Reset the ender chest
    Settings.resetEnderChest = plugin.getConfig().getBoolean("general.resetenderchest", false);
    // Check if /island command is allowed when falling
    Settings.allowTeleportWhenFalling = plugin.getConfig().getBoolean("general.allowfallingteleport", true);
    Settings.fallingCommandBlockList = plugin.getConfig().getStringList("general.blockingcommands");
    // Challenges
    Settings.broadcastMessages = plugin.getConfig().getBoolean("general.broadcastmessages", true);
    Settings.removeCompleteOntimeChallenges = plugin.getConfig().getBoolean("general.removecompleteonetimechallenges", false);
    Settings.addCompletedGlow = plugin.getConfig().getBoolean("general.addcompletedglow", true);
    // Max home number
    Settings.maxHomes = plugin.getConfig().getInt("general.maxhomes", 1);
    if (Settings.maxHomes < 1) {
        Settings.maxHomes = 1;
    }
    // Make island automatically
    Settings.makeIslandIfNone = plugin.getConfig().getBoolean("general.makeislandifnone", false);
    // Immediate teleport
    Settings.immediateTeleport = plugin.getConfig().getBoolean("general.immediateteleport", false);
    // Respawn on island
    Settings.respawnOnIsland = plugin.getConfig().getBoolean("general.respawnonisland", false);
    // Team chat
    Settings.teamChat = plugin.getConfig().getBoolean("general.teamchat", true);
    Settings.logTeamChat = plugin.getConfig().getBoolean("general.logteamchat", true);
    // Chat prefixes
    Settings.chatLevelPrefix = plugin.getConfig().getString("general.chatlevelprefix", "{ISLAND_LEVEL}");
    Settings.chatChallengeLevelPrefix = plugin.getConfig().getString("general.chatchallanegelevelprefix", "{ISLAND_CHALLENGE_LEVEL}");
    Settings.chatIslandPlayer = plugin.getConfig().getString("general.chatislandplayer", "{ISLAND_PLAYER}");
    // Chat team suffixes - Not public right now
    Settings.setTeamName = plugin.getConfig().getBoolean("general.setteamsuffix", false);
    Settings.teamSuffix = plugin.getConfig().getString("general.teamsuffix", "([level])");
    // Restrict wither
    Settings.restrictWither = plugin.getConfig().getBoolean("general.restrictwither", true);
    // Warp Restriction
    Settings.warpLevelsRestriction = plugin.getConfig().getInt("general.warplevelrestriction", 10);
    // Warp panel
    Settings.useWarpPanel = plugin.getConfig().getBoolean("general.usewarppanel", true);
    // Mute death messages
    Settings.muteDeathMessages = plugin.getConfig().getBoolean("general.mutedeathmessages", false);
    // How often the grid will be saved to file. Default is 5 minutes
    Settings.backupDuration = (plugin.getConfig().getLong("general.backupduration", 5) * 20 * 60);
    // Allow pushing
    Settings.allowPushing = plugin.getConfig().getBoolean("general.allowpushing", true);
    // try to remove the team from the scoreboard
    if (Settings.allowPushing) {
        try {
            ScoreboardManager manager = plugin.getServer().getScoreboardManager();
            if (manager != null) {
                Scoreboard scoreboard = manager.getMainScoreboard();
                if (scoreboard != null) {
                    Team pTeam = scoreboard.getTeam(NO_PUSH_TEAM_NAME);
                    if (pTeam != null) {
                        pTeam.unregister();
                    }
                }
            }
        } catch (Exception e) {
            plugin.getLogger().warning("Problem removing no push from scoreboard.");
        }
    }
    // Recover superflat
    Settings.recoverSuperFlat = plugin.getConfig().getBoolean("general.recoversuperflat");
    if (Settings.recoverSuperFlat) {
        plugin.getLogger().warning("*********************************************************");
        plugin.getLogger().warning("WARNING: Recover super flat mode is enabled");
        plugin.getLogger().warning("This will regenerate any chunks with bedrock at y=0 when they are loaded");
        plugin.getLogger().warning("Switch off when superflat chunks are cleared");
        plugin.getLogger().warning("You should back up your world before running this");
        plugin.getLogger().warning("*********************************************************");
    }
    // Persistent coops
    Settings.persistantCoops = plugin.getConfig().getBoolean("general.persistentcoops");
    // Only leader can coop
    Settings.onlyLeaderCanCoop = plugin.getConfig().getBoolean("general.onlyleadercancoop", false);
    // Can coop requests be rejected
    Settings.coopIsRequest = plugin.getConfig().getBoolean("general.coopisrequest", true);
    // Fake players
    Settings.allowedFakePlayers = plugin.getConfig().getStringList("general.fakeplayers");
    // Allow Obsidian Scooping
    Settings.allowObsidianScooping = plugin.getConfig().getBoolean("general.allowobsidianscooping", true);
    // Use old display (chat instead of GUI) for Island top ten
    Settings.displayIslandTopTenInChat = plugin.getConfig().getBoolean("general.islandtopteninchat", false);
    // Magic Cobble Generator
    Settings.useMagicCobbleGen = plugin.getConfig().getBoolean("general.usemagiccobblegen", false);
    if (Settings.useMagicCobbleGen) {
        Settings.magicCobbleGenOnlyAtSpawn = plugin.getConfig().getBoolean("general.magiccobblegenonlyatspawn", false);
        if (plugin.getConfig().isSet("general.magiccobblegenchances")) {
            // plugin.getLogger().info("DEBUG: magic cobble gen enabled and chances section found");
            // Clear the cobble gen chances so they can be reloaded
            LavaCheck.clearChances();
            Settings.magicCobbleGenChances = new TreeMap<Long, TreeMap<Double, Material>>();
            for (String level : plugin.getConfig().getConfigurationSection("general.magiccobblegenchances").getKeys(false)) {
                long levelLong = 0;
                try {
                    if (level.equals("default")) {
                        levelLong = Long.MIN_VALUE;
                    } else {
                        levelLong = Long.parseLong(level);
                    }
                    TreeMap<Double, Material> blockMapTree = new TreeMap<Double, Material>();
                    double chanceTotal = 0;
                    for (String block : plugin.getConfig().getConfigurationSection("general.magiccobblegenchances." + level).getKeys(false)) {
                        double chance = plugin.getConfig().getDouble("general.magiccobblegenchances." + level + "." + block, 0D);
                        if (chance > 0 && Material.getMaterial(block) != null && Material.getMaterial(block).isBlock()) {
                            // Store the cumulative chance in the treemap. It does not need to add up to 100%
                            chanceTotal += chance;
                            blockMapTree.put(chanceTotal, Material.getMaterial(block));
                        }
                    }
                    if (!blockMapTree.isEmpty() && chanceTotal > 0) {
                        Settings.magicCobbleGenChances.put(levelLong, blockMapTree);
                        // Store the requested values as a % chance
                        Map<Material, Double> chances = new HashMap<Material, Double>();
                        for (Entry<Double, Material> en : blockMapTree.entrySet()) {
                            double chance = plugin.getConfig().getDouble("general.magiccobblegenchances." + level + "." + en.getValue(), 0D);
                            chances.put(en.getValue(), (chance / chanceTotal) * 100);
                        }
                        LavaCheck.storeChances(levelLong, chances);
                    }
                } catch (NumberFormatException e) {
                    // Putting the catch here means that an invalid level is skipped completely
                    plugin.getLogger().severe("Unknown level '" + level + "' listed in magiccobblegenchances section! Must be an integer or 'default'. Skipping...");
                }
            }
        }
    }
    // Disable offline redstone
    Settings.disableOfflineRedstone = plugin.getConfig().getBoolean("general.disableofflineredstone", false);
    // Allow/disallow TNT pusing
    Settings.allowTNTPushing = plugin.getConfig().getBoolean("general.allowTNTpushing", true);
    // Fancy island level display
    Settings.fancyIslandLevelDisplay = plugin.getConfig().getBoolean("general.fancylevelinchat", false);
    // Check config.yml version
    String configVersion = plugin.getConfig().getString("general.version", "");
    // Ignore last digit if it is 4 digits long
    if (configVersion.split("\\.").length == 4) {
        configVersion = configVersion.substring(0, configVersion.lastIndexOf('.'));
    }
    // Save for plugin version
    String version = plugin.getDescription().getVersion();
    // plugin.getLogger().info("DEBUG: version length " + version.split("\\.").length);
    if (version.split("\\.").length == 4) {
        version = version.substring(0, version.lastIndexOf('.'));
    }
    if (configVersion.isEmpty() || !configVersion.equalsIgnoreCase(version)) {
        // Check to see if this has already been shared
        File newConfig = new File(plugin.getDataFolder(), "config.new.yml");
        plugin.getLogger().warning("***********************************************************");
        plugin.getLogger().warning("Config file is out of date. See config.new.yml for updates!");
        plugin.getLogger().warning("config.yml version is '" + configVersion + "'");
        plugin.getLogger().warning("Latest config version is '" + version + "'");
        plugin.getLogger().warning("***********************************************************");
        if (!newConfig.exists()) {
            File oldConfig = new File(plugin.getDataFolder(), "config.yml");
            File bakConfig = new File(plugin.getDataFolder(), "config.bak");
            if (oldConfig.renameTo(bakConfig)) {
                plugin.saveResource("config.yml", false);
                oldConfig.renameTo(newConfig);
                bakConfig.renameTo(oldConfig);
            }
        }
    }
    // *** Non-Public Settings - these are "secret" settings that may not be used anymore
    // This may be required if head issues grow...
    Settings.warpHeads = plugin.getConfig().getBoolean("general.warpheads", false);
    // Level logging
    Settings.levelLogging = plugin.getConfig().getBoolean("general.levellogging");
    // Custom generator
    Settings.useOwnGenerator = plugin.getConfig().getBoolean("general.useowngenerator", false);
    // Use physics when pasting island block schematics
    Settings.usePhysics = plugin.getConfig().getBoolean("general.usephysics", false);
    // Legacy setting support for hopper limiting
    if (Settings.limitedBlocks.isEmpty()) {
        Settings.hopperLimit = plugin.getConfig().getInt("general.hopperlimit", -1);
        if (Settings.hopperLimit > 0) {
            Settings.limitedBlocks.put("HOPPER", Settings.hopperLimit);
        }
    }
    // No acid bottles or buckets
    Settings.acidBottle = plugin.getConfig().getBoolean("general.acidbottles", true);
    // ************ Protection Settings ****************
    // Default settings hashmaps - make sure this is kept up to date with new settings
    // If a setting is not listed, the world default is used
    Settings.defaultWorldSettings.clear();
    Settings.defaultIslandSettings.clear();
    Settings.defaultSpawnSettings.clear();
    Settings.visitorSettings.clear();
    ConfigurationSection protectionWorld = plugin.getConfig().getConfigurationSection("protection.world");
    for (String setting : protectionWorld.getKeys(false)) {
        try {
            SettingsFlag flag = SettingsFlag.valueOf(setting.toUpperCase());
            boolean value = plugin.getConfig().getBoolean("protection.world." + flag.name());
            Settings.defaultWorldSettings.put(flag, value);
            Settings.defaultSpawnSettings.put(flag, value);
            Settings.defaultIslandSettings.put(flag, value);
        } catch (Exception e) {
            plugin.getLogger().severe("Unknown setting in config.yml:protection.world " + setting.toUpperCase() + " skipping...");
        }
    }
    // Establish defaults if they are missing in the config file.
    for (SettingsFlag flag : SettingsFlag.values()) {
        if (!Settings.defaultWorldSettings.containsKey(flag)) {
            plugin.getLogger().warning("config.yml:protection.world." + flag.name() + " is missing. You should add it to the config file. Setting to false by default");
            Settings.defaultWorldSettings.put(flag, false);
        }
        if (!Settings.defaultIslandSettings.containsKey(flag)) {
            Settings.defaultIslandSettings.put(flag, false);
        }
        if (!Settings.defaultSpawnSettings.containsKey(flag)) {
            Settings.defaultSpawnSettings.put(flag, false);
        }
    }
    ConfigurationSection protectionIsland = plugin.getConfig().getConfigurationSection("protection.island");
    for (String setting : protectionIsland.getKeys(false)) {
        try {
            SettingsFlag flag = SettingsFlag.valueOf(setting.toUpperCase());
            // Only items in the config.yml can be per island customized
            Settings.visitorSettings.put(flag, protectionIsland.getBoolean(setting));
            // plugin.getLogger().info("DEBUG: visitor flag added " + flag);
            Settings.defaultIslandSettings.put(flag, Settings.visitorSettings.get(flag));
        } catch (Exception e) {
            plugin.getLogger().severe("Unknown setting in config.yml:island.world " + setting.toUpperCase() + " skipping...");
        }
    }
    // ******************** Biome Settings *********************
    Settings.biomeCost = plugin.getConfig().getDouble("biomesettings.defaultcost", 100D);
    if (Settings.biomeCost < 0D) {
        Settings.biomeCost = 0D;
        plugin.getLogger().warning("Biome default cost is < $0, so set to zero.");
    }
    String defaultBiome = plugin.getConfig().getString("biomesettings.defaultbiome", "PLAINS");
    try {
        Settings.defaultBiome = Biome.valueOf(defaultBiome);
    } catch (Exception e) {
        plugin.getLogger().severe("Could not parse biome " + defaultBiome + " using PLAINS instead.");
        Settings.defaultBiome = Biome.PLAINS;
    }
    // ******************** Schematic Section *******************
    // Hack skeleton spawners for 1.11
    Settings.hackSkeletonSpawners = plugin.getConfig().getBoolean("schematicsection.hackskeletonspawners", true);
    // ****************** Levels blockvalues.yml ****************
    // Get the blockvalues.yml file
    YamlConfiguration blockValuesConfig = Util.loadYamlFile("blockvalues.yml");
    // Get the under water multiplier
    Settings.deathpenalty = blockValuesConfig.getInt("deathpenalty", 0);
    Settings.sumTeamDeaths = blockValuesConfig.getBoolean("sumteamdeaths");
    Settings.maxDeaths = blockValuesConfig.getInt("maxdeaths", 10);
    Settings.islandResetDeathReset = blockValuesConfig.getBoolean("islandresetdeathreset", true);
    Settings.teamJoinDeathReset = blockValuesConfig.getBoolean("teamjoindeathreset", true);
    Settings.underWaterMultiplier = blockValuesConfig.getDouble("underwater", 1D);
    Settings.levelCost = blockValuesConfig.getInt("levelcost", 100);
    if (Settings.levelCost < 1) {
        Settings.levelCost = 1;
        plugin.getLogger().warning("levelcost in blockvalues.yml cannot be less than 1. Setting to 1.");
    }
    Settings.blockLimits = new HashMap<MaterialData, Integer>();
    if (blockValuesConfig.isSet("limits")) {
        for (String material : blockValuesConfig.getConfigurationSection("limits").getKeys(false)) {
            try {
                String[] split = material.split(":");
                byte data = 0;
                if (split.length > 1) {
                    data = Byte.valueOf(split[1]);
                }
                Material mat;
                if (StringUtils.isNumeric(split[0])) {
                    mat = Material.getMaterial(Integer.parseInt(split[0]));
                } else {
                    mat = Material.valueOf(split[0].toUpperCase());
                }
                MaterialData materialData = new MaterialData(mat);
                materialData.setData(data);
                Settings.blockLimits.put(materialData, blockValuesConfig.getInt("limits." + material, 0));
                if (DEBUG) {
                    plugin.getLogger().info("Maximum number of " + materialData + " will be " + Settings.blockLimits.get(materialData));
                }
            } catch (Exception e) {
                plugin.getLogger().warning("Unknown material (" + material + ") in blockvalues.yml Limits section. Skipping...");
            }
        }
    }
    Settings.blockValues = new HashMap<MaterialData, Integer>();
    if (blockValuesConfig.isSet("blocks")) {
        for (String material : blockValuesConfig.getConfigurationSection("blocks").getKeys(false)) {
            try {
                String[] split = material.split(":");
                byte data = 0;
                if (split.length > 1) {
                    data = Byte.valueOf(split[1]);
                }
                MaterialData materialData = null;
                if (StringUtils.isNumeric(split[0])) {
                    materialData = new MaterialData(Integer.parseInt(split[0]));
                } else {
                    materialData = new MaterialData(Material.valueOf(split[0].toUpperCase()));
                }
                materialData.setData(data);
                Settings.blockValues.put(materialData, blockValuesConfig.getInt("blocks." + material, 0));
                if (DEBUG) {
                    plugin.getLogger().info(materialData.toString() + " value " + Settings.blockValues.get(materialData));
                }
            } catch (Exception e) {
                // e.printStackTrace();
                plugin.getLogger().warning("Unknown material (" + material + ") in blockvalues.yml blocks section. Skipping...");
            }
        }
    } else {
        plugin.getLogger().severe("No block values in blockvalues.yml! All island levels will be zero!");
    }
    // All done
    return true;
}
Also used : HashMap(java.util.HashMap) YamlConfiguration(org.bukkit.configuration.file.YamlConfiguration) SettingsFlag(com.wasteofplastic.acidisland.Island.SettingsFlag) Scoreboard(org.bukkit.scoreboard.Scoreboard) ScoreboardManager(org.bukkit.scoreboard.ScoreboardManager) Team(org.bukkit.scoreboard.Team) PotionEffectType(org.bukkit.potion.PotionEffectType) SpawnEgg1_9(com.wasteofplastic.acidisland.util.SpawnEgg1_9) Material(org.bukkit.Material) SpawnEgg(org.bukkit.material.SpawnEgg) IOException(java.io.IOException) TreeMap(java.util.TreeMap) IOException(java.io.IOException) EntityType(org.bukkit.entity.EntityType) PotionType(org.bukkit.potion.PotionType) DamageCause(org.bukkit.event.entity.EntityDamageEvent.DamageCause) MaterialData(org.bukkit.material.MaterialData) ItemStack(org.bukkit.inventory.ItemStack) File(java.io.File) ConfigurationSection(org.bukkit.configuration.ConfigurationSection)

Example 19 with Scoreboard

use of org.bukkit.scoreboard.Scoreboard in project Denizen-For-Bukkit by DenizenScript.

the class CustomEntityHelper_v1_9_R2 method spawnFakePlayer.

@Override
public FakePlayer spawnFakePlayer(Location location, String name, String skin) throws IllegalArgumentException {
    String fullName = name;
    String prefix = null;
    String suffix = null;
    if (name == null) {
        return null;
    } else if (fullName.length() > 16) {
        prefix = fullName.substring(0, 16);
        if (fullName.length() > 30) {
            int len = 30;
            name = fullName.substring(16, 30);
            if (name.matches(".*[^A-Za-z0-9_].*")) {
                if (fullName.length() >= 32) {
                    len = 32;
                    name = fullName.substring(16, 32);
                } else if (fullName.length() == 31) {
                    len = 31;
                    name = fullName.substring(16, 31);
                }
            } else if (name.length() > 46) {
                throw new IllegalArgumentException("You must specify a name with no more than 46 characters for FAKE_PLAYER entities!");
            } else {
                name = ChatColor.RESET + name;
            }
            suffix = fullName.substring(len);
        } else {
            name = fullName.substring(16);
            if (!name.matches(".*[^A-Za-z0-9_].*")) {
                name = ChatColor.RESET + name;
            }
            if (name.length() > 16) {
                suffix = name.substring(16);
                name = name.substring(0, 16);
            }
        }
    }
    if (skin != null && skin.length() > 16) {
        throw new IllegalArgumentException("You must specify a name with no more than 16 characters for FAKE_PLAYER entity skins!");
    }
    CraftWorld world = (CraftWorld) location.getWorld();
    WorldServer worldServer = world.getHandle();
    PlayerProfile playerProfile = new PlayerProfile(name, null);
    if (skin == null && !name.matches(".*[^A-Za-z0-9_].*")) {
        playerProfile = NMSHandler.getInstance().fillPlayerProfile(playerProfile);
    }
    if (skin != null) {
        PlayerProfile skinProfile = new PlayerProfile(skin, null);
        skinProfile = NMSHandler.getInstance().fillPlayerProfile(skinProfile);
        playerProfile.setTexture(skinProfile.getTexture());
        playerProfile.setTextureSignature(skinProfile.getTextureSignature());
    }
    UUID uuid = UUID.randomUUID();
    if (uuid.version() == 4) {
        long msb = uuid.getMostSignificantBits();
        msb &= ~0x0000000000004000L;
        msb |= 0x0000000000002000L;
        uuid = new UUID(msb, uuid.getLeastSignificantBits());
    }
    playerProfile.setUniqueId(uuid);
    GameProfile gameProfile = new GameProfile(playerProfile.getUniqueId(), playerProfile.getName());
    gameProfile.getProperties().put("textures", new Property("textures", playerProfile.getTexture(), playerProfile.getTextureSignature()));
    final EntityFakePlayer_v1_9_R2 fakePlayer = new EntityFakePlayer_v1_9_R2(worldServer.getMinecraftServer(), worldServer, gameProfile, new PlayerInteractManager(worldServer));
    fakePlayer.setPositionRotation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
    CraftFakePlayer_v1_9_R2 craftFakePlayer = fakePlayer.getBukkitEntity();
    craftFakePlayer.fullName = fullName;
    if (prefix != null) {
        Scoreboard scoreboard = Bukkit.getScoreboardManager().getMainScoreboard();
        String teamName = "FAKE_PLAYER_TEAM_" + fullName;
        String hash = null;
        try {
            MessageDigest md = MessageDigest.getInstance("MD5");
            byte[] bytes = teamName.getBytes("UTF-8");
            md.update(bytes, 0, bytes.length);
            hash = new BigInteger(1, md.digest()).toString(16).substring(0, 16);
        } catch (Exception e) {
            e.printStackTrace();
        }
        if (hash != null) {
            Team team = scoreboard.getTeam(hash);
            if (team == null) {
                team = scoreboard.registerNewTeam(hash);
                team.setPrefix(prefix);
                if (suffix != null) {
                    team.setSuffix(suffix);
                }
            }
            team.addPlayer(craftFakePlayer);
        }
    }
    return craftFakePlayer;
}
Also used : PlayerProfile(net.aufdemrand.denizen.nms.util.PlayerProfile) WorldServer(net.minecraft.server.v1_9_R2.WorldServer) CraftFakePlayer_v1_9_R2(net.aufdemrand.denizen.nms.impl.entities.CraftFakePlayer_v1_9_R2) EntityFakePlayer_v1_9_R2(net.aufdemrand.denizen.nms.impl.entities.EntityFakePlayer_v1_9_R2) GameProfile(com.mojang.authlib.GameProfile) Scoreboard(org.bukkit.scoreboard.Scoreboard) PlayerInteractManager(net.minecraft.server.v1_9_R2.PlayerInteractManager) BigInteger(java.math.BigInteger) Team(org.bukkit.scoreboard.Team) UUID(java.util.UUID) MessageDigest(java.security.MessageDigest) CraftWorld(org.bukkit.craftbukkit.v1_9_R2.CraftWorld) Property(com.mojang.authlib.properties.Property)

Example 20 with Scoreboard

use of org.bukkit.scoreboard.Scoreboard in project Denizen-For-Bukkit by DenizenScript.

the class ScoreboardCommand method execute.

@SuppressWarnings("unchecked")
@Override
public void execute(final ScriptEntry scriptEntry) throws CommandExecutionException {
    // Get objects
    List<dPlayer> viewers = (List<dPlayer>) scriptEntry.getObject("viewers");
    dList lines = scriptEntry.hasObject("lines") ? dList.valueOf(scriptEntry.getElement("lines").asString()) : new dList();
    Element action = scriptEntry.getElement("action");
    Element id = scriptEntry.getElement("id");
    Element objective = scriptEntry.getElement("objective");
    Element criteria = scriptEntry.getElement("criteria");
    Element score = scriptEntry.getElement("score");
    Element displaySlot = scriptEntry.getElement("displayslot");
    Action act = Action.valueOf(action.asString().toUpperCase());
    // Report to dB
    dB.report(scriptEntry, getName(), action.debug() + id.debug() + (viewers != null ? aH.debugObj("viewers", viewers.toString()) : "") + (objective != null ? objective.debug() : "") + (act.equals(Action.ADD) && objective != null ? criteria.debug() : "") + (!lines.isEmpty() ? lines.debug() : "") + (act.equals(Action.ADD) && score != null ? score.debug() : "") + (act.equals(Action.ADD) && objective != null ? displaySlot.debug() : ""));
    Scoreboard board = null;
    // Get the main scoreboard by default
    if (id.asString().equalsIgnoreCase("main")) {
        board = ScoreboardHelper.getMain();
    } else {
        // If this scoreboard already exists, get it
        if (ScoreboardHelper.hasScoreboard(id.asString())) {
            board = ScoreboardHelper.getScoreboard(id.asString());
        } else // Else, create a new one if Action is ADD
        if (act.equals(Action.ADD)) {
            board = ScoreboardHelper.createScoreboard(id.asString());
        }
    }
    // Don't progress if we ended up with a null board
    if (board == null) {
        dB.echoError(scriptEntry.getResidingQueue(), "Scoreboard " + id.asString() + " does not exist!");
        return;
    }
    Objective obj = null;
    if (act.equals(Action.ADD)) {
        if (objective != null) {
            // Try getting the objective from the board
            obj = board.getObjective(objective.asString());
            // Create the objective if it does not already exist
            if (obj == null) {
                obj = board.registerNewObjective(objective.asString(), criteria.asString());
            } else // recreate the objective
            if (criteria != null && !obj.getCriteria().equals(criteria.asString())) {
                obj.unregister();
                obj = board.registerNewObjective(objective.asString(), criteria.asString());
            }
            // Change the objective's display slot
            if (!displaySlot.asString().equalsIgnoreCase("none")) {
                obj.setDisplaySlot(DisplaySlot.valueOf(displaySlot.asString().toUpperCase()));
            }
            obj.setDisplayName(objective.asString());
            if (!lines.isEmpty()) {
                // use a score of 0
                if (score == null) {
                    score = new Element(0);
                }
                // for clarifications
                for (String line : lines) {
                    line = line.replaceAll("[pP]@", "");
                    if (line.length() > 48) {
                        line = line.substring(0, 48);
                    }
                    ScoreboardHelper.addScore(obj, getOfflinePlayer(line), score.asInt());
                }
            }
        } else // the command cannot do anything at all, so print a message about that
        if (viewers == null && !lines.isEmpty()) {
            dB.echoDebug(scriptEntry, "Cannot add lines without specifying an objective!");
        }
    } else if (act.equals(Action.REMOVE)) {
        if (objective != null) {
            // Try getting the objective from the board
            obj = board.getObjective(objective.asString());
            if (obj != null) {
                // Remove the entire objective if no lines have been specified
                if (lines.isEmpty()) {
                    dB.echoDebug(scriptEntry, "Removing objective " + obj.getName() + " from scoreboard " + id.asString());
                    obj.unregister();
                } else {
                    for (String line : lines) {
                        line = line.replaceAll("[pP]@", "");
                        ScoreboardHelper.removeScore(obj, getOfflinePlayer(line));
                    }
                }
            } else {
                dB.echoError(scriptEntry.getResidingQueue(), "Objective " + objective.asString() + " does not exist in scoreboard " + id.asString());
            }
        } else // lines from every objective
        if (!lines.isEmpty()) {
            dB.echoDebug(scriptEntry, "Removing lines " + lines.identify() + " from all objectives in scoreboard " + id.asString());
            for (String line : lines) {
                line = line.replaceAll("[pP]@", "");
                ScoreboardHelper.removePlayer(id.asString(), getOfflinePlayer(line));
            }
        } else // of viewers should be removed instead)
        if (viewers == null) {
            dB.echoDebug(scriptEntry, "Removing scoreboard " + id.asString());
            ScoreboardHelper.deleteScoreboard(id.asString());
        }
    }
    if (viewers != null) {
        for (dPlayer viewer : viewers) {
            // Add viewers for this scoreboard
            if (act.equals(Action.ADD)) {
                // to the map of viewers saved by Denizen
                if (!id.asString().equalsIgnoreCase("main")) {
                    ScoreboardHelper.viewerMap.put(viewer.getName(), id.asString());
                }
                // is already online
                if (viewer.isOnline()) {
                    viewer.getPlayerEntity().setScoreboard(board);
                }
            } else // Remove viewers for this scoreboard
            if (act.equals(Action.REMOVE)) {
                // Take this player out of the map of viewers
                ScoreboardHelper.viewerMap.remove(viewer.getName());
                // provided by Bukkit)
                if (viewer.isOnline()) {
                    viewer.getPlayerEntity().setScoreboard(ScoreboardHelper.createScoreboard());
                }
            }
        }
    }
}
Also used : Objective(org.bukkit.scoreboard.Objective) Scoreboard(org.bukkit.scoreboard.Scoreboard) net.aufdemrand.denizen.objects.dPlayer(net.aufdemrand.denizen.objects.dPlayer) net.aufdemrand.denizencore.objects.dList(net.aufdemrand.denizencore.objects.dList) Element(net.aufdemrand.denizencore.objects.Element) List(java.util.List) net.aufdemrand.denizencore.objects.dList(net.aufdemrand.denizencore.objects.dList)

Aggregations

Scoreboard (org.bukkit.scoreboard.Scoreboard)39 Team (org.bukkit.scoreboard.Team)24 GameProfile (com.mojang.authlib.GameProfile)11 UUID (java.util.UUID)11 Objective (org.bukkit.scoreboard.Objective)11 Property (com.mojang.authlib.properties.Property)7 BigInteger (java.math.BigInteger)7 MessageDigest (java.security.MessageDigest)7 Player (org.bukkit.entity.Player)7 PlayerProfile (net.aufdemrand.denizen.nms.util.PlayerProfile)4 PlayerProfile (com.denizenscript.denizen.nms.util.PlayerProfile)3 File (java.io.File)3 Skin (net.citizensnpcs.npc.skin.Skin)3 User (net.dzikoysk.funnyguilds.basic.User)3 YamlConfiguration (org.bukkit.configuration.file.YamlConfiguration)3 EntityType (org.bukkit.entity.EntityType)3 PotionEffectType (org.bukkit.potion.PotionEffectType)3 PotionType (org.bukkit.potion.PotionType)3 Score (org.bukkit.scoreboard.Score)3 PlayerTag (com.denizenscript.denizen.objects.PlayerTag)2