/** * Return a double value within given bounds, with preset. * * @param data * @param path * @param min * @param max * @param preset * @return */ public double getDouble(final String path, final double min, final double max, final double preset){ final double value = getDouble(path, preset); if (value < min) return min; else if (value > max) return max; else return value; }
/** * Return an int value within given bounds, with preset. * * @param data * @param path * @param min * @param max * @param preset * @return */ public long getInt(final String path, final int min, final int max, final int preset){ final int value = getInt(path, preset); if (value < min) return min; else if (value > max) return max; else return value; }
/** * Return a long value within given bounds, with preset. * * @param data * @param path * @param min * @param max * @param preset * @return */ public long getLong(final String path, final long min, final long max, final long preset){ final long value = getLong(path, preset); if (value < min) return min; else if (value > max) return max; else return value; }
/** * Short cut to set a value and the last changed build number. * <hr> * Performs set(path, value) and setLastChangedBuildNumber(path, * lastChangedBuildNumber). * * @param path * @param value * @param lastChangedBuildNumber */ public void set(String path, Object value, int lastChangedBuildNumber) { set(path, value); setLastChangedBuildNumber(path, lastChangedBuildNumber); }
ConfigurationSection section = config.getConfigurationSection(pathPrefix + ConfPaths.SUB_BREAKINGTIME); for (final String input : section.getKeys(false)) { try { for (final String input : config.getStringList(pathPrefix + ConfPaths.SUB_ALLOWINSTANTBREAK)) { final Material id = RawConfigFile.parseMaterial(input); if (id == null) { StaticLog.logWarning("Bad block id (" + pathPrefix + ConfPaths.SUB_ALLOWINSTANTBREAK + "): " + input); section = config.getConfigurationSection(pathPrefix + ConfPaths.SUB_OVERRIDEFLAGS); if (section != null) { final Map<String, Object> entries = section.getValues(false); for (final Entry<String, Object> entry : entries.entrySet()) { final String key = entry.getKey(); final Material id = RawConfigFile.parseMaterial(key); if (id == null) { StaticLog.logWarning("Bad block id (" + pathPrefix + ConfPaths.SUB_OVERRIDEFLAGS + "): " + key);
/** * Outputs warnings to console. * @param path * @param target Collection to fill materials into. */ public void readMaterialFromList(final String path, final Collection<Material> target) { final List<String> content = getStringList(path); if (content == null || content.isEmpty()) return; for (final String entry : content){ final Material mat = parseMaterial(entry); if (mat == null){ StaticLog.logWarning("Bad material entry (" + path +"): " + entry); } else{ target.add(mat); } } }
final ConfigurationSection section = getConfigurationSection(sectionPath); if (section == null) { if (allowDefault && !map.containsKey(null)) { final String path = sectionPath + "." + key; if (ucKey.equals("DEFAULT")) { defaultValue = getDouble(path, defaultValue); map.put(null, defaultValue); map.put(type, getDouble(path, defaultValue));
/** * Set a value depending on the detected Minecraft version. * @param path * @param cmpVersion The version to compare to (N.N.N). * @param valueLT Value to use if the detected version is smaller/less than the given one. * @param valueEQ Value to use if the detected version is equal to the given one. * @param valueGT Value to use if the detected version is greater than the detected one. * @param valueUnknown Value to use if the version could not be detected (e.g. unknown format). */ public void setVersionDependent(final String path, final String cmpVersion, final Object valueLT, final Object valueEQ, final Object valueGT, final Object valueUnknown) { set(path, ServerVersion.select(cmpVersion, valueLT, valueEQ, valueGT, valueUnknown)); }
public AlmostBoolean getAlmostBoolean(final String path, final AlmostBoolean defaultValue) { final AlmostBoolean choice = AlmostBoolean.match(getString(path, null)); return choice == null ? defaultValue : choice; }
/** * Attempt to get a Material from a string. * * @param content * @return */ public static Material parseMaterial(String content) { content = content.trim().toUpperCase(); try { // TODO: Custom lookup (both vanilla and Bukkit/Spigot). return Material.matchMaterial(prepareMatchMaterial(content)); } catch (Exception e) {} return null; }
/** * Translate AlmostBoolean to boolean directly. * * @param path * @param decideOptimistically * If to use decideOptimistically() instead of decide(). * @param trueForNotSet * In case the property is not set, return true if this is set. * @return */ public boolean getAlmostBoolean(final String path, final boolean decideOptimistically, final boolean trueForNotSet) { final AlmostBoolean ref = getAlmostBoolean(path, null); if (ref == null) { return trueForNotSet; } else if (decideOptimistically) { return ref.decideOptimistically(); } else { return ref.decide(); } }