/** * Gets the numbers belonging to all their vaults. * * @param holder * @return a set of Integers, which are player's vaults' numbers (fuck grammar). */ public Set<Integer> getVaultNumbers(String holder) { Set<Integer> vaults = new HashSet<>(); YamlConfiguration file = getPlayerVaultFile(holder, true); if (file == null) { return vaults; } for (String s : file.getKeys(false)) { try { // vault% int number = Integer.valueOf(s.substring(4)); vaults.add(number); } catch (NumberFormatException e) { // silent } } return vaults; }
public void load(YamlConfiguration configuration, boolean cleanup) { int originNodes = map.size(); int updateNodes = 0; if (cleanup) { map.clear(); } for (String s : configuration.getKeys(true)) { boolean updated = false; Object value = configuration.get(s); if (value instanceof TLocaleSerialize) { updated = map.put(s, Collections.singletonList((TLocaleSerialize) value)) != null; } else if (value instanceof List && !((List) value).isEmpty()) { if (isListString((List) value)) { updated = map.put(s, Collections.singletonList(TLocaleText.of(value))) != null; } else { updated = map.put(s, ((List<?>) value).stream().map(o -> o instanceof TLocaleSerialize ? (TLocaleSerialize) o : TLocaleText.of(String.valueOf(o))).collect(Collectors.toList())) != null; } } else if (!(value instanceof ConfigurationSection)) { String str = String.valueOf(value); updated = map.put(s, Collections.singletonList(str.length() == 0 ? TLocaleSerialize.getEmpty() : TLocaleText.of(str))) != null; } if (updated) { updateNodes++; } } latestUpdateNodes.set(originNodes - updateNodes); } }
/** * Merges a language YAML file to this locale * @param toBeMerged the YamlConfiguration of the language file */ public void merge(YamlConfiguration toBeMerged) { for (String key : toBeMerged.getKeys(true)) { if (!key.startsWith("meta") && !config.contains(key)) { config.set(key, toBeMerged.get(key)); } } updateAuthors(toBeMerged); }
private static boolean process(YamlConfiguration defaults, ConfigurationSection section, boolean addOnlyIfEmpty, boolean removeObsolete) { boolean modified = false; Set<String> present = section.getKeys(true); Set<String> required = defaults.getKeys(true); if (!addOnlyIfEmpty || present.isEmpty()) { for (String req : required) { if (!present.remove(req)) { section.set(req, defaults.get(req)); modified = true; } } } if (removeObsolete) { for (String obs : present) { section.set(obs, null); modified = true; } } return modified; }
TemplateStore read() { YamlConfiguration yaml = new YamlConfiguration(); try { File file = new File(plugin.getDataFolder(), TemplateStore.FILENAME); if (!file.exists()) { plugin.getLogger().info(TemplateStore.FILENAME + " not found, creating default..."); plugin.saveResource(TemplateStore.FILENAME, false); } yaml.load(file); } catch (InvalidConfigurationException e) { throw new IllegalStateException(TemplateStore.FILENAME + " is invalid!", e); } catch (FileNotFoundException e) { throw new IllegalStateException(TemplateStore.FILENAME + " is missing!", e); } catch (IOException e) { throw new IllegalStateException(e); } Map<String, Template> map = new HashMap<>(); for (String key : yaml.getKeys(false)) { validateTemplateNode(key, yaml); String templateId = stripStateSuffix(key); map.computeIfAbsent(templateId, id -> loadTemplate(id, yaml)); } plugin.getLogger().info("Loaded " + map.size() + " sign templates."); return new TemplateStore(map); }
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); } }
public DiscountModule() { config = YamlConfiguration.loadConfiguration(ChestShop.loadFile("discounts.yml")); config.options().header("This file is for discount management. You are able to do that:\n" + "group1: 75\n" + "That means that the person with ChestShop.discount.group1 permission will pay only 75% of the price. \n" + "For example, if the price is 100 dollars, the player pays only 75 dollars.\n" + "(Only works in buy-only Admin Shops!)"); try { config.save(ChestShop.loadFile("discounts.yml")); } catch (IOException e) { e.printStackTrace(); } groupList = config.getKeys(false); }
/** * Check if the location given is a sign, and if so, remove it from the signs.yml file * * @param location The location to check */ public void blockChangeCheck(Location location) { if (plugin.getSigns().getKeys(false).isEmpty()) { return; // Save us a check. } String world = location.getWorld().getName(); int x = location.getBlockX(); int y = location.getBlockY(); int z = location.getBlockZ(); if (plugin.getSigns().getKeys(false).contains(world + ";;" + x + ";;" + y + ";;" + z)) { plugin.getSigns().set(world + ";;" + x + ";;" + y + ";;" + z, null); plugin.saveSigns(); } }
Collection<String> allKeys = currentConfig.getKeys(true); for (String key : allKeys) { Object defaultValue = defaultConfig.get(key); int originalTopSize = currentConfig.getKeys(false).size(); int cleanTopSize = cleanConfig.getKeys(false).size(); int cleanSize = cleanConfig.getKeys(true).size(); int removedCount = allKeys.size() - cleanSize; if (removedCount > 0) {
String sanitizedEntityName = entityName.replace(".", "_"); if (entitiesFile.getKeys(false).contains(sanitizedEntityName)) { return;
for (String key : config.getKeys(false)) { if (key.equals("configuration-version")) continue; if (config.isConfigurationSection(key)) {
for (String key : this.getSource().getKeys(true)) { Object value = this.getSource().get(key); if (value instanceof String) {
int dupes = 0; for (String key : config.getKeys(false)) { String value = config.getString(key);
} else { StringBuilder sb = new StringBuilder(); for (String key : file.getKeys(false)) { sb.append(key.replace("vault", "")).append(" ");
info("Loading image map data from " + configurationFile.getName()); configuration.load(configurationFile); Set<String> maps = configuration.getKeys(false); boolean needsUpdate = false; for (String mapIdString : maps) {
int y = l.getBlockY(); int z = l.getBlockZ(); if (plugin.getSigns().getKeys(false).contains(world + ";;" + x + ";;" + y + ";;" + z)) { int num = PlayerVaults.getInstance().getSigns().getInt(world + ";;" + x + ";;" + y + ";;" + z + ".chest", 1); if (player.hasPermission("playervaults.signs.use") || player.hasPermission("playervaults.signs.bypass")) {