diff --git a/src/main/java/net/aufdemrand/denizencore/objects/Element.java b/src/main/java/net/aufdemrand/denizencore/objects/Element.java index dc86acaa..82a06fb9 100644 --- a/src/main/java/net/aufdemrand/denizencore/objects/Element.java +++ b/src/main/java/net/aufdemrand/denizencore/objects/Element.java @@ -1299,10 +1299,44 @@ public String getAttribute(Attribute attribute) { } // <--[tag] - // @attribute ]> + // @attribute ]> // @returns Element(Decimal) // @group math // @description + // Returns the higher number: this element or the specified one. + // --> + if (attribute.startsWith("max") + && attribute.hasContext(1)) { + if (!isDouble()) { + dB.echoError("Element '" + element + "' is not a valid number!"); + return null; + } + return new Element(Math.max(asDouble(), new Element(attribute.getContext(1)).asDouble())) + .getAttribute(attribute.fulfill(1)); + } + + // <--[tag] + // @attribute ]> + // @returns Element(Decimal) + // @group math + // @description + // Returns the lower number: this element or the specified one. + // --> + if (attribute.startsWith("min") + && attribute.hasContext(1)) { + if (!isDouble()) { + dB.echoError("Element '" + element + "' is not a valid number!"); + return null; + } + return new Element(Math.min(asDouble(), new Element(attribute.getContext(1)).asDouble())) + .getAttribute(attribute.fulfill(1)); + } + + // <--[tag] + // @attribute ]> + // @returns Element(Number) + // @group math + // @description // Returns the element plus a number, using integer math. // --> if (attribute.startsWith("add_int") @@ -1317,7 +1351,7 @@ public String getAttribute(Attribute attribute) { // <--[tag] // @attribute ]> - // @returns Element(Decimal) + // @returns Element(Number) // @group math // @description // Returns the element divided by a number. @@ -1334,7 +1368,7 @@ public String getAttribute(Attribute attribute) { // <--[tag] // @attribute ]> - // @returns Element(Decimal) + // @returns Element(Number) // @group math // @description // Returns the element multiplied by a number. @@ -1351,7 +1385,7 @@ public String getAttribute(Attribute attribute) { // <--[tag] // @attribute ]> - // @returns Element(Decimal) + // @returns Element(Number) // @group math // @description // Returns the element minus a number.