diff --git a/src/com/sk89q/worldguard/protection/ApplicableRegionSet.java b/src/com/sk89q/worldguard/protection/ApplicableRegionSet.java index 26794cd3..e89aba26 100644 --- a/src/com/sk89q/worldguard/protection/ApplicableRegionSet.java +++ b/src/com/sk89q/worldguard/protection/ApplicableRegionSet.java @@ -261,44 +261,56 @@ else if(appSize < 2) } + public String getAreaFlag(String name, String subname, String defaultValue, Boolean inherit, LocalPlayer player) + { + String data = getAreaFlag(name, subname, inherit, player); + return data != null ? data : defaultValue; + } + public Boolean getBooleanAreaFlag(String name, String subname, Boolean inherit, LocalPlayer player) { String data = getAreaFlag(name, subname, inherit, player); - if(data == null) - { - return null; - } - return Boolean.valueOf(data); + return data != null ? Boolean.valueOf(data) : null; + } + + public Boolean getBooleanAreaFlag(String name, String subname, boolean defaultValue, Boolean inherit, LocalPlayer player) + { + String data = getAreaFlag(name, subname, inherit, player); + return data != null ? Boolean.valueOf(data) : defaultValue; } public Integer getIntAreaFlag(String name, String subname, Boolean inherit, LocalPlayer player) { String data = getAreaFlag(name, subname, inherit, player); - if(data == null) - { - return null; - } - return Integer.valueOf(data); + return data != null ? Integer.valueOf(data) : null; + } + + public Integer getIntAreaFlag(String name, String subname, int defaultValue, Boolean inherit, LocalPlayer player) + { + String data = getAreaFlag(name, subname, inherit, player); + return data != null ? Integer.valueOf(data) : defaultValue; } public Float getFloatAreaFlag(String name, String subname, Boolean inherit, LocalPlayer player) { String data = getAreaFlag(name, subname, inherit, player); - if(data == null) - { - return null; - } - return Float.valueOf(data); + return data != null ? Float.valueOf(data) : null; } - public Double getDoubleAreaFlag(String name, String subname, Boolean inherit, LocalPlayer player) + public Float getFloatAreaFlag(String name, String subname, float defaultValue, Boolean inherit, LocalPlayer player) { String data = getAreaFlag(name, subname, inherit, player); - if(data == null) - { - return null; - } - return Double.valueOf(data); + return data != null ? Float.valueOf(data) : defaultValue; + } + + public Double getDoubleAreaFlag(String name, String subname, Boolean inherit, LocalPlayer player) { + String data = getAreaFlag(name, subname, inherit, player); + return data != null ? Double.valueOf(data) : null; + } + + public Double getDoubleAreaFlag(String name, String subname, double defaultValue, Boolean inherit, LocalPlayer player) { + String data = getAreaFlag(name, subname, inherit, player); + return data != null ? Double.valueOf(data) : defaultValue; } /** diff --git a/src/com/sk89q/worldguard/protection/regions/AreaFlags.java b/src/com/sk89q/worldguard/protection/regions/AreaFlags.java index de2f6edb..92d63638 100644 --- a/src/com/sk89q/worldguard/protection/regions/AreaFlags.java +++ b/src/com/sk89q/worldguard/protection/regions/AreaFlags.java @@ -234,46 +234,56 @@ public String getFlag(String name, String subname) return getFlagData(name).get(subname); } + public String getFlag(String name, String subname, String defaultValue) + { + String data = getFlagData(name).get(subname); + return data != null ? data : defaultValue; + } + public Boolean getBooleanFlag(String name, String subname) { String data = getFlagData(name).get(subname); - if(data == null) - { - return null; - } - return Boolean.valueOf(data); + return data != null ? Boolean.valueOf(data) : null; + } + + public Boolean getBooleanFlag(String name, String subname, boolean defaultValue) + { + String data = getFlagData(name).get(subname); + return data != null ? Boolean.valueOf(data) : defaultValue; } public Integer getIntFlag(String name, String subname) { String data = getFlagData(name).get(subname); - if(data == null) - { - return null; - } - return Integer.valueOf(data); + return data != null ? Integer.valueOf(data) : null; + } + + public Integer getIntFlag(String name, String subname, int defaultValue) + { + String data = getFlagData(name).get(subname); + return data != null ? Integer.valueOf(data) : defaultValue; } public Float getFloatFlag(String name, String subname) { String data = getFlagData(name).get(subname); - if(data == null) - { - return null; - } - return Float.valueOf(data); + return data != null ? Float.valueOf(data) : null; } - public Double getDoubleFlag(String name, String subname) + public Float getFloatFlag(String name, String subname, float defaultValue) { String data = getFlagData(name).get(subname); - if(data == null) - { - return null; - } - return Double.valueOf(data); + return data != null ? Float.valueOf(data) : defaultValue; } - + public Double getDoubleFlag(String name, String subname) { + String data = getFlagData(name).get(subname); + return data != null ? Double.valueOf(data) : null; + } + + public Double getDoubleFlag(String name, String subname, double defaultValue) { + String data = getFlagData(name).get(subname); + return data != null ? Double.valueOf(data) : defaultValue; + } }