diff --git a/src/main/java/net/aufdemrand/denizen/objects/Element.java b/src/main/java/net/aufdemrand/denizen/objects/Element.java index a515771abd..68c8f61953 100644 --- a/src/main/java/net/aufdemrand/denizen/objects/Element.java +++ b/src/main/java/net/aufdemrand/denizen/objects/Element.java @@ -241,11 +241,41 @@ public String getAttribute(Attribute attribute) { || attribute.startsWith("as_entity")) return dEntity.valueOf(element).getAttribute(attribute.fulfill(1)); + // <--[tag] + // @attribute + // @returns Element(Number) + // @description + // Rounds a decimal upward. + // --> + if (attribute.startsWith("round_up")) + try { + return new Element((int)Math.ceil(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)); + } + + // <--[tag] + // @attribute + // @returns Element(Number) + // @description + // Rounds a decimal downward. + // --> + if (attribute.startsWith("round_down")) + try { + return new Element((int)Math.floor(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)); + } + // <--[tag] // @attribute // @returns Element(Number) // @description - // Returns the element as a number without a decimal. Rounds up double values. + // Returns the element as a number without a decimal. Rounds double values. // --> if (attribute.startsWith("asint") || attribute.startsWith("as_int"))