-
-
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 |
|---|---|---|
|
|
@@ -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; | ||
|
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. This line should be all that's required.
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. the |
||
| } | ||
|
|
||
| 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 <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 +4608,8 @@ public final boolean trySpecialEntityMatcher(String text, boolean isNPC) { | |
| return isMobType(); | ||
| case "animal": | ||
| return isAnimalType(); | ||
| case "enemy": | ||
| return isEnemyType(); | ||
| } | ||
| return false; | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this need to be a separate method and not part of the tag?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added to entity matcher to match similar tags