/** * Retrieves a section as a list of maps. * * @param key the key to look up * @return the value as a list of maps */ @SuppressWarnings("unchecked") public List<Map<?, ?>> getMapList(Key key) { if (parameters.containsKey(key)) { return (List<Map<?, ?>>) parameters.get(key); } // there's no get or default method for the getMapList method, so using contains. if (!config.contains(key.path)) { parameters.put(key, key.def); return (List<Map<?, ?>>) key.def; } return config.getMapList(key.path); }
if (!config.contains(key.path)) { config.set(key.path, key.def); changed = true;
if (!config.contains(key.path)) { config.set(key.path, key.def); changed = true;
if (key.migrate == Migrate.BUKKIT && bukkit.contains(key.migratePath)) { config.set(key.path, bukkit.get(key.migratePath)); migrateStatus = true;
@Override public boolean has(String path) { return configFile.contains(path); }
@Override public boolean contains(Object file, String path) { return ((YamlConfiguration) file).contains(path); }
public boolean contains(String reference) { return config.contains(reference); }
@Override public void response(UUID uuid) { if (players.contains("Players." + uuid.toString())) { players.set("Players." + uuid.toString(), priority); save(players, playersFile); } } });
/** * Get text from the yml file for this locale * @param reference - the YAML node where the text is * @return Text for this locale reference or the reference if nothing has been found */ public String get(String reference) { if (config.contains(reference)) { return config.getString(reference); } return reference; // return reference in case nothing has been found }
public void removeValue(String path) { if (config.contains(path)) { logger.log(Level.INFO, "Removing deprecated value {0} in file {1}", new Object[]{path, configFile}); config.set(path, null); } }
/** * Checks if a vault exists. * * @param holder holder of the vault. * @param number vault number. * @return true if the vault file and vault number exist in that file, otherwise false. */ public boolean vaultExists(String holder, int number) { File file = new File(directory, holder + ".yml"); if (!file.exists()) { return false; } return getPlayerVaultFile(holder, true).contains(String.format(VAULTKEY, number)); }
/** * Checks if a vault exists. * * @param holder holder of the vault. * @param number vault number. * @return true if the vault file and vault number exist in that file, otherwise false. */ public boolean vaultExists(String holder, int number) { File file = new File(directory, holder + ".yml"); if (!file.exists()) { return false; } return getPlayerVaultFile(holder).contains("vault" + number); }
YamlConfiguration config = new YamlConfiguration(); File[] files = this.getDataFolder().listFiles(); for(File file : files){ try { config.load(file); if(config.contains("Path")){ //What you need to do. } } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (InvalidConfigurationException e) { e.printStackTrace(); } }
public long getSetLong(String path, long defaultInt) throws InvalidConfigurationException { if (config.isInt(path)) { return config.getLong(path); } else if (config.contains(path)) { throw new InvalidConfigurationException("Object " + config.get(path) + " found under " + path + " in file " + configFile.toAbsolutePath() + " is not a long"); } else { logger.log(Level.INFO, "Setting {0} to {1} in file {2}", new Object[]{path, defaultInt, configFile}); config.set(path, defaultInt); return defaultInt; } }
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; } }
/** * 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); }
/** * Paste clipboard at this location * @param location - location */ public void pasteClipboard(Location location) { if (blockConfig.contains(BLOCKS_YAML_PREFIX)) { paste(location.getWorld(), null, location, null); } else { plugin.logError("Clipboard has no block data in it to paste!"); } }
public int getSetInt(String path, int defaultInt) throws InvalidConfigurationException { if (config.isInt(path)) { return config.getInt(path); } else if (config.contains(path)) { throw new InvalidConfigurationException("Object " + config.get(path) + " found under " + path + " in file " + configFile.toAbsolutePath() + " is not an integer"); } else { logger.log(Level.INFO, "Setting {0} to {1} in file {2}", new Object[]{path, defaultInt, configFile}); config.set(path, defaultInt); return defaultInt; } }
public boolean getSetBoolean(String path, boolean defaultBoolean) throws InvalidConfigurationException { if (config.isBoolean(path)) { return config.getBoolean(path); } else if (config.contains(path)) { throw new InvalidConfigurationException("Object " + config.get(path) + " found under " + path + " in file " + configFile.toAbsolutePath() + " is not a boolean (true/false)"); } else { logger.log(Level.INFO, "Setting {0} to {1} in file {2}", new Object[]{path, defaultBoolean, configFile}); config.set(path, defaultBoolean); return defaultBoolean; } }
public static PlayerData fromFile(String key, YamlConfiguration file) { if (!file.contains("Players." + key)) return null; PlayerData data = new PlayerData(); data.setUuid(UUID.fromString(key)); data.setName(file.getString("Players." + key + ".Name")); data.setPrefix(file.getString("Players." + key + ".Prefix", "")); data.setSuffix(file.getString("Players." + key + ".Suffix", "")); data.setSortPriority(file.getInt("Players." + key + ".SortPriority", -1)); return data; }