-
-
Notifications
You must be signed in to change notification settings - Fork 113
Add is_enemy tag #2837
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Add is_enemy tag #2837
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -100,6 +100,7 @@ public class EntityTag implements ObjectTag, Adjustable, EntityFormObject, Flagg | |
| // "projectile" plaintext: matches for any projectile type (arrow, trident, fish hook, snowball, etc). | ||
| // "hanging" plaintext: matches for any hanging type (painting, item_frame, etc). | ||
| // "monster" plaintext: matches for any monster type (creepers, zombies, etc). | ||
| // "enemy" plaintext: matches for any hostile entities (zombies, shulkers, ect). | ||
| // "animal" plaintext: matches for any animal type (pigs, cows, etc). | ||
| // "mob" plaintext: matches for any mob type (creepers, pigs, etc). | ||
| // "living" plaintext: matches for any living type (players, pigs, creepers, etc). | ||
|
|
@@ -610,6 +611,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; | ||
|
tal5 marked this conversation as resolved.
|
||
| } | ||
|
|
||
| public boolean isMobType() { | ||
| if (getBukkitEntity() == null && entity_type != null) { | ||
| return Mob.class.isAssignableFrom(entity_type.getBukkitEntityType().getEntityClass()); | ||
|
|
@@ -2372,6 +2380,20 @@ else if (object.getBukkitEntity() instanceof Hanging hanging) { | |
| return new ElementTag(object.isMonsterType()); | ||
| }); | ||
|
|
||
| if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_19)) { | ||
|
|
||
| // <--[tag] | ||
| // @attribute <EntityTag.is_enemy> | ||
| // @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> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure the link is necessary, unless you're referencing entities that Spigot defines as "enemies"? |
||
| // --> | ||
| tagProcessor.registerTag(ElementTag.class, "is_enemy", (attribute, object) -> { | ||
| return new ElementTag(object.isEnemyType()); | ||
| }); | ||
| } | ||
|
|
||
| // <--[tag] | ||
| // @attribute <EntityTag.is_mob> | ||
| // @returns ElementTag(Boolean) | ||
|
|
@@ -4587,6 +4609,8 @@ public final boolean trySpecialEntityMatcher(String text, boolean isNPC) { | |
| return isMobType(); | ||
| case "animal": | ||
| return isAnimalType(); | ||
| case "enemy": | ||
| return isEnemyType(); | ||
|
Comment on lines
+4612
to
+4613
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This needs documentation (the "matchers" section in the
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. did so, though I worry it's a little confusing. Monster is a subset of Enemy but they mostly sound like the same thing, and I'm not sure how to document it more clearly without just giving a list of entities included or excluded |
||
| } | ||
| return false; | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.