From 3b1fbb1d44ec1401057814795a3125f1adab7143 Mon Sep 17 00:00:00 2001 From: mcmonkey4eva Date: Sat, 27 Sep 2014 13:16:07 -0700 Subject: [PATCH] Handle as_int error with a fallback gracefully as_int was previously not fallback-compatible as_double and as_money too --- .../java/net/aufdemrand/denizen/objects/Element.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/net/aufdemrand/denizen/objects/Element.java b/src/main/java/net/aufdemrand/denizen/objects/Element.java index d721af5641..38a371fc52 100644 --- a/src/main/java/net/aufdemrand/denizen/objects/Element.java +++ b/src/main/java/net/aufdemrand/denizen/objects/Element.java @@ -371,8 +371,8 @@ public String getAttribute(Attribute attribute) { try { return new Element(Double.valueOf(element)) .getAttribute(attribute.fulfill(1)); } catch (NumberFormatException e) { - dB.echoError("'" + element + "' is not a valid Double."); - return new Element("null").getAttribute(attribute.fulfill(1)); + if (!attribute.hasAlternative()) + dB.echoError("'" + element + "' is not a valid Double."); } // <--[tag] @@ -391,8 +391,8 @@ public String getAttribute(Attribute attribute) { return new Element(Math.round(Double.valueOf(element))) .getAttribute(attribute.fulfill(1)); } catch (NumberFormatException e) { - dB.echoError("'" + element + "' is not a valid Integer."); - return new Element("null").getAttribute(attribute.fulfill(1)); + if (!attribute.hasAlternative()) + dB.echoError("'" + element + "' is not a valid Integer."); } // <--[tag] @@ -409,8 +409,8 @@ public String getAttribute(Attribute attribute) { return new Element(d.format(Double.valueOf(element))) .getAttribute(attribute.fulfill(1)); } catch (NumberFormatException e) { - dB.echoError("'" + element + "' is not a valid number."); - return new Element("null").getAttribute(attribute.fulfill(1)); + if (!attribute.hasAlternative()) + dB.echoError("'" + element + "' is not a valid number."); } }