diff --git a/plugin/src/main/java/com/denizenscript/denizen/objects/AreaContainmentObject.java b/plugin/src/main/java/com/denizenscript/denizen/objects/AreaContainmentObject.java index 82562334e0..431309e804 100644 --- a/plugin/src/main/java/com/denizenscript/denizen/objects/AreaContainmentObject.java +++ b/plugin/src/main/java/com/denizenscript/denizen/objects/AreaContainmentObject.java @@ -190,14 +190,7 @@ static void registerTags(Class type, Objec // @description // Returns a boolean indicating whether the specified location is inside this area. // --> - processor.registerTag(ElementTag.class, "contains", (attribute, area) -> { - if (!attribute.hasParam()) { - return null; - } - LocationTag loc = attribute.paramAsType(LocationTag.class); - if (loc == null) { - return null; - } + processor.registerTag(ElementTag.class, LocationTag.class, "contains", (attribute, area, loc) -> { return new ElementTag(area.doesContainLocation(loc)); }, "contains_location"); @@ -253,11 +246,8 @@ static void registerTags(Class type, Objec // Gets a list of all block locations with a specified flag within the area. // Searches the internal flag lists, rather than through all possible blocks. // --> - processor.registerTag(ListTag.class, "blocks_flagged", (attribute, area) -> { - if (!attribute.hasParam()) { - return null; - } - return area.getBlocksFlagged(CoreUtilities.toLowerCase(attribute.getParam()), attribute); + processor.registerTag(ListTag.class, ElementTag.class, "blocks_flagged", (attribute, area, flagName) -> { + return area.getBlocksFlagged(CoreUtilities.toLowerCase(flagName.toString()), attribute); }); // <--[tag] @@ -276,14 +266,7 @@ static void registerTags(Class type, Objec // @description // Returns whether this area is fully inside another cuboid. // --> - processor.registerTag(ElementTag.class, "is_within", (attribute, area) -> { - if (!attribute.hasParam()) { - return null; - } - CuboidTag cub2 = attribute.paramAsType(CuboidTag.class); - if (cub2 == null) { - return null; - } + processor.registerTag(ElementTag.class, CuboidTag.class, "is_within", (attribute, area, cub2) -> { CuboidTag cuboid = area instanceof CuboidTag ? (CuboidTag) area : area.getCuboidBoundary(); if (cub2 != null) { boolean contains = true; @@ -319,14 +302,7 @@ static void registerTags(Class type, Objec // @description // Returns a copy of the area, with the specified world. // --> - processor.registerTag(type, "with_world", (attribute, area) -> { - if (!attribute.hasParam()) { - return null; - } - WorldTag world = attribute.paramAsType(WorldTag.class); - if (world == null) { - return null; - } + processor.registerTag(type, WorldTag.class, "with_world", (attribute, area, world) -> { return (T) area.withWorld(world); }); } diff --git a/plugin/src/main/java/com/denizenscript/denizen/objects/ChunkTag.java b/plugin/src/main/java/com/denizenscript/denizen/objects/ChunkTag.java index 0dac3878c8..8704761c62 100644 --- a/plugin/src/main/java/com/denizenscript/denizen/objects/ChunkTag.java +++ b/plugin/src/main/java/com/denizenscript/denizen/objects/ChunkTag.java @@ -290,12 +290,8 @@ public static void registerTags() { // @description // Returns the chunk with the specified coordinates added to it. // --> - tagProcessor.registerTag(ChunkTag.class, "add", (attribute, object) -> { - if (!attribute.hasParam()) { - attribute.echoError("The tag ChunkTag.add[<#>,<#>] must have a value."); - return null; - } - List coords = CoreUtilities.split(attribute.getParam(), ','); + tagProcessor.registerTag(ChunkTag.class, ElementTag.class, "add", (attribute, object, addCoords) -> { + List coords = CoreUtilities.split(addCoords.toString(), ','); if (coords.size() < 2) { attribute.echoError("The tag ChunkTag.add[<#>,<#>] requires two values!"); return null; @@ -317,12 +313,8 @@ public static void registerTags() { // @description // Returns the chunk with the specified coordinates subtracted from it. // --> - tagProcessor.registerTag(ChunkTag.class, "sub", (attribute, object) -> { - if (!attribute.hasParam()) { - attribute.echoError("The tag ChunkTag.add[<#>,<#>] must have a value."); - return null; - } - List coords = CoreUtilities.split(attribute.getParam(), ','); + tagProcessor.registerTag(ChunkTag.class, ElementTag.class, "sub", (attribute, object, subCoords) -> { + List coords = CoreUtilities.split(subCoords.toString(), ','); if (coords.size() < 2) { attribute.echoError("The tag ChunkTag.sub[<#>,<#>] requires two values!"); return null; @@ -644,16 +636,12 @@ public static void registerTags() { // Gets a list of all block locations with a specified flag within the CuboidTag. // Searches the internal flag lists, rather than through all possible blocks. // --> - tagProcessor.registerTag(ListTag.class, "blocks_flagged", (attribute, object) -> { - if (!attribute.hasParam()) { - attribute.echoError("ChunkTag.blocks_flagged[...] must have an input value."); - return null; - } + tagProcessor.registerTag(ListTag.class, ElementTag.class, "blocks_flagged", (attribute, object, flagNameInput) -> { Chunk chunk = object.getChunkForTag(attribute); if (chunk == null) { return null; } - String flagName = CoreUtilities.toLowerCase(attribute.getParam()); + String flagName = CoreUtilities.toLowerCase(flagNameInput.toString()); ListTag blocks = new ListTag(); LocationFlagSearchHelper.getFlaggedLocations(chunk, flagName, (loc) -> { blocks.addObject(new LocationTag(loc)); 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 eaf7f83f91..e0945fc621 100644 --- a/plugin/src/main/java/com/denizenscript/denizen/objects/ColorTag.java +++ b/plugin/src/main/java/com/denizenscript/denizen/objects/ColorTag.java @@ -475,15 +475,8 @@ public static void registerTags() { // @description // Returns the color that results if you mix this color with another. // --> - tagProcessor.registerTag(ColorTag.class, "mix", (attribute, object) -> { // Temporarily non-static because the input could be 'random' - ColorTag mixed_with = attribute.paramAsType(ColorTag.class); - if (mixed_with != null) { - return new ColorTag(object.mixWith(mixed_with)); - } - else { - Debug.echoError("'" + attribute.getParam() + "' is not a valid color!"); - return null; - } + tagProcessor.registerTag(ColorTag.class, ColorTag.class, "mix", (attribute, object, mixWith) -> { // Temporarily non-static because the input could be 'random' + return new ColorTag(object.mixWith(mixWith)); }); // <--[tag]