use of fr.neatmonster.nocheatplus.worlds.IWorldDataManager in project NoCheatPlus by NoCheatPlus.
the class ConfigManager method isTrueForAnyConfig.
/**
* Check if any config has a boolean set to true for the given path.
* <hr/>
* NOTE: Check activation flags need a query to the WorldDataManager, as
* MAYBE typically means to activate, if the parent is active (checks <-
* check group <- check (<- sub check)).
*
* @param path
* @return True if any config has a boolean set to true for the given path.
*/
public static boolean isTrueForAnyConfig(String path) {
final IWorldDataManager worldMan = NCPAPIProvider.getNoCheatPlusAPI().getWorldDataManager();
final Iterator<Entry<String, IWorldData>> it = worldMan.getWorldDataIterator();
while (it.hasNext()) {
if (it.next().getValue().getRawConfiguration().getBoolean(path, false)) {
return true;
}
}
return false;
}
use of fr.neatmonster.nocheatplus.worlds.IWorldDataManager in project NoCheatPlus by NoCheatPlus.
the class ConfigManager method getMinNumberForAllConfigs.
/**
* Get the minimally found number for the given config path. This does not throw errors. It will return null, if nothing is found or all lookups failed otherwise.
* <br>
* Note: What happens with things like NaN is unspecified.
* @param path Config path.
* @return Value or null.
*/
public static Double getMinNumberForAllConfigs(final String path) {
Number min = null;
final IWorldDataManager worldMan = NCPAPIProvider.getNoCheatPlusAPI().getWorldDataManager();
final Iterator<Entry<String, IWorldData>> it = worldMan.getWorldDataIterator();
while (it.hasNext()) {
final ConfigFile config = it.next().getValue().getRawConfiguration();
try {
final Object obj = config.get(path);
if (obj instanceof Number) {
final Number num = (Number) obj;
if (min == null || num.doubleValue() < min.doubleValue()) {
min = num;
}
}
} catch (Throwable t) {
// Holzhammer
}
}
return min.doubleValue();
}
Aggregations