Fix player nametags always appearing

This commit is contained in:
Camotoy 2023-03-17 13:41:13 -04:00
parent acb25b0c99
commit 147618d5bc
No known key found for this signature in database
GPG key ID: 7EEFB66FE798081F
2 changed files with 9 additions and 10 deletions

View file

@ -33,9 +33,9 @@ import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.HashSet;
import java.util.Objects;
import java.util.Set;
@Getter
@ -46,7 +46,7 @@ public final class Team {
@Getter(AccessLevel.PACKAGE)
private final Set<String> entities;
@Setter @Nullable private NameTagVisibility nameTagVisibility;
@Nonnull private NameTagVisibility nameTagVisibility = NameTagVisibility.ALWAYS;
@Setter private TeamColor color;
private final TeamData currentData;
@ -189,11 +189,6 @@ public final class Team {
}
public boolean isVisibleFor(String entity) {
if (nameTagVisibility == null) {
// Null - normal behavior
return true;
}
return switch (nameTagVisibility) {
case HIDE_FOR_OTHER_TEAMS -> {
// Player must be in a team in order for HIDE_FOR_OTHER_TEAMS to be triggered
@ -206,8 +201,12 @@ public final class Team {
};
}
public NameTagVisibility getNameTagVisibility() {
return Objects.requireNonNullElse(this.nameTagVisibility, NameTagVisibility.ALWAYS);
public Team setNameTagVisibility(@Nullable NameTagVisibility nameTagVisibility) {
if (nameTagVisibility != null) {
// Null check like this (and this.nameTagVisibility defaults to ALWAYS) as of Java 1.19.4
this.nameTagVisibility = nameTagVisibility;
}
return this;
}
@Override

View file

@ -11,7 +11,7 @@ websocket = "1.5.1"
protocol = "2.9.17-20230217.002312-1"
raknet = "1.6.28-20220125.214016-6"
mcauthlib = "d9d773e"
mcprotocollib = "1.19.4-20230315.153350-3"
mcprotocollib = "1.19.4-20230317.173631-4"
adventure = "4.12.0-20220629.025215-9"
adventure-platform = "4.1.2"
junit = "5.9.2"