diff --git a/plugin/src/main/java/com/denizenscript/denizen/objects/EntityTag.java b/plugin/src/main/java/com/denizenscript/denizen/objects/EntityTag.java index 4ce44f74ab..31e60e87b0 100644 --- a/plugin/src/main/java/com/denizenscript/denizen/objects/EntityTag.java +++ b/plugin/src/main/java/com/denizenscript/denizen/objects/EntityTag.java @@ -610,6 +610,13 @@ public boolean isMonsterType() { return getBukkitEntity() instanceof Monster; } + public boolean isEnemyType() { + if (getBukkitEntity() == null && entity_type != null) { + return Enemy.class.isAssignableFrom(entity_type.getBukkitEntityType().getEntityClass()); + } + return getBukkitEntity() instanceof Enemy; + } + public boolean isMobType() { if (getBukkitEntity() == null && entity_type != null) { return Mob.class.isAssignableFrom(entity_type.getBukkitEntityType().getEntityClass()); @@ -2372,6 +2379,20 @@ else if (object.getBukkitEntity() instanceof Hanging hanging) { return new ElementTag(object.isMonsterType()); }); + if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_19)) { + + // <--[tag] + // @attribute + // @returns ElementTag(Boolean) + // @group data + // @description + // Returns whether the entity type is an enemy. See <@link url https://hub.spigotmc.org/javadocs/spigot/org/bukkit/entity/Enemy.html> + // --> + tagProcessor.registerTag(ElementTag.class, "is_enemy", (attribute, object) -> { + return new ElementTag(object.isEnemyType()); + }); + } + // <--[tag] // @attribute // @returns ElementTag(Boolean) @@ -4587,6 +4608,8 @@ public final boolean trySpecialEntityMatcher(String text, boolean isNPC) { return isMobType(); case "animal": return isAnimalType(); + case "enemy": + return isEnemyType(); } return false; }