Package org.bukkit.configuration

Examples of org.bukkit.configuration.ConfigurationSection


     * must contain a list of at least one "monster: number" node.
     * @param config
     * @return a "reverse" map of monsters and numbers
     */
    private static SortedMap<Integer,MACreature> getMonsterMap(ConfigurationSection config) {
        ConfigurationSection section = config.getConfigurationSection("monsters");
        if (section == null) {
            return null;
        }

        Set<String> monsters = section.getKeys(false);
        if (monsters == null || monsters.isEmpty()) {
            return null;
        }
       
        // Prepare the map.
View Full Code Here


       
        return result;
    }
   
    private static Map<String,List<Upgrade>> getUpgradeMap(ConfigurationSection config) {
        ConfigurationSection section = config.getConfigurationSection("upgrades");
        if (section == null) {
            return null;
        }

        Set<String> classes = section.getKeys(false);
        if (classes == null || classes.isEmpty()) {
            return null;
        }
       
        Map<String,List<Upgrade>> upgrades = new HashMap<String,List<Upgrade>>();
        String path = "upgrades.";
       
        for (String className : classes) {
            String itemList;
            // Legacy support
            Object val = config.get(path + className, null);
            if (val instanceof String) {
                itemList = (String) val;
                List<ItemStack> stacks = ItemParser.parseItems(itemList);
                List<Upgrade> list = new ArrayList<Upgrade>();
                for (ItemStack stack : stacks) {
                    list.add(new GenericUpgrade(stack));
                }
                upgrades.put(className.toLowerCase(), list);
            }
            // New complex setup
            else if (val instanceof ConfigurationSection) {
                ConfigurationSection classSection = (ConfigurationSection) val;
                List<Upgrade> list = new ArrayList<Upgrade>();

                // Items (Generic + Weapons)
                itemList = classSection.getString("items", null);
                if (itemList != null) {
                    for (ItemStack stack : ItemParser.parseItems(itemList)) {
                        list.add(ArenaClass.isWeapon(stack) ? new WeaponUpgrade(stack) : new GenericUpgrade(stack));
                    }
                }

                // Armor
                itemList = classSection.getString("armor", null);
                if (itemList != null) {
                    for (ItemStack stack : ItemParser.parseItems(itemList)) {
                        list.add(new ArmorUpgrade(stack));
                    }
                }

                // Permissions
                List<String> perms = classSection.getStringList("permissions");
                if (!perms.isEmpty()) {
                    for (String perm : perms) {
                        list.add(new PermissionUpgrade(perm));
                    }
                }
View Full Code Here

        if (plugin.getDebug())
          plugin.log.warning(e.getMessage());
      }
    }
    for (String name : fc.getKeys(false)) {
      ConfigurationSection cs = fc.getConfigurationSection(name);
      Material mat = Material.matchMaterial(cs.getString("Material"));
      ChatColor color = ChatColor.valueOf(cs.getString("Color")
          .toUpperCase());
      List<String> lore = cs.getStringList("Lore");
      ItemStack tool = new ItemStack(mat);
      List<String> list = new ArrayList<String>();
      for (String s : lore) {
        list.add(ChatColor.translateAlternateColorCodes(
            "&".toCharArray()[0], s));
      }
      ConfigurationSection cs1 = cs
          .getConfigurationSection("Enchantments");
      if (cs1 != null) {
        for (String ench : cs1.getKeys(false)) {
          Enchantment encha = Enchantment.getByName(ench
              .toUpperCase());
          if (encha == null)
            continue;
          tool.addUnsafeEnchantment(encha, cs1.getInt(ench));
        }
      }
      ItemMeta meta = tool.getItemMeta();
      meta.setDisplayName(color + name);
      meta.setLore(list);
View Full Code Here

    /**
     * Returns a list of flag names currently attached to an NPC.
     */
    public Set<String> listNPCFlags(int npcid) {
        ConfigurationSection section = denizen.getSaves().getConfigurationSection("NPCs." + npcid + ".Flags");
        return section != null ? section.getValues(true).keySet() : null;
    }
View Full Code Here

    /**
     * Returns a list of flag names currently attached to the server.
     */
    public Set<String> listGlobalFlags() {
        ConfigurationSection section = denizen.getSaves().getConfigurationSection("Global.Flags");
        return section != null ? section.getValues(true).keySet() : null;
    }
View Full Code Here

    /**
     * Returns a list of flag names currently attached to a player.
     */
    public Set<String> listPlayerFlags(dPlayer player) {
        ConfigurationSection section = denizen.getSaves().getConfigurationSection("Players." + player.getSaveName() + ".Flags");
        return section!= null ? section.getValues(true).keySet() : null;
    }
View Full Code Here

        if (savesConfig.contains("a_saves.version"))
            saves_version = savesConfig.getInt("a_saves.version");

        if (saves_version == 1) {
            dB.log("Updating saves from v1 to v2...");
            ConfigurationSection section = savesConfig.getConfigurationSection("Players");
            if (section != null) {
                ArrayList<String> keyList = new ArrayList<String>(section.getKeys(false));
                // Remove UPPERCASE cooldown saves from the list - handled manually
                for (int i = 0; i < keyList.size(); i++) {
                    String key = keyList.get(i);
                    if (!key.equals(key.toUpperCase()) && keyList.contains(key.toUpperCase())) {
                        keyList.remove(key.toUpperCase());
                    }
                }
                // Handle all actual player saves
                for (int i = 0; i < keyList.size(); i++) {
                    String key = keyList.get(i);
                    try {
                        // Flags
                        ConfigurationSection playerSection = savesConfig.getConfigurationSection("Players." + key);
                        if (playerSection == null) {
                            dB.echoError("Can't update saves for player '" + key + "' - broken YAML section!");
                            continue;
                        }
                        Map<String, Object> keys = playerSection.getValues(true);
                        if (!key.equals(key.toUpperCase()) && savesConfig.contains("Players." + key.toUpperCase())) {
                            // Cooldowns
                            keys.putAll(savesConfig.getConfigurationSection("Players." + key.toUpperCase()).getValues(true));
                            savesConfig.set("Players." + key.toUpperCase(), null);
                        }
View Full Code Here

              LogUtil.logWarning("[NoCheatPlus] Bad damage cause (combined.invulnerable.ignore): " + input);
          }
      }
      // Read modifiers for causes.
      Integer defaultMod = 0;
      final ConfigurationSection sec = config.getConfigurationSection(ConfPaths.COMBINED_INVULNERABLE_MODIFIERS);
        for (final String input : sec.getKeys(false)){
            final int modifier = sec.getInt(input, 0);
            final String normInput = input.trim().toUpperCase();
            if (normInput.equals("ALL")){
                defaultMod = modifier;
                continue;
            }
View Full Code Here

              setBlockProps(id, instantType);
            }
        }
       
        // Override block flags.
        ConfigurationSection section = config.getConfigurationSection(pathPrefix + ConfPaths.SUB_OVERRIDEFLAGS);
        if (section != null){
          final Map<String, Object> entries = section.getValues(false);
          boolean hasErrors = false;
          for (final Entry<String, Object> entry : entries.entrySet()){
            final String key = entry.getKey();
            final Integer id = RawConfigFile.parseTypeId(key);
                if (id == null || id < 0 || id >= 4096){
View Full Code Here

    // Is this a compound?
    if (node instanceof ConfigurationSection) {
      // Is this a list of a map?
      if (type != NbtType.TAG_END) {
        NbtList<Object> list = NbtFactory.ofList(decoded[0]);
        ConfigurationSection section = (ConfigurationSection) node;
        List<String> sorted = sortSet(section.getKeys(false));
       
        // Read everything in order
        for (String key : sorted) {
          NbtBase<Object> base = (NbtBase<Object>) readNode(section, key.toString());
          base.setName(NbtList.EMPTY_NAME);
          list.getValue().add(base);
        }
        return (NbtWrapper<?>) list;
     
      } else {
        NbtCompound compound = NbtFactory.ofCompound(decoded[0]);
        ConfigurationSection section = (ConfigurationSection) node;
       
        // As above
        for (String key : section.getKeys(false))
          compound.put(readNode(section, key));
        return (NbtWrapper<?>) compound;
      }
     
    } else {
View Full Code Here

TOP

Related Classes of org.bukkit.configuration.ConfigurationSection

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.