From c59341049fb056743a49d0c885bedf12b7f91571 Mon Sep 17 00:00:00 2001 From: Bukkit/Spigot Date: Fri, 14 Jan 2011 23:38:40 -0800 Subject: [PATCH] Added Configuration.getBoolean(). By: sk89q --- .../org/bukkit/util/config/Configuration.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/paper-api/src/main/java/org/bukkit/util/config/Configuration.java b/paper-api/src/main/java/org/bukkit/util/config/Configuration.java index 7d37b06748..11303dac68 100644 --- a/paper-api/src/main/java/org/bukkit/util/config/Configuration.java +++ b/paper-api/src/main/java/org/bukkit/util/config/Configuration.java @@ -196,4 +196,24 @@ public class Configuration { return def; } } + + /** + * Gets a boolean at a location. This will either return an boolean + * or the default value. If the object at the particular location is not + * actually a boolean, the default value will be returned. + * + * @param path SK's dot notation supported + * @param def default value + * @return boolean or default + */ + public boolean getBoolean(String path, boolean def) { + Object o = getProperty(path); + if (o == null) { + return def; + } else if (o instanceof Boolean) { + return (Boolean)o; + } else { + return def; + } + } }