Java Code Examples for org.bukkit.configuration.file.FileConfiguration#isConfigurationSection()
The following examples show how to use
org.bukkit.configuration.file.FileConfiguration#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: Rewards.java From CombatLogX with GNU General Public License v3.0 | 6 votes |
private void setupRewards() { this.rewardList.clear(); FileConfiguration config = getConfig("rewards.yml"); if(!config.isConfigurationSection("rewards")) return; ConfigurationSection sectionRewards = config.getConfigurationSection("rewards"); if(sectionRewards == null) return; Set<String> rewardSet = sectionRewards.getKeys(false); for(String rewardId : rewardSet) { ConfigurationSection rewardInfo = sectionRewards.getConfigurationSection(rewardId); if(rewardInfo == null) continue; Reward reward = setupReward(rewardId, rewardInfo); if(reward != null) this.rewardList.add(reward); } }
Example 2
Source File: Sounds.java From iDisguise with Creative Commons Attribution Share Alike 4.0 International | 6 votes |
public static void init(String file) { try { BufferedReader reader = new BufferedReader(new InputStreamReader(Sounds.class.getResourceAsStream(file))); FileConfiguration fileConfiguration = YamlConfiguration.loadConfiguration(reader); if(fileConfiguration.isConfigurationSection("STEP")) { stepSounds = new Sounds(fileConfiguration.getConfigurationSection("STEP")); } for(DisguiseType type : DisguiseType.values()) { if(fileConfiguration.isConfigurationSection(type.name())) { setSoundsForEntity(type, new Sounds(fileConfiguration.getConfigurationSection(type.name()))); } } reader.close(); } catch(IOException e) { iDisguise.getInstance().getLogger().log(Level.SEVERE, "Cannot load the required sound effect configuration.", e); } }
Example 3
Source File: ResourceManagerGuildImpl.java From NovaGuilds with GNU General Public License v3.0 | 4 votes |
@Override public boolean save(NovaGuild guild) { if(!guild.isChanged() && !isInSaveQueue(guild) || guild.isUnloaded()) { return false; } if(!guild.isAdded()) { add(guild); } FileConfiguration guildData = getData(guild); if(guildData == null) { LoggerUtils.error("Attempting to save non-existing guild. " + guild.getName()); return false; } try { IConverter<NovaGuild, UUID> resourceToUUIDConverter = new ResourceToUUIDConverterImpl<>(); IConverter<Object, String> toStringConverter = new ToStringConverterImpl(); //set values guildData.set("name", guild.getName()); guildData.set("tag", guild.getTag()); guildData.set("leader", guild.getLeader().getUUID().toString()); guildData.set("allies", toStringConverter.convert((List) resourceToUUIDConverter.convert(guild.getAllies()))); guildData.set("alliesinv", toStringConverter.convert((List) resourceToUUIDConverter.convert(guild.getAllyInvitations()))); guildData.set("wars", toStringConverter.convert((List) resourceToUUIDConverter.convert(guild.getWars()))); guildData.set("nowar", toStringConverter.convert((List) resourceToUUIDConverter.convert(guild.getNoWarInvitations()))); guildData.set("money", guild.getMoney()); guildData.set("points", guild.getPoints()); guildData.set("lives", guild.getLives()); guildData.set("slots", guild.getSlots()); guildData.set("banner", BannerUtils.serialize(guild.getBannerMeta())); guildData.set("timerest", guild.getTimeRest()); guildData.set("lostlive", guild.getLostLiveTime()); guildData.set("activity", guild.getInactiveTime()); guildData.set("created", guild.getTimeCreated()); guildData.set("openinv", guild.isOpenInvitation()); //spawnpoint Location home = guild.getHome(); guildData.set("home.world", home.getWorld().getUID().toString()); guildData.set("home.x", home.getBlockX()); guildData.set("home.y", home.getBlockY()); guildData.set("home.z", home.getBlockZ()); guildData.set("home.yaw", home.getYaw()); //bankloc Location vaultLocation = guild.getVaultLocation(); if(vaultLocation != null) { guildData.set("bankloc.world", vaultLocation.getWorld().getUID().toString()); guildData.set("bankloc.x", vaultLocation.getBlockX()); guildData.set("bankloc.y", vaultLocation.getBlockY()); guildData.set("bankloc.z", vaultLocation.getBlockZ()); } else { guildData.set("bankloc", null); } //Remove old ranks data if(guildData.isConfigurationSection("ranks")) { guildData.set("ranks", null); } //save guildData.save(getFile(guild)); } catch(IOException e) { LoggerUtils.exception(e); } return true; }
Example 4
Source File: CommandAdminConfigGet.java From NovaGuilds with GNU General Public License v3.0 | 4 votes |
@Override public void execute(CommandSender sender, String[] args) throws Exception { if(args.length == 0) { getCommand().getUsageMessage().send(sender); return; } String path = args[0]; String value = ""; Map<VarKey, String> vars = new HashMap<>(); FileConfiguration config = plugin.getConfigManager().getConfig(); if(!config.contains(path)) { Message.CHAT_INVALIDPARAM.send(sender); return; } if(config.isConfigurationSection(path)) { int depth = 1; String lastSection = null; vars.put(VarKey.DEPTH, ""); vars.put(VarKey.KEY, path); Message.CHAT_ADMIN_CONFIG_GET_LIST_SECTION.clone().vars(vars).send(sender); for(String string : config.getConfigurationSection(path).getKeys(true)) { String[] prefixSplit = StringUtils.split(string, "."); String prefix = StringUtils.contains(string, ".") ? StringUtils.removeEnd(string, "." + prefixSplit[prefixSplit.length - 1]) : string; if(lastSection != null && !prefix.startsWith(lastSection)) { depth--; lastSection = null; } String space = ""; for(int i = 0; i < depth; i++) { space += " "; } vars.put(VarKey.DEPTH, space); if(config.isConfigurationSection(path + "." + string)) { depth++; lastSection = string; vars.put(VarKey.KEY, prefixSplit[prefixSplit.length - 1]); Message.CHAT_ADMIN_CONFIG_GET_LIST_SECTION.clone().vars(vars).send(sender); } else { //key vars.put(VarKey.KEY, StringUtils.removeStart(string, prefix + ".")); Message.CHAT_ADMIN_CONFIG_GET_LIST_KEY.clone().vars(vars).send(sender); } } } else { if(config.isList(path)) { value = StringUtils.join(config.getStringList(path), " "); } else { value = config.getString(path); } } vars.put(VarKey.KEY, path); vars.put(VarKey.VALUE, value); if(!value.isEmpty()) { Message.CHAT_ADMIN_CONFIG_GET_SINGLE.clone().vars(vars).send(sender); } }