From 0496f281b7cc69df91af4deaaa13cfb046b8bf43 Mon Sep 17 00:00:00 2001 From: asofold Date: Sat, 26 Jul 2014 22:28:53 +0200 Subject: [PATCH] Add isTrueForAnyConfig, e.g. to check if to register listeners at all. --- .../nocheatplus/config/ConfigManager.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/config/ConfigManager.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/config/ConfigManager.java index 9ef30978..c6a81030 100644 --- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/config/ConfigManager.java +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/config/ConfigManager.java @@ -281,6 +281,20 @@ public class ConfigManager { ConfigManager.worldsMap = newWorldsMap; } + /** + * Check if any config has a boolean set to true for the given path. + * @param path + * @return True if any config has a boolean set to true for the given path. + */ + public static boolean isTrueForAnyConfig(String path) { + for (final ConfigFile cfg : worldsMap.values()){ + if (cfg.getBoolean(path, false)) { + return true; + } + } + return false; + } + /** * Get the maximally 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. *