public ConfigurationSection getWorlds() { return config.getConfigurationSection("worlds"); }
/** * Creates a MaterialValueManager using the data from the resource file * {@code builtin/materialValues.yml} in the Glowstone jar. */ public BuiltinMaterialValueManager() { values = new EnumMap<>(Material.class); YamlConfiguration builtinValues = YamlConfiguration.loadConfiguration(new InputStreamReader( getClass().getClassLoader().getResourceAsStream("builtin/materialValues.yml"))); defaultValue = new BuiltinValueCollection( builtinValues.getConfigurationSection("default")); // NON-NLS registerBuiltins(builtinValues); }
/** * @return Amount of lines in a hologram */ public int getLineCount() { return config.getConfigurationSection("lines").getKeys(false).size(); }
@Override public Map<String, String> getStringMap(String path) { Map<String, String> values = new HashMap<String, String>(); ConfigurationSection configurationSection = configFile.getConfigurationSection(path); if (configurationSection != null) { for (Map.Entry<String, Object> entry : configurationSection.getValues(false).entrySet()) { values.put(entry.getKey(), (String) entry.getValue()); } } return values; }
@Override public String[] getKeys(Object file, String path) { String[] ss = new String[0]; return ((YamlConfiguration) file).getConfigurationSection(path).getKeys(false).toArray(ss); }
protected String[] get(Event event) { String k = (String) this.key.getSingle(event); String f = (String) this.file.getSingle(event); if ((k == null) || (f == null)) { return null; } File file = new File(f.replaceAll("/", Matcher.quoteReplacement(File.separator))); if (!file.exists()) { try { file.getParentFile().mkdirs(); file.createNewFile(); } catch (IOException e) { } } YamlConfiguration yml = YamlConfiguration.loadConfiguration(file); if (yml == null) { return null; } ConfigurationSection cs = yml.getConfigurationSection(k); if (cs == null) { return null; } ArrayList<String> list = new ArrayList<String>(); for (String key : cs.getKeys(false)) { list.add(key); } String[] s = new String[list.size()]; return list.toArray(s); }
public Map<String, String> getSetStringMap(String path, Map<String, String> defaultValues) throws InvalidConfigurationException { if (config.isConfigurationSection(path)) { ConfigurationSection section = config.getConfigurationSection(path); Map<String, Object> entries = section.getValues(false); Map<String, String> values = new HashMap<>(entries.size()); for (Map.Entry<String, Object> entry : entries.entrySet()) { Object obj = entry.getValue(); if (obj instanceof String) { values.put(entry.getKey(), (String) obj); } else if (obj instanceof Double || obj instanceof Integer || obj instanceof Boolean) { values.put(entry.getKey(), obj.toString()); } else { throw new InvalidConfigurationException("Object " + obj + " found in map " + path + " in file " + configFile.toAbsolutePath() + " is not an integerr"); } } return values; } else if (config.contains(path)) { throw new InvalidConfigurationException("Object " + config.get(path) + " found under " + path + " in file " + configFile + " is not a map"); } else { logger.log(Level.INFO, "Setting {0} to {1} in file {2}", new Object[]{path, defaultValues, configFile}); ConfigurationSection section = config.createSection(path); for (Map.Entry<String, String> entry : defaultValues.entrySet()) { section.set(entry.getKey(), entry.getValue()); } return defaultValues; } }
public ConfigurationSection getSetSection(String path, Map<String, String> defaultValues) throws InvalidConfigurationException { if (config.isConfigurationSection(path)) { return config.getConfigurationSection(path); } else if (config.contains(path)) { throw new InvalidConfigurationException("Object " + config.get(path) + " found under " + path + " in file " + configFile + " is not a configuration section"); } else { logger.log(Level.INFO, "Setting {0} to {1} in file {2}", new Object[]{path, defaultValues, configFile}); ConfigurationSection section = config.createSection(path); for (Map.Entry<String, String> entry : defaultValues.entrySet()) { section.set(entry.getKey(), entry.getValue()); } return section; } }
@Override public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) { String lastArg = args[args.length - 1]; if (args.length <= 1) { return partial(args[0], ROOT_SUBS); } else if (args.length == 2) { String sub = args[0]; return partial(lastArg, removeUnwanted(plugin.getGeneralKeeper().getPluginYAML().getConfigurationSection("commands." + sub).getKeys(false))); } return ImmutableList.of(); }
private void convertToMaterial(String sectionPath) { ConfigurationSection section = configuration.getConfigurationSection(sectionPath); if (section != null) { for (String typeId : section.getKeys(false)) { Material material = Material.matchMaterial(typeId); if (material != null) { configuration.set(sectionPath + "." + material.toString().toLowerCase(), configuration.get(sectionPath + "." + typeId)); configuration.set(sectionPath + "." + typeId, null); } } } }
protected void describeParameters(CommandSender sender) { Collection<String> keys = parameters.getKeys(false); if (keys.size() == 0) { sender.sendMessage(ChatColor.GRAY + " (None)"); } for (String key : keys) { String value = null; if (parameters.isConfigurationSection(key)) { ConfigurationSection child = parameters.getConfigurationSection(key); value = "(" + child.getKeys(false).size() + " values)"; } else { value = parameters.getString(key); } sender.sendMessage(ChatColor.LIGHT_PURPLE + " " + key + ": " + value); } }
ConfigurationSection perms = data.getConfigurationSection("permissions"); perms.getKeys(true).forEach(perm -> { if (perms.contains(perm + ".default") && perms.contains(perm + ".description")) {
/** * Gets an inventory without storing references to it. Used for dropping a players inventories on death. * * @param holder The holder of the vault. * @param number The vault number. * @return The inventory of the specified holder and vault number. */ public Inventory getVault(UUID holder, int number) { YamlConfiguration playerFile = getPlayerVaultFile(holder); ConfigurationSection section = playerFile.getConfigurationSection("vault" + number); int maxSize = VaultOperations.getMaxVaultSize(holder.toString()); String title = Lang.VAULT_TITLE.toString().replace("%number", String.valueOf(number)); if (section == null) { VaultHolder vaultHolder = new VaultHolder(number); Inventory inv = Bukkit.createInventory(vaultHolder, maxSize, title); vaultHolder.setInventory(inv); return inv; } else { List<String> data = new ArrayList<>(); for (String s : section.getKeys(false)) { String value = section.getString(s); data.add(value); } return Serialization.toInventory(data, number, maxSize, title); } }
/** * @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; }
ConfigurationSection section = disguisesConfig.getConfigurationSection("Disguises");
/** * Get the format for the given line of the hologram * @param line Line of the hologram * @param reqMap Values of the requirements that might be needed by the format (contains {@code null} if not comparable) * @param plaMap Values of the placeholders that might be needed by the format * @return The format of the first working option, or an empty String if no option is working * because of not fulfilled requirements */ public String getFormat(int line, Map<Requirement, Object> reqMap, Map<Placeholder, Object> plaMap) { ConfigurationSection options = config.getConfigurationSection("lines." + line + ".options"); optionLoop: for (String key : options.getKeys(false)) { ConfigurationSection option = options.getConfigurationSection(key); List<String> requirements = option.getStringList("requirements"); String format = option.getString("format"); for (String sReq : requirements) { for (Requirement req : reqMap.keySet()) { if (sReq.contains(req.toString())) { if (!evalRequirement(sReq, reqMap)) { continue optionLoop; } } } } return evalPlaceholder(format, plaMap); } return ""; }
private void loadGroups() { List<GroupData> groupData = new ArrayList<>(); for (String groupName : groups.getConfigurationSection("Groups").getKeys(false)) { GroupData data = new GroupData(); data.setGroupName(groupName); data.setPermission(groups.getString("Groups." + groupName + ".Permission", "nte.default")); data.setPrefix(groups.getString("Groups." + groupName + ".Prefix", "")); data.setSuffix(groups.getString("Groups." + groupName + ".Suffix", "")); data.setSortPriority(groups.getInt("Groups." + groupName + ".SortPriority", -1)); groupData.add(data); } handler.assignGroupData(groupData); }
SkyKit kit; try { kit = SkyKitDecoder.decodeKit(config.getConfigurationSection(key), key); } catch (SkyConfigurationException ex) { plugin.getLogger().log(Level.SEVERE, "Error loading kit! " + key + " won't be accessible until this is fixed!", ex);
} else { YamlConfiguration playerFile = getPlayerVaultFile(player.getUniqueId()); if (playerFile.getConfigurationSection("vault" + number) == null) { VaultHolder vaultHolder = new VaultHolder(number); if (EconomyOperations.payToCreate(player)) {
for (String partyName : partiesFile.getConfigurationSection("").getKeys(false)) { Party party = new Party(partyName);