Skip to content

Add is_enemy tag#2837

Open
creaturesofhabit wants to merge 2 commits into
DenizenScript:devfrom
creaturesofhabit:is_enemy
Open

Add is_enemy tag#2837
creaturesofhabit wants to merge 2 commits into
DenizenScript:devfrom
creaturesofhabit:is_enemy

Conversation

@creaturesofhabit

@creaturesofhabit creaturesofhabit commented Jul 22, 2026

Copy link
Copy Markdown

For this thread, adds the 1.19+ is_enemy tag to return if the entity is in spigot's enemy interface

@MC-Samuel MC-Samuel left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very good for your first PR!

return getBukkitEntity() instanceof Monster;
}

public boolean isEnemyType() {

Copy link
Copy Markdown
Contributor

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?

Copy link
Copy Markdown
Author

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

if (getBukkitEntity() == null && entity_type != null) {
return Enemy.class.isAssignableFrom(entity_type.getBukkitEntityType().getEntityClass());
}
return getBukkitEntity() instanceof Enemy;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line should be all that's required.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the entity_type check allows unspawned entities (eg, <entity[zombie].is_enemy>) to check correctly when getBukkitEntity() is null

// @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>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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"?

This also requires/justifies the seperate method
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants