Java Code Examples for org.bukkit.configuration.ConfigurationSection#isInt()
The following examples show how to use
org.bukkit.configuration.ConfigurationSection#isInt() .
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: SpigotConfig.java From Kettle with GNU General Public License v3.0 | 6 votes |
private static void stats() { disableStatSaving = getBoolean("stats.disable-saving", false); if (!config.contains("stats.forced-stats")) { config.createSection("stats.forced-stats"); } ConfigurationSection section = config.getConfigurationSection("stats.forced-stats"); for (String name : section.getKeys(true)) { if (section.isInt(name)) { if (StatList.getOneShotStat(name) == null) { Bukkit.getLogger().log(Level.WARNING, "Ignoring non existent stats.forced-stats " + name); continue; } forcedStats.put(name, section.getInt(name)); } } }
Example 2
Source File: ParticleData.java From NyaaUtils with MIT License | 6 votes |
@SuppressWarnings("deprecation") @Override public void deserialize(ConfigurationSection config) { if (config.getString("version", "").length() == 0) { String materialName = config.getString("material", null); if (materialName != null) { Material m = Material.matchMaterial(materialName, true); if (m.isBlock() && config.isInt("dataValue")) { config.set("material", Bukkit.getUnsafe().fromLegacy(m, (byte) config.getInt("dataValue")).getMaterial().name()); } else { config.set("material", Bukkit.getUnsafe().fromLegacy(m).name()); } } } ISerializable.deserialize(config, this); }
Example 3
Source File: SpigotConfig.java From Thermos with GNU General Public License v3.0 | 6 votes |
private static void stats() { disableStatSaving = getBoolean( "stats.disable-saving", false ); if ( !config.contains( "stats.forced-stats" ) ) { config.createSection( "stats.forced-stats" ); } ConfigurationSection section = config.getConfigurationSection( "stats.forced-stats" ); for ( String name : section.getKeys( true ) ) { if ( section.isInt( name ) ) { forcedStats.put( name, section.getInt( name ) ); } } if ( disableStatSaving && section.getInt( "achievement.openInventory", 0 ) < 1 ) { Bukkit.getLogger().warning( "*** WARNING *** stats.disable-saving is true but stats.forced-stats.achievement.openInventory" + " isn't set to 1. Disabling stat saving without forcing the achievement may cause it to get stuck on the player's " + "screen." ); } }
Example 4
Source File: IslandInfo.java From uSkyBlock with GNU General Public License v3.0 | 6 votes |
private int getMaxPartyIntValue(String name, int defaultValue) { int value = defaultValue; 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.isInt(name)) { int memberValue = memberSection.getInt(name, value); if (memberValue > value) { value = memberValue; } } } } } return value; }
Example 5
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 6
Source File: IconSerializer.java From ChestCommands with GNU General Public License v3.0 | 6 votes |
public static Coords loadCoordsFromSection(ConfigurationSection section) { Validate.notNull(section, "ConfigurationSection cannot be null"); Integer x = null; Integer y = null; if (section.isInt(Nodes.POSITION_X)) { x = section.getInt(Nodes.POSITION_X); } if (section.isInt(Nodes.POSITION_Y)) { y = section.getInt(Nodes.POSITION_Y); } return new Coords(x, y); }
Example 7
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 8
Source File: PlayerShopkeeper.java From Shopkeepers with GNU General Public License v3.0 | 6 votes |
@Override protected void load(ConfigurationSection config) throws ShopkeeperCreateException { super.load(config); try { ownerUUID = UUID.fromString(config.getString("owner uuid")); } catch (Exception e) { // uuid invalid or non-existent: throw new ShopkeeperCreateException("Missing owner uuid!"); } ownerName = config.getString("owner", "unknown"); if (!config.isInt("chestx") || !config.isInt("chesty") || !config.isInt("chestz")) { throw new ShopkeeperCreateException("Missing chest coordinate(s)"); } // update chest: this.setChest(config.getInt("chestx"), config.getInt("chesty"), config.getInt("chestz")); forHire = config.getBoolean("forhire"); hireCost = config.getItemStack("hirecost"); if (forHire && hireCost == null) { Log.warning("Couldn't load hire cost! Disabling 'for hire' for shopkeeper at " + this.getPositionString()); forHire = false; } }
Example 9
Source File: VillagerShop.java From Shopkeepers with GNU General Public License v3.0 | 6 votes |
@Override protected void load(ConfigurationSection config) { super.load(config); // load profession: String professionInput; if (config.isInt("prof")) { // import from pre 1.10 profession ids: int profId = config.getInt("prof"); professionInput = String.valueOf(profId); this.profession = getProfessionFromOldId(profId); } else { professionInput = config.getString("prof"); this.profession = getProfession(professionInput); } // validate: if (!isVillagerProfession(profession)) { // fallback: Log.warning("Missing or invalid villager profession '" + professionInput + "'. Using '" + Profession.FARMER + "' now."); this.profession = Profession.FARMER; } }
Example 10
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; }