Java Code Examples for org.bukkit.configuration.ConfigurationSection#getInt()
The following examples show how to use
org.bukkit.configuration.ConfigurationSection#getInt() .
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: FlagSection.java From HeavySpleef with GNU General Public License v3.0 | 6 votes |
public FlagSection(ConfigurationSection section) { this.autostartVote = section.getInt("autostart-vote", 75); this.anticampingWarn = section.getInt("anticamping-warn", 3); this.anticampingDoWarn = section.getBoolean("anticamping-do-warn", true); this.anticampingTeleport = section.getInt("anticamping-teleport", 6); String readyBlockStr = section.getString("ready-block", "IRON_BLOCK"); MaterialDataMatcher matcher = MaterialDataMatcher.newMatcher(readyBlockStr); matcher.match(); readyBlock = matcher.result(); String leaveItemStr = section.getString("leave-item", "MAGMA_CREAM"); if (!leaveItemStr.equalsIgnoreCase("NONE")) { matcher = MaterialDataMatcher.newMatcher(leaveItemStr); matcher.match(); leaveItem = matcher.result(); } else { leaveItem = null; } this.spleggEggVelocityFactor = section.getDouble("splegg-egg-velocity-factor", 1d); this.spleggEggCooldown = section.getInt("splegg-egg-cooldown", 0); }
Example 2
Source File: ChallengeFactory.java From uSkyBlock with GNU General Public License v3.0 | 6 votes |
private static Reward createReward(ConfigurationSection section) { if (section == null) { return null; } List<String> items = new ArrayList<>(); if (!section.getStringList("items").isEmpty()) { items.addAll(section.getStringList("items")); } else if (section.getString("items", null) != null) { items.addAll(Arrays.asList(section.getString("items").split(" "))); } return new Reward( section.getString("text", "\u00a74Unknown"), ItemStackUtil.createItemsWithProbabilty(items), section.getString("permission"), section.getInt("currency", 0), section.getInt("xp", 0), section.getStringList("commands")); }
Example 3
Source File: BlockLimitLogic.java From uSkyBlock with GNU General Public License v3.0 | 6 votes |
public BlockLimitLogic(uSkyBlock plugin) { this.plugin = plugin; FileConfiguration config = plugin.getConfig(); limitsEnabled = config.getBoolean("options.island.block-limits.enabled", false); if (limitsEnabled) { ConfigurationSection section = config.getConfigurationSection("options.island.block-limits"); Set<String> keys = section.getKeys(false); keys.remove("enabled"); for (String key : keys) { Material material = Material.getMaterial(key.toUpperCase()); int limit = section.getInt(key, -1); if (material != null && limit >= 0) { blockLimits.put(material, limit); } else { log.warning("Unknown material " + key + " supplied for block-limit, or value not an integer"); } } } }
Example 4
Source File: DatabaseConfig.java From HeavySpleef with GNU General Public License v3.0 | 6 votes |
@Override public void inflate(Configuration config, Object... args) { Validate.isTrue(args.length > 0, "args.length must be greater than 0"); Validate.isTrue(args[0] instanceof File, "args[0] must be an instance of " + File.class.getCanonicalName()); File baseDir = (File) args[0]; ConfigurationSection moduleSection = config.getConfigurationSection("database-modules"); this.statisticsEnabled = moduleSection.getBoolean("statistics.enabled"); this.maxStatisticCacheSize = moduleSection.getInt("statistics.max-cache-size", DEFAULT_MAX_CACHE_SIZE); this.connections = Lists.newArrayList(); ConfigurationSection connectionsSection = config.getConfigurationSection("persistence-connection"); for (String key : connectionsSection.getKeys(false)) { connections.add(new DatabaseConnection(connectionsSection.getConfigurationSection(key), baseDir)); } }
Example 5
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 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: PriceOffer.java From Shopkeepers with GNU General Public License v3.0 | 6 votes |
public static List<PriceOffer> loadFromConfigOld(ConfigurationSection config, String node) { List<PriceOffer> offers = new ArrayList<PriceOffer>(); ConfigurationSection offersSection = config.getConfigurationSection(node); if (offersSection != null) { for (String key : offersSection.getKeys(false)) { ConfigurationSection offerSection = offersSection.getConfigurationSection(key); ItemStack item = offerSection.getItemStack("item"); if (item != null) { // legacy: the amount was stored separately from the item item.setAmount(offerSection.getInt("amount", 1)); if (offerSection.contains("attributes")) { String attributes = offerSection.getString("attributes"); if (attributes != null && !attributes.isEmpty()) { item = NMSManager.getProvider().loadItemAttributesFromString(item, attributes); } } } int price = offerSection.getInt("cost"); if (Utils.isEmpty(item) || price < 0) continue; // invalid offer offers.add(new PriceOffer(item, price)); } } return offers; }
Example 8
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 9
Source File: JoinSign.java From DungeonsXL with GNU General Public License v3.0 | 6 votes |
protected JoinSign(DungeonsXL plugin, World world, int id, ConfigurationSection config) { super(plugin, world, id); startSign = world.getBlockAt(config.getInt("x"), config.getInt("y"), config.getInt("z")); String identifier = config.getString("dungeon"); dungeon = plugin.getDungeonRegistry().get(identifier); // LEGACY if (config.contains("maxElements")) { maxElements = config.getInt("maxElements"); } else if (config.contains("maxGroupsPerGame")) { maxElements = config.getInt("maxGroupsPerGame"); } else if (config.contains("maxPlayersPerGroup")) { maxElements = config.getInt("maxPlayersPerGroup"); } startIfElementsAtLeast = config.getInt("startIfElementsAtLeast", -1); verticalSigns = (int) Math.ceil((float) (1 + maxElements) / 4); update(); }
Example 10
Source File: GeneralSection.java From HeavySpleef with GNU General Public License v3.0 | 6 votes |
public GeneralSection(ConfigurationSection section) { String prefix = section.getString("spleef-prefix"); if (prefix != null) { this.spleefPrefix = ChatColor.translateAlternateColorCodes(TRANSLATE_CHAR, prefix); } else { this.spleefPrefix = ChatColor.DARK_GRAY + "[" + ChatColor.GOLD + ChatColor.BOLD + "Spleef" + ChatColor.DARK_GRAY + "]"; } this.whitelistedCommands = section.getStringList("command-whitelist"); String vipPrefix = section.getString("vip-prefix"); if (vipPrefix != null) { this.vipPrefix = ChatColor.translateAlternateColorCodes(TRANSLATE_CHAR, vipPrefix); } else { this.vipPrefix = ChatColor.RED.toString(); } this.vipJoinFull = section.getBoolean("vip-join-full", true); this.pvpTimer = section.getInt("pvp-timer", 0); this.broadcastGameStart = section.getBoolean("broadcast-game-start", true); this.broadcastGameStartBlacklist = section.getStringList("broadcast-game-start-blacklist"); this.winMessageToAll = section.getBoolean("win-message-to-all", true); this.warmupMode = section.getBoolean("warmup-mode", false); this.warmupTime = section.getInt("warmup-time", 10); this.adventureMode = section.getBoolean("adventure-mode", true); }
Example 11
Source File: ConfigUtil.java From ChestCommands with GNU General Public License v3.0 | 5 votes |
public static Integer getAnyInt(ConfigurationSection config, String... paths) { for (String path : paths) { if (config.isSet(path)) { return config.getInt(path); } } return null; }
Example 12
Source File: GovernmentManager.java From Civs with GNU General Public License v3.0 | 5 votes |
private HashSet<GovTypeBuff> getBuffs(ConfigurationSection section) { HashSet<GovTypeBuff> buffs = new HashSet<>(); for (String key : section.getKeys(false)) { GovTypeBuff.BuffType buffType = GovTypeBuff.BuffType.valueOf(key.toUpperCase()); List<String> groups = section.getStringList(key + ".groups"); List<String> regions = section.getStringList(key + ".regions"); HashSet<String> groupSet; if (groups.isEmpty()) { groupSet = new HashSet<>(); } else { groupSet = new HashSet<>(groups); } HashSet<String> regionSet; if (regions.isEmpty()) { regionSet = new HashSet<>(); } else { regionSet = new HashSet<>(regions); } GovTypeBuff govTypeBuff = new GovTypeBuff(buffType, section.getInt(key + ".percent", 10), groupSet, regionSet); buffs.add(govTypeBuff); } return buffs; }
Example 13
Source File: ConfigManager.java From ObsidianDestroyer with GNU General Public License v3.0 | 4 votes |
/** * Translates the materials.yml from memory into a map for quick access * * @return map of materials keys and material durability data */ public Map<String, DurabilityMaterial> getDurabilityMaterials() { final long time = System.currentTimeMillis(); final ConfigurationSection section = materials.getConfigurationSection("HandledMaterials"); int errorDuraCount = 0; int invalidDuraCount = 0; int disabledDuraCount = 0; Map<String, DurabilityMaterial> durabilityMaterials = new HashMap<>(); for (String durabilityMaterial : section.getKeys(false)) { try { final ConfigurationSection materialSection = section.getConfigurationSection(durabilityMaterial); Material material = Material.matchMaterial(durabilityMaterial); if (material == null) { material = Material.matchMaterial(durabilityMaterial, true); if (material == null) { if (DurabilityMaterial.isEnabled(materialSection)) { ObsidianDestroyer.LOG.log(Level.WARNING, "Invalid Material Type: Unable to load ''{0}''", durabilityMaterial); } invalidDuraCount++; continue; } else { ObsidianDestroyer.LOG.log(Level.WARNING, "Semi-Valid Material Type: Loaded as ''{0}''", material.name()); } } if (!Util.isSolid(material) && !materialSection.contains("HandleNonSolid") && !materialSection.getBoolean("HandleNonSolid")) { ObsidianDestroyer.LOG.log(Level.WARNING, "Non-Solid Material Type: Did not load ''{0}''", durabilityMaterial); invalidDuraCount++; continue; } final DurabilityMaterial durablock; if (materialSection.contains("MetaData")) { durablock = new DurabilityMaterial(material, materialSection.getInt("MetaData"), materialSection); } else { durablock = new DurabilityMaterial(material, materialSection); } if (durablock.getEnabled()) { if (getVerbose() || getDebug()) { ObsidianDestroyer.LOG.log(Level.INFO, "Loaded durability of ''{0}'' for ''{1}''", new Object[]{durablock.getDurability(), durablock.toString()}); } durabilityMaterials.put(durablock.toString(), durablock); } else if (getDebug()) { ObsidianDestroyer.debug("Disabled durability of '" + durablock.getDurability() + "' for '" + durablock.toString() + "'"); disabledDuraCount++; } } catch (Exception e) { ObsidianDestroyer.LOG.log(Level.SEVERE, "Failed loading material ''{0}''", durabilityMaterial); errorDuraCount++; } } ObsidianDestroyer.LOG.log(Level.INFO, "Loaded and enabled ''{0}'' material durabilities from config in ''{1}'' ms.", new Object[]{durabilityMaterials.size(), (System.currentTimeMillis() - time)}); ObsidianDestroyer.LOG.log(Level.INFO, "Material in Error: ''{0}'' Invalid: ''{1}'' Disabled: ''{2}''", new Object[]{errorDuraCount, invalidDuraCount, disabledDuraCount}); return durabilityMaterials; }
Example 14
Source File: FeeLevelRequirement.java From DungeonsXL with GNU General Public License v3.0 | 4 votes |
@Override public void setup(ConfigurationSection config) { fee = config.getInt("feeLevel"); }
Example 15
Source File: EntityRemoverTool.java From NBTEditor with GNU General Public License v3.0 | 4 votes |
@Override protected void applyConfig(ConfigurationSection section) { super.applyConfig(section); _radius = section.getInt("radius", 3); }
Example 16
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 17
Source File: PlantTreeEventHandler.java From GiantTrees with GNU General Public License v3.0 | 4 votes |
public PlantTreeEventHandler(final Plugin plugin) { this.plugin = plugin; this.renderer = new TreeRenderer(plugin); this.popup = new PopupHandler(plugin); try { // Read the raw config final ConfigurationSection patternSection = plugin.getConfig() .getConfigurationSection("planting-pattern"); final List<String> rows = patternSection.getStringList("pattern"); final ConfigurationSection materialsSection = patternSection.getConfigurationSection("materials"); final Map<String, Object> configMaterialMap = materialsSection.getValues(false); final Map<Character, String> materialDataMap = new HashMap<>(); for (final Map.Entry<String, Object> kvp : configMaterialMap.entrySet()) { materialDataMap.put(kvp.getKey().charAt(0), (String) kvp.getValue()); } if (materialDataMap.values().stream().noneMatch(s -> s.equals("SAPLING"))) { throw new Exception("Must have at least one 'SAPLING' in the recipe."); } boneMealConsumed = patternSection.getInt("bone-meal-consumed"); // Create a PhysicalCraftingRecipe for each kind of sapling List<Material> saplings = Lists.newArrayList(Material.OAK_SAPLING, Material.SPRUCE_SAPLING, Material.BIRCH_SAPLING, Material.JUNGLE_SAPLING, Material.ACACIA_SAPLING, Material.DARK_OAK_SAPLING); for (Material sapling : saplings) { Map<Character, String> patchedMaterialDataMap = new HashMap<>(materialDataMap); for (Character c : patchedMaterialDataMap.keySet()) { if (patchedMaterialDataMap.get(c).equals("SAPLING")) { patchedMaterialDataMap.put(c, sapling.name()); } } recipes.add(PhysicalCraftingRecipe.fromStringRepresentation(rows.toArray(new String[] {}), patchedMaterialDataMap)); } enabled = true; } catch (final Exception e) { plugin.getLogger().severe("The planting-pattern config section is invalid! Disabling survival planting of giant trees. " + e.toString()); enabled = false; } }
Example 18
Source File: NovaGroupImpl.java From NovaGuilds with GNU General Public License v3.0 | 4 votes |
/** * The constructor * * @param group group name */ public NovaGroupImpl(String group) { name = group; LoggerUtils.info("Loading group '" + name + "'..."); //setting all values ConfigurationSection section = plugin.getConfig().getConfigurationSection("groups." + group); for(NovaGroup.Key<?> key : Key.values()) { String path = paths.get(key); if(!section.contains(path) && values.get(key) != null) { continue; } Object value = null; if(key.getType() == Double.class) { value = section.getDouble(path); } else if(key.getType() == Integer.class) { value = section.getInt(path); } else if(key.getType() == List.class) { value = ItemStackUtils.stringToItemStackList(section.getStringList(path)); if(value == null) { value = new ArrayList<ItemStack>(); } } else if(key.getType() == Schematic.class) { String schematicName = section.getString(path); if(schematicName != null && !schematicName.isEmpty()) { try { value = new SchematicImpl(schematicName); } catch(FileNotFoundException e) { LoggerUtils.error("Schematic not found: schematic/" + schematicName); } } } values.put(key, value); } int autoRegionWidth = get(Key.REGION_AUTOSIZE) * 2 + 1; if(autoRegionWidth > Config.REGION_MAXSIZE.getInt()) { values.put(Key.REGION_AUTOSIZE, Config.REGION_MAXSIZE.getInt() / 2 - 1); LoggerUtils.error("Group " + name + " has too big autoregion. Reset to " + get(Key.REGION_AUTOSIZE)); } if(get(Key.REGION_AUTOSIZE) != 0 && autoRegionWidth < Config.REGION_MINSIZE.getInt()) { values.put(Key.REGION_AUTOSIZE, Config.REGION_MINSIZE.getInt() / 2); LoggerUtils.error("Group " + name + " has too small autoregion. Reset to " + get(Key.REGION_AUTOSIZE)); } }
Example 19
Source File: DeathItemsModule.java From UHC with MIT License | 4 votes |
@Override public void initialize() throws InvalidConfigurationException { if (!config.contains(ITEMS_KEY)) { final ConfigurationSection section = config.createSection(ITEMS_KEY); final ConfigurationSection wool = section.createSection("example wool"); wool.set(TYPE_KEY, "WOOL"); wool.set(AMOUNT_KEY, DEFAULT_ITEM_AMOUNT_1); wool.set(DATA_KEY, DEFAULT_ITEM_DATA_1); final ConfigurationSection dirt = section.createSection("example dirt"); dirt.set(TYPE_KEY, "DIRT"); dirt.set(AMOUNT_KEY, DEFAULT_ITEM_AMOUNT_2); } final ConfigurationSection itemsSection = config.getConfigurationSection(ITEMS_KEY); for (final String key : itemsSection.getKeys(false)) { final ConfigurationSection itemSection = itemsSection.getConfigurationSection(key); if (!itemSection.contains(AMOUNT_KEY)) { throw new InvalidConfigurationException("A drop item requires an `amount`"); } if (!itemSection.contains(TYPE_KEY)) { throw new InvalidConfigurationException("A drop item requires a `type`"); } final int amount = itemSection.getInt(AMOUNT_KEY); if (amount <= 0) throw new InvalidConfigurationException("A drop item cannot have a <= 0 amount"); final Material type; try { type = EnumConverter.forEnum(Material.class).convert(itemSection.getString(TYPE_KEY)); } catch (ValueConversionException ex) { throw new InvalidConfigurationException( "Invalid material for drop item: " + itemSection.getString(TYPE_KEY), ex ); } final ItemStack stack = new ItemStack(type, amount); if (itemSection.contains(DATA_KEY)) { stack.setDurability((short) itemSection.getInt(DATA_KEY)); } stacks.add(stack); } super.initialize(); }
Example 20
Source File: Titles.java From XSeries with MIT License | 3 votes |
/** * Parses and sends a title from the config. * The configuration section must at least * contain {@code title} or {@code subtitle} * * <p> * <b>Example:</b> * <blockquote><pre> * ConfigurationSection titleSection = plugin.getConfig().getConfigurationSection("restart-title"); * Titles.sendTitle(player, titleSection); * </pre></blockquote> * * @param player the player to send the title to. * @param config the configuration section to parse the title properties from. * @since 1.0.0 */ public static void sendTitle(@Nonnull Player player, @Nonnull ConfigurationSection config) { String title = config.getString("title"); String subtitle = config.getString("subtitle"); int fadeIn = config.getInt("fade-in"); int stay = config.getInt("stay"); int fadeOut = config.getInt("fade-out"); if (fadeIn < 1) fadeIn = 10; if (stay < 1) stay = 20; if (fadeOut < 1) fadeOut = 10; sendTitle(player, fadeIn, stay, fadeOut, title, subtitle); }