org.bukkit.configuration.ConfigurationSection Java Examples
The following examples show how to use
org.bukkit.configuration.ConfigurationSection.
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: PacketsModule.java From ExploitFixer with GNU General Public License v3.0 | 7 votes |
final public void reload(final Configuration configYml) { final ConfigurationSection configurationSection = configYml.getConfigurationSection("packets.multipliers"); final String name = "packets"; this.name = "Packets"; this.enabled = configYml.getBoolean(name + ".enabled"); this.cancelVls = configYml.getDouble(name + ".cancel_vls"); this.reduceVls = configYml.getDouble(name + ".reduce_vls"); this.offline = configYml.getBoolean(name + ".offline"); this.dataVls = configYml.getDouble(name + ".data.vls"); this.dataBytes = configYml.getInt(name + ".data.bytes", 24000); this.dataBytesBook = configYml.getInt(name + ".data.bytes_book", 268); this.dataBytesSign = configYml.getInt(name + ".data.bytes_sign", 47); this.dataBytesDivider = configYml.getInt(name + ".data.bytes_divider", 200); this.windowClick = configYml.getDouble(name + ".window_click"); this.blockPlaceVls = configYml.getDouble(name + ".block_place"); this.blockDigVls = configYml.getDouble(name + ".block_dig"); this.setCreativeSlot = configYml.getDouble(name + ".set_creative_slot"); this.violations = new Violations(configYml.getConfigurationSection(name + ".violations")); for (final String key : configurationSection.getKeys(false)) multipliers.put(key, configurationSection.getDouble(key)); }
Example #2
Source File: GeneralRegion.java From AreaShop with GNU General Public License v3.0 | 7 votes |
/** * Checks an event and handles saving to and restoring from schematic for it. * @param type The type of event */ public void handleSchematicEvent(RegionEvent type) { // Check the individual>group>default setting if(!isRestoreEnabled()) { AreaShop.debug("Schematic operations for " + getName() + " not enabled, skipped"); return; } // Get the safe and restore names ConfigurationSection profileSection = getConfigurationSectionSetting("general.schematicProfile", "schematicProfiles"); if(profileSection == null) { return; } String save = profileSection.getString(type.getValue() + ".save"); String restore = profileSection.getString(type.getValue() + ".restore"); // Save the region if needed if(save != null && !save.isEmpty()) { save = Message.fromString(save).replacements(this).getSingle(); saveRegionBlocks(save); } // Restore the region if needed if(restore != null && !restore.isEmpty()) { restore = Message.fromString(restore).replacements(this).getSingle(); restoreRegionBlocks(restore); } }
Example #3
Source File: GeneralRegion.java From AreaShop with GNU General Public License v3.0 | 7 votes |
/** * Get a configuration section setting for this region, defined as follows * - If the region has the setting in its own file (/regions/regionName.yml), use that * - If the region has groups, use the setting defined by the most important group, if any * - Otherwise fallback to the default.yml file setting * @param path The path to get the setting of * @return The value of the setting */ public ConfigurationSection getConfigurationSectionSetting(String path) { if(config.isSet(path)) { return config.getConfigurationSection(path); } ConfigurationSection result = null; int priority = Integer.MIN_VALUE; boolean found = false; for(RegionGroup group : plugin.getFileManager().getGroups()) { if(group.isMember(this) && group.getSettings().isSet(path) && group.getPriority() > priority) { result = group.getSettings().getConfigurationSection(path); priority = group.getPriority(); found = true; } } if(found) { return result; } if(this.getFileManager().getRegionSettings().isSet(path)) { return this.getFileManager().getRegionSettings().getConfigurationSection(path); } else { return this.getFileManager().getFallbackRegionSettings().getConfigurationSection(path); } }
Example #4
Source File: SignsFeature.java From AreaShop with GNU General Public License v3.0 | 7 votes |
/** * Constructor. * @param region The region to bind to */ public SignsFeature(GeneralRegion region) { setRegion(region); signs = new HashMap<>(); // Setup current signs ConfigurationSection signSection = region.getConfig().getConfigurationSection("general.signs"); if(signSection != null) { for(String signKey : signSection.getKeys(false)) { RegionSign sign = new RegionSign(this, signKey); Location location = sign.getLocation(); if(location == null) { AreaShop.warn("Sign with key " + signKey + " of region " + region.getName() + " does not have a proper location"); continue; } signs.put(sign.getStringLocation(), sign); signsByChunk.computeIfAbsent(sign.getStringChunk(), key -> new ArrayList<>()) .add(sign); } allSigns.putAll(signs); } }
Example #5
Source File: Config.java From BetonQuest with GNU General Public License v3.0 | 6 votes |
/** * Returns the ID of a conversation assigned to specified NPC, across all * packages. If there are multiple assignments for the same value, the first * one will be returned. * * @param value the name of the NPC (as defined in <i>main.yml</i>) * @return the ID of the conversation assigned to this NPC or null if there * isn't one */ public static String getNpc(String value) { // load npc assignments from all packages for (String packName : packages.keySet()) { ConfigPackage pack = packages.get(packName); ConfigurationSection assignments = pack.getMain().getConfig().getConfigurationSection("npcs"); if (assignments != null) { for (String assignment : assignments.getKeys(false)) { if (assignment.equalsIgnoreCase(value)) { return packName + "." + assignments.getString(assignment); } } } } return null; }
Example #6
Source File: IServerBridge.java From PlotMe-Core with GNU General Public License v3.0 | 6 votes |
public ConfigurationSection loadDefaultConfig(ConfigAccessor configFile, String world) { ConfigurationSection defaultWorld = getDefaultWorld(); ConfigurationSection configSection; if (configFile.getConfig().contains(world)) { configSection = configFile.getConfig().getConfigurationSection(world); } else { configFile.getConfig().set(world, defaultWorld); configFile.saveConfig(); configSection = configFile.getConfig().getConfigurationSection(world); } for (String path : defaultWorld.getKeys(true)) { configSection.addDefault(path, defaultWorld.get(path)); } configFile.saveConfig(); return configSection; }
Example #7
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 #8
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 #9
Source File: AnniSign.java From AnnihilationPro with MIT License | 6 votes |
public void saveToConfig(ConfigurationSection configSection) { if(configSection != null) { configSection.set("isSignPost", this.isSignPost()); //ConfigManager.saveLocation(this.getLocation(), configSection.createSection("Location")); getLocation().saveToConfig(configSection.createSection("Location")); configSection.set("FacingDirection", this.getFacingDirection().name()); String data; if(this.getType().equals(SignType.Brewing)) data = "Brewing"; else if(this.getType().equals(SignType.Weapon)) data = "Weapon"; else data = "Team-"+this.getType().getTeam().getName(); configSection.set("Data", data); } }
Example #10
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 #11
Source File: Configuration.java From NyaaUtils with MIT License | 6 votes |
@Override public void serialize(ConfigurationSection config) { // general values save & standalone config save ISerializable.serialize(config, this); // Enchantment Max Level constraint ConfigurationSection list = config.createSection("enchant.max_level"); for (Enchantment k : enchantMaxLevel.keySet()) { if (k == null || k.getKey() == null || k.getKey().getKey() == null) continue; list.set(k.getKey().getKey(), enchantMaxLevel.get(k)); } config.set("particles.limits", null); for (ParticleType type : particlesLimits.keySet()) { particlesLimits.get(type).serialize(config.createSection("particles.limits." + type.name())); } }
Example #12
Source File: LevelConfigYmlReader.java From uSkyBlock with GNU General Public License v3.0 | 6 votes |
private BlockLevelConfig readBlockSection(ConfigurationSection section, BlockMatch blockMatch, BlockLevelConfigBuilder defaultBuilder) { BlockLevelConfigBuilder builder = defaultBuilder.copy() .base(blockMatch); double score = section.getDouble("score", -1); if (score >= 0) { builder.scorePerBlock(score); } int limit = section.getInt("limit", -1); if (limit >= 0) { builder.limit(limit); } int diminishingReturns = section.getInt("diminishingReturns", -1); if (diminishingReturns >= 0) { builder.diminishingReturns(diminishingReturns); } int negativeReturns = section.getInt("negativeReturns", -1); if (negativeReturns >= 0) { builder.negativeReturns(negativeReturns); } List<String> additionBlocks = section.getStringList("additionalBlocks"); if (!additionBlocks.isEmpty()) { builder.additionalBlocks(additionBlocks.stream().map(s -> getBlockMatch(s)).collect(Collectors.toList()).toArray(new BlockMatch[0])); } return builder.build(); }
Example #13
Source File: LevelConfigYmlWriter.java From uSkyBlock with GNU General Public License v3.0 | 6 votes |
private void writeToSection(ConfigurationSection section, BlockLevelConfig config, BlockLevelConfig mapDefault) { if (!config.getAdditionalBlocks().isEmpty()) { section.set("additionalBlocks", config.getAdditionalBlocks().stream().distinct().map(m -> m.toString()).collect(Collectors.toList())); } if (config.getScorePerBlock() >= 0 && config.getScorePerBlock() != mapDefault.getScorePerBlock()) { section.set("score", config.getScorePerBlock()); } if (config.getLimit() >= 0 && config.getLimit() != mapDefault.getLimit()) { section.set("limit", config.getLimit()); } if (config.getDiminishingReturns() > 0 && config.getLimit() != mapDefault.getDiminishingReturns()) { section.set("diminishingReturns", config.getDiminishingReturns()); } if (config.getNegativeReturns() > 0 && config.getLimit() != mapDefault.getNegativeReturns()) { section.set("negativeReturns", config.getNegativeReturns()); } }
Example #14
Source File: QuestCommand.java From BetonQuest with GNU General Public License v3.0 | 6 votes |
/** * Returns a list including all possible options for tab complete of the * /betonquest vector command * * @param sender * @param args * @return */ private List<String> completeVector(CommandSender sender, String[] args) { if (args.length == 2) { if (args[1] == null || !args[1].contains(".")) { return completePackage(sender, args); } String pack = args[1].substring(0, args[1].indexOf(".")); ConfigPackage configPack = Config.getPackages().get(pack); if (configPack == null) return new ArrayList<>(); ConfigurationSection section = configPack.getMain().getConfig().getConfigurationSection("variables"); Collection<String> keys = section.getKeys(false); if (keys.isEmpty()) return new ArrayList<>(); return new ArrayList<>(keys); } return new ArrayList<>(); }
Example #15
Source File: HologramFormat.java From ShopChest with MIT License | 6 votes |
/** * @return Whether the hologram text has to change dynamically without reloading */ public boolean isDynamic() { int count = getLineCount(); for (int i = 0; i < count; i++) { ConfigurationSection options = config.getConfigurationSection("lines." + i + ".options"); for (String key : options.getKeys(false)) { ConfigurationSection option = options.getConfigurationSection(key); String format = option.getString("format"); if (format.contains(Placeholder.STOCK.toString()) || format.contains(Placeholder.CHEST_SPACE.toString())) { return true; } for (String req : option.getStringList("requirements")) { if (req.contains(Requirement.IN_STOCK.toString()) || req.contains(Requirement.CHEST_SPACE.toString())) { return true; } } } } return false; }
Example #16
Source File: WorldMatcher.java From UHC with MIT License | 6 votes |
public WorldMatcher(ConfigurationSection section, List<String> worldsDefault, boolean isWhitelistDefault) { if (!section.contains(WORLDS_KEY)) { section.set(WORLDS_KEY, worldsDefault); } if (!section.contains(IS_WHITELIST_KEY)) { section.set(IS_WHITELIST_KEY, isWhitelistDefault); } worlds = ImmutableSet.copyOf( Iterables.filter( Iterables.transform(section.getStringList(WORLDS_KEY), TO_LOWER_CASE), Predicates.notNull() ) ); isWhitelist = section.getBoolean(IS_WHITELIST_KEY); }
Example #17
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 #18
Source File: RegionSign.java From AreaShop with GNU General Public License v3.0 | 6 votes |
/** * Check if the sign needs to update periodically. * @return true if it needs periodic updates, otherwise false */ public boolean needsPeriodicUpdate() { ConfigurationSection signConfig = getProfile(); if(signConfig == null || !signConfig.isSet(getRegion().getState().getValue().toLowerCase())) { return false; } ConfigurationSection stateConfig = signConfig.getConfigurationSection(getRegion().getState().getValue().toLowerCase()); if(stateConfig == null) { return false; } // Check the lines for the timeleft tag for(int i = 1; i <= 4; i++) { String line = stateConfig.getString("line" + i); if(line != null && !line.isEmpty() && line.contains(Message.VARIABLE_START + AreaShop.tagTimeLeft + Message.VARIABLE_END)) { return true; } } return false; }
Example #19
Source File: XPMain.java From AnnihilationPro with MIT License | 6 votes |
public void loadXPVars(ConfigurationSection section) { assert section != null; int nexusHitXP = section.getInt("Nexus-Hit-XP"); int killXP = section.getInt("Player-Kill-XP"); String gaveXPMessage = section.getString("Gave-XP-Message"); String myXPMessage = section.getString("MyXP-Command-Message"); int[] teamXPs = new int[4]; teamXPs[0] = section.getInt("Winning-Team-XP"); teamXPs[1] = section.getInt("Second-Place-Team-XP"); teamXPs[2] = section.getInt("Third-Place-Team-XP"); teamXPs[3] = section.getInt("Last-Place-Team-XP"); XPListeners listeners = new XPListeners(this.xpSystem,gaveXPMessage,killXP,nexusHitXP,teamXPs); MyXPCommand command = new MyXPCommand(this.xpSystem,myXPMessage); //AnniEvent.registerListener(listeners); Bukkit.getPluginManager().registerEvents(listeners, this); this.getCommand("MyXP").setExecutor(command); }
Example #20
Source File: SignLayoutConfiguration.java From HeavySpleef with GNU General Public License v3.0 | 6 votes |
@Override public void inflateUnsafe(Configuration config, Object[] args) throws ParseException { List<String> lines = Lists.newArrayList(); ConfigurationSection layoutSection = config.getConfigurationSection("layout"); for (int i = 1; i <= SignLayout.LINE_COUNT; i++) { String line = layoutSection.getString(String.valueOf(i)); lines.add(line); } layout = new SignLayout(lines); if (config.contains("options")) { options = config.getConfigurationSection("options"); } }
Example #21
Source File: GuildHandler.java From Guilds with MIT License | 6 votes |
/** * Load all the roles */ private void loadRoles() { final YamlConfiguration conf = YamlConfiguration.loadConfiguration(new File(guildsPlugin.getDataFolder(), "roles.yml")); final ConfigurationSection roleSec = conf.getConfigurationSection("roles"); for (String s : roleSec.getKeys(false)) { final String path = s + ".permissions."; final String name = roleSec.getString(s + ".name"); final String perm = roleSec.getString(s + ".permission-node"); final int level = Integer.parseInt(s); final GuildRole role = new GuildRole(name, perm, level); for (GuildRolePerm rolePerm: GuildRolePerm.values()) { final String valuePath = path + rolePerm.name().replace("_", "-").toLowerCase(); if (roleSec.getBoolean(valuePath)) { role.addPerm(rolePerm); } } this.roles.add(role); } }
Example #22
Source File: JSONConfiguration.java From QuickShop-Reremake with GNU General Public License v3.0 | 6 votes |
protected void convertMapsToSections( @NotNull Map<?, ?> input, @NotNull ConfigurationSection section) { final Object result = SerializationHelper.deserialize(input); if (result instanceof Map) { input = (Map<?, ?>) result; for (Map.Entry<?, ?> entry : input.entrySet()) { final String key = entry.getKey().toString(); final Object value = entry.getValue(); if (value instanceof Map) { convertMapsToSections((Map<?, ?>) value, section.createSection(key)); } else { section.set(key, value); } } } else { section.set("", result); } }
Example #23
Source File: GuildHandler.java From Guilds with MIT License | 6 votes |
private void loadTiers() { final YamlConfiguration conf = YamlConfiguration.loadConfiguration(new File(guildsPlugin.getDataFolder(), "tiers.yml")); final ConfigurationSection tierSec = conf.getConfigurationSection("tiers.list"); for (String key : tierSec.getKeys(false)) { tiers.add(GuildTier.builder() .level(tierSec.getInt(key + ".level")) .name(tierSec.getString(key + ".name")) .cost(tierSec.getDouble(key + ".cost", 1000)) .maxMembers(tierSec.getInt(key + ".max-members", 10)) .vaultAmount(tierSec.getInt(key + ".vault-amount", 1)) .mobXpMultiplier(tierSec.getDouble(key + ".mob-xp-multiplier", 1.0)) .damageMultiplier(tierSec.getDouble(key + ".damage-multiplier", 1.0)) .maxBankBalance(tierSec.getDouble(key + ".max-bank-balance", 10000)) .membersToRankup(tierSec.getInt(key + ".members-to-rankup", 5)) .maxAllies(tierSec.getInt(key + ".max-allies", 10)) .useBuffs(tierSec.getBoolean(key + ".use-buffs", true)) .permissions(tierSec.getStringList(key + ".permissions")) .build()); } }
Example #24
Source File: Shopkeeper.java From Shopkeepers with GNU General Public License v3.0 | 5 votes |
/** * Loads a shopkeeper's saved data from a config section of a config file. * * @param config * the config section * @throws ShopkeeperCreateException * if the shopkeeper cannot be properly loaded */ protected void load(ConfigurationSection config) throws ShopkeeperCreateException { String uniqueIdString = config.getString("uniqueId", ""); try { this.uniqueId = UUID.fromString(uniqueIdString); } catch (IllegalArgumentException e) { if (!uniqueIdString.isEmpty()) { Log.warning("Invalid shop uuid '" + uniqueIdString + "'. Creating a new one."); } this.uniqueId = UUID.randomUUID(); } this.name = Utils.colorize(config.getString("name", "")); this.worldName = config.getString("world"); this.x = config.getInt("x"); this.y = config.getInt("y"); this.z = config.getInt("z"); this.updateChunkData(); ShopObjectType objectType = ShopkeepersPlugin.getInstance().getShopObjectTypeRegistry().get(config.getString("object")); if (objectType == null) { // use default shop object type: objectType = ShopkeepersPlugin.getInstance().getDefaultShopObjectType(); Log.warning("Invalid object type '" + config.getString("object") + "' for shopkeeper '" + uniqueId + "'. Did you edit the save file? Switching to default type '" + objectType.getIdentifier() + "'."); } this.shopObject = objectType.createObject(this, new ShopCreationData()); // dummy ShopCreationData this.shopObject.load(config); }
Example #25
Source File: BookPlayerShopkeeper.java From Shopkeepers with GNU General Public License v3.0 | 5 votes |
@Override protected void load(ConfigurationSection config) throws ShopkeeperCreateException { super.load(config); // load offers: this.clearOffers(); // TODO remove legacy: load offers from old costs section (since late MC 1.12.2) this.addOffers(BookOffer.loadFromConfig(config, "costs")); this.addOffers(BookOffer.loadFromConfig(config, "offers")); }
Example #26
Source File: ItemManager.java From Civs with GNU General Public License v3.0 | 5 votes |
public Map<String, Integer> loadCivItems(FileConfiguration civConfig) { HashMap<String, Integer> items = new HashMap<>(); ConfigurationSection configurationSection = civConfig.getConfigurationSection("items"); if (configurationSection == null) { return items; } for (String key : configurationSection.getKeys(false)) { CivItem currentItem = getItemType(key); if (currentItem == null) { continue; } items.put(key, civConfig.getInt("items." + key)); } return items; }
Example #27
Source File: BukkitConfigAdapter.java From LuckPerms with MIT License | 5 votes |
@Override public List<String> getKeys(String path, List<String> def) { ConfigurationSection section = this.configuration.getConfigurationSection(path); if (section == null) { return def; } Set<String> keys = section.getKeys(false); return keys == null ? def : new ArrayList<>(keys); }
Example #28
Source File: CancelEffect.java From Civs with GNU General Public License v3.0 | 5 votes |
public CancelEffect(Spell spell, String key, Object target, Entity origin, int level, ConfigurationSection section) { super(spell, key, target, origin, level, section); this.silent = section.getBoolean("silent", false); this.target = section.getString("target", "self"); this.abilityName = section.getString("ability", "self"); this.whitelist = section.getStringList("whitelist"); this.blacklist = section.getStringList("blacklist"); this.config = section; }
Example #29
Source File: NavigatorInterface.java From ProjectAres with GNU Affero General Public License v3.0 | 5 votes |
@Override protected void configChanged(@Nullable ConfigurationSection before, @Nullable ConfigurationSection after) throws InvalidConfigurationException { super.configChanged(before, after); if(after != null) { load(after); } else { clear(); } }
Example #30
Source File: SavePortals.java From WildernessTp with MIT License | 5 votes |
private void fillMap() { ConfigurationSection sec = portals.getConfigurationSection("Portals"); if(sec == null){ plugin.getLogger().info("Portals file is empty probably not a problem"); return; } for (String name : sec.getKeys(false)) { if (name == null) { plugin.getLogger().info("Portals file is empty probably not a problem if it is report this"); return; } String loc = portals.getString("Portals." + name); plugin.portals.put(name, loc); } }