Java Code Examples for org.bukkit.configuration.ConfigurationSection#isConfigurationSection()
The following examples show how to use
org.bukkit.configuration.ConfigurationSection#isConfigurationSection() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Shop.java From AnnihilationPro with MIT License | 6 votes |
public Shop(XPSystem system, ConfigurationSection shopSection) { menus = new HashMap<UUID,ItemMenu>(); purchasedMessage = getString(shopSection,"Already-Purchased-Kit"); forsaleMessage = getString(shopSection,"Not-Yet-Purchased-Kit"); confirmMessage = getString(shopSection,"Confirm-Purchase-Kit"); confirmExpired = getString(shopSection,"Confirmation-Expired"); notEnoughXP = getString(shopSection,"Not-Enough-XP"); kitPurchased = getString(shopSection,"Kit-Purchased"); noKitsToPurchase = getString(shopSection,"No-Kits-To-Purchase"); if(!shopSection.isConfigurationSection("Kits")) shopSection.createSection("Kits"); ConfigurationSection kitSec = shopSection.getConfigurationSection("Kits"); Collection<Kit> kits = Kit.getKits(); items = new KitShopMenuItem[kits.size()]; int c =0; for(Kit k : kits) { ConfigManager.setDefaultIfNotSet(kitSec, k.getName(), 10000); KitShopMenuItem item = new KitShopMenuItem(new KitWrapper(k,kitSec.getInt(k.getName())),system); items[c] = item; c++; } }
Example 2
Source File: AdminShopkeeper.java From Shopkeepers with GNU General Public License v3.0 | 6 votes |
private List<ItemStack[]> loadRecipesOld(ConfigurationSection config, String node) { List<ItemStack[]> recipes = new ArrayList<ItemStack[]>(); ConfigurationSection recipesSection = config.getConfigurationSection(node); if (recipesSection != null) { for (String key : recipesSection.getKeys(false)) { ConfigurationSection recipeSection = recipesSection.getConfigurationSection(key); ItemStack[] recipe = new ItemStack[3]; for (int slot = 0; slot < 3; slot++) { if (recipeSection.isConfigurationSection(String.valueOf(slot))) { recipe[slot] = Utils.getNullIfEmpty(this.loadItemStackOld(recipeSection.getConfigurationSection(String.valueOf(slot)))); } } if (recipe[0] == null || recipe[2] == null) continue; // invalid recipe recipes.add(recipe); } } return recipes; }
Example 3
Source File: Transforms.java From EffectLib with MIT License | 6 votes |
public static Transform loadTransform(ConfigurationSection base, String value) { if (base.isConfigurationSection(value)) { return loadTransform(ConfigUtils.getConfigurationSection(base, value)); } if (base.isDouble(value) || base.isInt(value)) { return new ConstantTransform(base.getDouble(value)); } if (base.isString(value)) { String equation = base.getString(value); if (equation.equalsIgnoreCase("t") || equation.equalsIgnoreCase("time")) { return new EchoTransform(); } EquationTransform transform = EquationStore.getInstance().getTransform(equation, "t"); Exception ex = transform.getException(); if (ex != null && effectManager != null) { effectManager.onError("Error parsing equation: " + equation, ex); } return transform; } return new ConstantTransform(0); }
Example 4
Source File: PerkLogic.java From uSkyBlock with GNU General Public License v3.0 | 6 votes |
private void addPartyPermissionPerks(String perm, ConfigurationSection config) { int[] values = {5, 6, 7, 8}; String[] perms = {"usb.extra.partysize1","usb.extra.partysize2","usb.extra.partysize3","usb.extra.partysize"}; for (int i = 0; i < values.length; i++) { donorPerks.put(perms[i], new PerkBuilder(donorPerks.get(perms[i])) .maxPartySize(values[i]) .build()); } if (config == null) { return; } for (String key : config.getKeys(false)) { if (config.isConfigurationSection(key)) { addPartyPermissionPerks((perm != null ? perm + "." : "") + key, config.getConfigurationSection(key)); } else if (config.isInt(key)) { // Read leaf donorPerks.put(perm, new PerkBuilder(donorPerks.get(perm)) .maxPartySize(config.getInt(key, 0)) .build()); } } }
Example 5
Source File: PerkLogic.java From uSkyBlock with GNU General Public License v3.0 | 6 votes |
private void addDonorPerks(String perm, ConfigurationSection config) { if (config == null) { return; } for (String key : config.getKeys(false)) { if (config.isConfigurationSection(key)) { addDonorPerks((perm != null ? perm + "." : "") + key, config.getConfigurationSection(key)); } else { // Read leaf donorPerks.put(perm, new Perk( ItemStackUtil.createItemList(config.getStringList("extraItems")), config.getInt("maxPartySize", defaultPerk.getMaxPartySize()), config.getInt("animals", defaultPerk.getAnimals()), config.getInt("monsters", defaultPerk.getMonsters()), config.getInt("villagers", defaultPerk.getVillagers()), config.getInt("golems", defaultPerk.getGolems()), config.getDouble("rewardBonus", defaultPerk.getRewBonus()), config.getDouble("hungerReduction", defaultPerk.getHungerReduction()), config.getStringList("schematics"), null)); } } }
Example 6
Source File: LevelConfigYmlReader.java From uSkyBlock with GNU General Public License v3.0 | 6 votes |
public BlockLevelConfigMap readLevelConfig(FileConfiguration config) { double defaultScore = config.getDouble("general.default", 10d); int defaultLimit = config.getInt("general.limit", Integer.MAX_VALUE); int defaultDiminishingReturns = config.getInt("general.diminishingReturns", 0); BlockLevelConfigBuilder defaultBuilder = new BlockLevelConfigBuilder() .scorePerBlock(defaultScore) .limit(defaultLimit) .diminishingReturns(defaultDiminishingReturns); List<BlockLevelConfig> blocks = new ArrayList<>(); addDefaults(blocks, defaultBuilder); ConfigurationSection section = config.getConfigurationSection("blocks"); if (section != null) { for (String key : section.getKeys(false)) { if (section.isConfigurationSection(key)) { BlockLevelConfig blockConfig = readBlockSection(section.getConfigurationSection(key), getBlockMatch(key), defaultBuilder); blocks.add(blockConfig); } } } return new BlockLevelConfigMap(blocks, defaultBuilder); }
Example 7
Source File: EnchantSrcConfig.java From NyaaUtils with MIT License | 6 votes |
@Override public void deserialize(ConfigurationSection config) { ISerializable.deserialize(config, this); enchantSrc = new ArrayList<>(); if (config.isConfigurationSection("enchantSrc")) { ConfigurationSection src = config.getConfigurationSection("enchantSrc"); for (String key : src.getKeys(false)) { if (src.isConfigurationSection(key)) { BasicItemMatcher tmp = new BasicItemMatcher(); tmp.deserialize(src.getConfigurationSection(key)); enchantSrc.add(tmp); } } } }
Example 8
Source File: RepairConfig.java From NyaaUtils with MIT License | 6 votes |
@Override public void deserialize(ConfigurationSection config) { repairMap.clear(); for (String key : config.getKeys(false)) { Material m; try { m = Material.valueOf(key); } catch (IllegalArgumentException ex) { continue; } if (!config.isConfigurationSection(key)) continue; RepairConfigItem item = new RepairConfigItem(); item.deserialize(config.getConfigurationSection(key)); repairMap.put(m, item.normalize()); } }
Example 9
Source File: GlobalLoreBlacklist.java From NyaaUtils with MIT License | 6 votes |
@Override public void deserialize(ConfigurationSection config) { aclMap.clear(); // load default values if (config.isConfigurationSection("default")) { this.default_enchant = config.getBoolean("default.enchant", default_enchant); this.default_repair = config.getBoolean("default.repair", default_repair); } // load all lores for (String key : config.getKeys(false)) { if (!key.equals("default") && config.isConfigurationSection(key)) { Flags flags = new Flags(); flags.deserialize(config.getConfigurationSection(key)); aclMap.put(key, flags); } } }
Example 10
Source File: TimerConfig.java From NyaaUtils with MIT License | 5 votes |
@Override public void deserialize(ConfigurationSection config) { timers.clear(); ISerializable.deserialize(config, this); if (config.isConfigurationSection("timers")) { ConfigurationSection list = config.getConfigurationSection("timers"); for (String k : list.getKeys(false)) { Timer timer = new Timer(); timer.deserialize(list.getConfigurationSection(k)); timers.put(timer.getName(), timer.clone()); } } }
Example 11
Source File: Timer.java From NyaaUtils with MIT License | 5 votes |
@Override public void deserialize(ConfigurationSection config) { ISerializable.deserialize(config, this); if (config.isConfigurationSection("checkpoint")) { ConfigurationSection list = config.getConfigurationSection("checkpoint"); for (String k : list.getKeys(false)) { Checkpoint checkpoint = new Checkpoint(); checkpoint.deserialize(list.getConfigurationSection(String.valueOf(k))); checkpoint.setTimerName(getName()); checkpoint.setCheckpointID(Integer.valueOf(k)); checkpointList.add(checkpoint.clone()); } } }
Example 12
Source File: WorldResourcepacks.java From ResourcepacksPlugins with GNU General Public License v3.0 | 5 votes |
private Map<String, Object> getValues(ConfigurationSection config) { Map<String, Object> map = new LinkedHashMap<>(); for (String key : config.getKeys(false)) { if (config.get(key, null) != null) { if (config.isConfigurationSection(key)) { map.put(key, getValues(config.getConfigurationSection(key))); } else { map.put(key, config.get(key)); } } } return map; }
Example 13
Source File: IslandInfo.java From uSkyBlock with GNU General Public License v3.0 | 5 votes |
@Override @NotNull public Map<Material, Integer> getBlockLimits() { Map<Material, Integer> blockLimitMap = new HashMap<>(); ConfigurationSection membersSection = config.getConfigurationSection("party.members"); if (membersSection != null) { for (String memberName : membersSection.getKeys(false)) { ConfigurationSection memberSection = membersSection.getConfigurationSection(memberName); if (memberSection != null) { if (memberSection.isConfigurationSection("blockLimits")) { ConfigurationSection blockLimits = memberSection.getConfigurationSection("blockLimits"); for (String material : blockLimits.getKeys(false)) { Material type = Material.matchMaterial(material); if (type != null) { blockLimitMap.computeIfAbsent(type, (k) -> { int memberMax = blockLimits.getInt(material, 0); return blockLimitMap.compute(type, (key, oldValue) -> oldValue != null && memberMax > 0 ? Math.max(memberMax, oldValue) : null); }); } } } } } } return blockLimitMap; }
Example 14
Source File: ParticleSet.java From NyaaUtils with MIT License | 5 votes |
@Override public void deserialize(ConfigurationSection config) { contents.clear(); ISerializable.deserialize(config, this); if (config.isConfigurationSection("contents")) { ConfigurationSection list = config.getConfigurationSection("contents"); for (String index : list.getKeys(false)) { ParticleData p = new ParticleData(); p.deserialize(list.getConfigurationSection(index)); contents.add(p); } } }
Example 15
Source File: LobbyMap.java From AnnihilationPro with MIT License | 5 votes |
@Override protected void loadFromConfig(ConfigurationSection section) { if(section != null && section.isConfigurationSection("SpawnLocation")) { spawn = new Loc(section.getConfigurationSection("SpawnLocation")).toLocation(); super.setWorldName(spawn.getWorld().getName()); } }
Example 16
Source File: ItemConfigurationParser.java From ProjectAres with GNU Affero General Public License v3.0 | 5 votes |
public ItemStack getItem(ConfigurationSection section, String key, Supplier<ItemStack> def) throws InvalidConfigurationException { if(section.isString(key)) { return new ItemStack(needItemType(section, key)); } if(!section.isConfigurationSection(key)) { return def.get(); } final ConfigurationSection itemSection = section.needSection(key); if(itemSection.isString("skull")) { return needSkull(itemSection, "skull"); } final Material material = needItemType(itemSection, "id"); final int damage = itemSection.getInt("damage", 0); if(damage < Short.MIN_VALUE || damage > Short.MAX_VALUE) { throw new InvalidConfigurationException(itemSection, "damage", "Item damage out of range"); } final ItemStack stack = new ItemStack(material, 1, (short) damage); if(itemSection.isString("skin")) { needSkull(stack, itemSection, "skin"); } return stack; }
Example 17
Source File: IslandInfo.java From uSkyBlock with GNU General Public License v3.0 | 4 votes |
public void updatePermissionPerks(@NotNull final Player member, @NotNull Perk perk) { Validate.notNull(member, "Member cannot be null"); Validate.notNull(perk, "Perk cannot be null"); boolean updateRegion = false; if (isLeader(member)) { String oldLeaderName = getLeader(); config.set("party.leader", member.getName()); updateRegion |= !oldLeaderName.equals(member.getName()); } ConfigurationSection section = config.getConfigurationSection("party.members." + member.getUniqueId()); boolean dirty = false; if (section != null) { section.set("name", member.getName()); int maxParty = section.getInt("maxPartySizePermission", Settings.general_maxPartySize); if (perk.getMaxPartySize() != maxParty) { section.set("maxPartySizePermission", perk.getMaxPartySize()); dirty = true; } int maxAnimals = section.getInt("maxAnimals", 0); if (perk.getAnimals() != maxAnimals) { section.set("maxAnimals", perk.getAnimals()); dirty = true; } int maxMonsters = section.getInt("maxMonsters", 0); if (perk.getMonsters() != maxMonsters) { section.set("maxMonsters", perk.getMonsters()); dirty = true; } int maxVillagers = section.getInt("maxVillagers", 0); if (perk.getVillagers() != maxVillagers) { section.set("maxVillagers", perk.getVillagers()); dirty = true; } int maxGolems = section.getInt("maxGolems", 0); if (perk.getGolems() != maxGolems) { section.set("maxGolems", perk.getGolems()); dirty = true; } if (section.isConfigurationSection("maxBlocks")) { dirty = true; Map<Material, Integer> blockLimits = perk.getBlockLimits(); section.set("blockLimits ", null); if (!blockLimits.isEmpty()) { ConfigurationSection maxBlocks = section.createSection("blockLimits"); for (Map.Entry<Material,Integer> limit : blockLimits.entrySet()) { maxBlocks.set(limit.getKey().name(), limit.getValue()); } } } } if (dirty) { save(); } if (updateRegion) { WorldGuardHandler.updateRegion(this); } }
Example 18
Source File: MainConfigMenu.java From uSkyBlock with GNU General Public License v3.0 | 4 votes |
private int addSection(ArrayList<ItemStack> menuList, ConfigurationSection sec, int row, int col, YmlConfiguration config, String filename) { if (isBlackListed(filename, sec.getCurrentPath())) { return row; } ItemStack item = new ItemStack(Material.PAPER, 1); ItemMeta meta = item.getItemMeta(); meta.setDisplayName("\u00a77\u00a7o" + sec.getName()); String comment = config.getComment(sec.getCurrentPath()); if (comment != null) { meta.setLore(wordWrap(comment.replaceAll("\n", " "), 20, 20)); } item.setItemMeta(meta); int index = getIndex(row, col); ensureCapacity(menuList, index); menuList.set(index, item); int colbase = ++col; boolean lastWasSection = true; for (String key : sec.getKeys(false)) { index = getIndex(row, col); ensureCapacity(menuList, index); if (sec.isConfigurationSection(key)) { if (!lastWasSection && col != colbase) { row++; col = colbase; } row = addSection(menuList, sec.getConfigurationSection(key), row, col, config, filename); col = colbase; lastWasSection = true; } else { String path = sec.getCurrentPath() + "." + key; if (isBlackListed(filename, path)) { continue; // Skip } boolean readonly = isReadonly(filename, path); item = null; if (sec.isBoolean(key)) { item = factory.createBooleanItem(sec.getBoolean(key), path, config, readonly); } else if (sec.isInt(key)) { item = factory.createIntegerItem(sec.getInt(key), path, config, readonly); } else { item = factory.createStringItem(sec.getString(key, ""), path, config, readonly); } if (item != null) { if (readonly) { ItemMeta itemMeta = item.getItemMeta(); List<String> lore = itemMeta.getLore(); lore.set(0, READONLY + lore.get(0) + tr("\u00a77 (readonly)")); itemMeta.setLore(lore); item.setItemMeta(itemMeta); } menuList.set(index, item); col++; lastWasSection = false; } } if (col >= 9) { row++; col = colbase; } } return col != colbase ? row+1 : row; }
Example 19
Source File: RentRegion.java From AreaShop with GNU General Public License v3.0 | 4 votes |
/** * Send the expiration warnings from the selected profile which is specified in the config. * Sends all warnings since previous call until (now + normal delay), delay can be found in the config as well. */ public void sendExpirationWarnings() { // Send from warningsDoneUntil to current+delay if(isDeleted() || !isRented()) { return; } ConfigurationSection profileSection = getConfigurationSectionSetting("rent.expirationWarningProfile", "expirationWarningProfiles"); if(profileSection == null) { return; } // Check if a warning needs to be send for each defined point in time Player player = Bukkit.getPlayer(getRenter()); long sendUntil = Calendar.getInstance().getTimeInMillis() + (plugin.getConfig().getInt("expireWarning.delay") * 60 * 1000); for(String timeBefore : profileSection.getKeys(false)) { long timeBeforeParsed = Utils.durationStringToLong(timeBefore); if(timeBeforeParsed <= 0) { return; } long checkTime = getRentedUntil() - timeBeforeParsed; if(checkTime > warningsDoneUntil && checkTime <= sendUntil) { List<String> commands; if(profileSection.isConfigurationSection(timeBefore)) { /* Legacy config layout: * "1 minute": * warnPlayer: true * commands: ["say hi"] */ commands = profileSection.getStringList(timeBefore + ".commands"); // Warn player if(profileSection.getBoolean(timeBefore + ".warnPlayer") && player != null) { message(player, "rent-expireWarning"); } } else { commands = profileSection.getStringList(timeBefore); } this.runCommands(Bukkit.getConsoleSender(), commands); } } warningsDoneUntil = sendUntil; }