diff --git a/plugin/src/main/java/com/denizenscript/denizen/objects/CuboidTag.java b/plugin/src/main/java/com/denizenscript/denizen/objects/CuboidTag.java index f3baf015e3..ec55c0d54b 100644 --- a/plugin/src/main/java/com/denizenscript/denizen/objects/CuboidTag.java +++ b/plugin/src/main/java/com/denizenscript/denizen/objects/CuboidTag.java @@ -1,5 +1,6 @@ package com.denizenscript.denizen.objects; +import com.denizenscript.denizen.events.BukkitScriptEvent; import com.denizenscript.denizen.objects.notable.NotableManager; import com.denizenscript.denizen.utilities.debugging.Debug; import com.denizenscript.denizen.utilities.depends.Depends; @@ -1487,35 +1488,23 @@ public static void registerTags() { } // <--[tag] - // @attribute |...)]> + // @attribute )]> // @returns ListTag(EntityTag) // @description - // Gets a list of all entities currently within the CuboidTag, with - // an optional search parameter for the entity type. + // Gets a list of all entities currently within the CuboidTag, with an optional search parameter for the entity. // --> registerTag("entities", (attribute, cuboid) -> { - ArrayList entities = new ArrayList<>(); - ListTag types = new ListTag(); - if (attribute.hasContext(1)) { - types = attribute.contextAsType(1, ListTag.class); - } + String matcher = attribute.hasContext(1) ? attribute.getContext(1) : null; + ListTag entities = new ListTag(); for (Entity ent : new WorldTag(cuboid.getWorld()).getEntitiesForTag()) { EntityTag current = new EntityTag(ent); if (cuboid.isInsideCuboid(ent.getLocation())) { - if (!types.isEmpty()) { - for (String type : types) { - if (current.identifySimpleType().equalsIgnoreCase(type)) { - entities.add(current); - break; - } - } - } - else { - entities.add(new EntityTag(ent)); + if (matcher == null || BukkitScriptEvent.tryEntity(current, matcher)) { + entities.addObject(new EntityTag(ent).getDenizenObject()); } } } - return new ListTag(entities); + return entities; }, "list_entities"); // <--[tag] diff --git a/plugin/src/main/java/com/denizenscript/denizen/objects/EllipsoidTag.java b/plugin/src/main/java/com/denizenscript/denizen/objects/EllipsoidTag.java index 9d66130fed..da5ee53f35 100644 --- a/plugin/src/main/java/com/denizenscript/denizen/objects/EllipsoidTag.java +++ b/plugin/src/main/java/com/denizenscript/denizen/objects/EllipsoidTag.java @@ -1,5 +1,6 @@ package com.denizenscript.denizen.objects; +import com.denizenscript.denizen.events.BukkitScriptEvent; import com.denizenscript.denizen.objects.notable.NotableManager; import com.denizenscript.denizen.utilities.debugging.Debug; import com.denizenscript.denizen.utilities.depends.Depends; @@ -671,34 +672,23 @@ else if (projZ >= projX && projZ >= projY) { } // <--[tag] - // @attribute |...)]> + // @attribute )]> // @returns ListTag(EntityTag) // @description - // Gets a list of all entities currently within the EllipsoidTag, with an optional search parameter for the entity type. + // Gets a list of all entities currently within the EllipsoidTag, with an optional search parameter for the entity. // --> registerTag("entities", (attribute, object) -> { - ArrayList entities = new ArrayList<>(); - ListTag types = new ListTag(); - if (attribute.hasContext(1)) { - types = attribute.contextAsType(1, ListTag.class); - } + String matcher = attribute.hasContext(1) ? attribute.getContext(1) : null; + ListTag entities = new ListTag(); for (Entity ent : new WorldTag(object.center.getWorld()).getEntitiesForTag()) { EntityTag current = new EntityTag(ent); if (object.contains(ent.getLocation())) { - if (!types.isEmpty()) { - for (String type : types) { - if (current.identifySimpleType().equalsIgnoreCase(type)) { - entities.add(current); - break; - } - } - } - else { - entities.add(new EntityTag(ent)); + if (matcher == null || BukkitScriptEvent.tryEntity(current, matcher)) { + entities.addObject(new EntityTag(ent).getDenizenObject()); } } } - return new ListTag(entities); + return entities; }); // <--[tag] diff --git a/plugin/src/main/java/com/denizenscript/denizen/objects/PlayerTag.java b/plugin/src/main/java/com/denizenscript/denizen/objects/PlayerTag.java index cd6c89548f..03567f7d9f 100644 --- a/plugin/src/main/java/com/denizenscript/denizen/objects/PlayerTag.java +++ b/plugin/src/main/java/com/denizenscript/denizen/objects/PlayerTag.java @@ -3298,6 +3298,7 @@ else if (getPlayerEntity().getGameMode() == GameMode.SPECTATOR) { // @input ItemTag // @description // Displays a book to a player. Must be a WRITTEN_BOOK item. + // For simple usage, consider specifying a book script name as the input. // --> if (mechanism.matches("show_book") && mechanism.requireObject(ItemTag.class)) { diff --git a/plugin/src/main/java/com/denizenscript/denizen/objects/PolygonTag.java b/plugin/src/main/java/com/denizenscript/denizen/objects/PolygonTag.java index a2d7504465..144f508094 100644 --- a/plugin/src/main/java/com/denizenscript/denizen/objects/PolygonTag.java +++ b/plugin/src/main/java/com/denizenscript/denizen/objects/PolygonTag.java @@ -1,5 +1,6 @@ package com.denizenscript.denizen.objects; +import com.denizenscript.denizen.events.BukkitScriptEvent; import com.denizenscript.denizen.objects.notable.NotableManager; import com.denizenscript.denizen.utilities.Settings; import com.denizenscript.denizen.utilities.debugging.Debug; @@ -610,35 +611,23 @@ public static void registerTags() { } // <--[tag] - // @attribute |...)]> + // @attribute )]> // @returns ListTag(EntityTag) // @description - // Gets a list of all entities currently within the PolygonTag, with - // an optional search parameter for the entity type. + // Gets a list of all entities currently within the PolygonTag, with an optional search parameter for the entity. // --> registerTag("entities", (attribute, polygon) -> { - ArrayList entities = new ArrayList<>(); - ListTag types = new ListTag(); - if (attribute.hasContext(1)) { - types = attribute.contextAsType(1, ListTag.class); - } + String matcher = attribute.hasContext(1) ? attribute.getContext(1) : null; + ListTag entities = new ListTag(); for (Entity ent : polygon.world.getEntitiesForTag()) { EntityTag current = new EntityTag(ent); if (polygon.doesContainLocation(ent.getLocation())) { - if (!types.isEmpty()) { - for (String type : types) { - if (current.identifySimpleType().equalsIgnoreCase(type)) { - entities.add(current); - break; - } - } - } - else { - entities.add(new EntityTag(ent)); + if (matcher == null || BukkitScriptEvent.tryEntity(current, matcher)) { + entities.addObject(new EntityTag(ent).getDenizenObject()); } } } - return new ListTag(entities); + return entities; }); // <--[tag]