From 534d9b3f8c2a0950ea0df44cb19aecd20b75f284 Mon Sep 17 00:00:00 2001 From: "Alex \"mcmonkey\" Goodwin" Date: Wed, 31 Aug 2022 16:35:27 -0700 Subject: [PATCH] ColorTag.rgb_integer --- .../denizen/objects/ColorTag.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/plugin/src/main/java/com/denizenscript/denizen/objects/ColorTag.java b/plugin/src/main/java/com/denizenscript/denizen/objects/ColorTag.java index e0945fc621..aa83fa9ce4 100644 --- a/plugin/src/main/java/com/denizenscript/denizen/objects/ColorTag.java +++ b/plugin/src/main/java/com/denizenscript/denizen/objects/ColorTag.java @@ -279,6 +279,30 @@ public static void registerTags() { } }); + // <--[tag] + // @attribute + // @returns ElementTag(Number) + // @description + // Returns the Red, Green, and Blue values of this ColorTag as an integer number, equivalent to an integer reparse of <@link tag ColorTag.hex>. + // Highest order bits are red, then green, then lowest is blue. + // This is a rare special case encoding usually avoided by most systems, but may be necessary for some obscure tools. + // --> + tagProcessor.registerStaticTag(ElementTag.class, "rgb_integer", (attribute, object) -> { + return new ElementTag((object.red << 16) | (object.green << 8) | (object.blue)); + }); + + // <--[tag] + // @attribute + // @returns ElementTag(Number) + // @description + // Returns the Alpha, Red, Green, and Blue values of this ColorTag as an integer number, equivalent to an integer reparse of <@link tag ColorTag.hex>. + // Highest order bits are alpha, then red, then green, then lowest is blue. + // This is a rare special case encoding usually avoided by most systems, but may be necessary for some obscure tools. + // --> + tagProcessor.registerStaticTag(ElementTag.class, "argb_integer", (attribute, object) -> { + return new ElementTag(((long) object.alpha << 24L) | ((long) object.red << 16L) | ((long) object.green << 8L) | ((long) object.blue)); + }); + // <--[tag] // @attribute // @returns ElementTag(Number)