Skip to content

Commit

Permalink
Add has_scoreboard_tag()
Browse files Browse the repository at this point in the history
  • Loading branch information
PseudoKnight committed Nov 11, 2024
1 parent 4259442 commit 5c98e12
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/main/java/com/laytonsmith/abstraction/MCEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ public interface MCEntity extends MCMetadatable {

Set<String> getScoreboardTags();

boolean hasScoreboardTag(String tag);

boolean addScoreboardTag(String tag);

boolean removeScoreboardTag(String tag);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,11 @@ public Set<String> getScoreboardTags() {
return e.getScoreboardTags();
}

@Override
public boolean hasScoreboardTag(String tag) {
return e.getScoreboardTags().contains(tag);
}

@Override
public boolean addScoreboardTag(String tag) {
return e.addScoreboardTag(tag);
Expand Down
25 changes: 25 additions & 0 deletions src/main/java/com/laytonsmith/core/functions/EntityManagement.java
Original file line number Diff line number Diff line change
Expand Up @@ -4590,6 +4590,31 @@ public Version since() {
}
}

@api(environments = {CommandHelperEnvironment.class})
public static class has_scoreboard_tag extends EntityGetterFunction {

@Override
public String getName() {
return "has_scoreboard_tag";
}

@Override
public String docs() {
return "boolean {entityUUID, tag} Returns whether this entity has a specific tag.";
}

@Override
public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException {
MCEntity e = Static.getEntity(args[0], t);
return CBoolean.get(e.hasScoreboardTag(args[1].val()));
}

@Override
public Version since() {
return MSVersion.V3_3_5;
}
}

@api(environments = {CommandHelperEnvironment.class})
public static class add_scoreboard_tag extends EntitySetterFunction {

Expand Down

0 comments on commit 5c98e12

Please sign in to comment.