From 720c90153585cb90020232c4007f4ac95677ed44 Mon Sep 17 00:00:00 2001 From: Camotoy <20743703+Camotoy@users.noreply.github.com> Date: Tue, 14 Mar 2023 07:44:52 -0400 Subject: [PATCH] Fix nameTagVisibility nullability --- .../geysermc/geyser/entity/EntityDefinitions.java | 1 - .../java/org/geysermc/geyser/scoreboard/Team.java | 13 ++++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/org/geysermc/geyser/entity/EntityDefinitions.java b/core/src/main/java/org/geysermc/geyser/entity/EntityDefinitions.java index 3271a962f..41a88f64f 100644 --- a/core/src/main/java/org/geysermc/geyser/entity/EntityDefinitions.java +++ b/core/src/main/java/org/geysermc/geyser/entity/EntityDefinitions.java @@ -858,7 +858,6 @@ public final class EntityDefinitions { { EntityDefinition abstractHorseEntityBase = EntityDefinition.inherited(AbstractHorseEntity::new, ageableEntityBase) .addTranslator(MetadataType.BYTE, AbstractHorseEntity::setHorseFlags) - .addTranslator(null) // UUID of owner .build(); CAMEL = EntityDefinition.inherited(CamelEntity::new, abstractHorseEntityBase) .type(EntityType.CAMEL) diff --git a/core/src/main/java/org/geysermc/geyser/scoreboard/Team.java b/core/src/main/java/org/geysermc/geyser/scoreboard/Team.java index 7738f5f42..b2e9043b5 100644 --- a/core/src/main/java/org/geysermc/geyser/scoreboard/Team.java +++ b/core/src/main/java/org/geysermc/geyser/scoreboard/Team.java @@ -33,7 +33,9 @@ import lombok.Getter; import lombok.Setter; import lombok.experimental.Accessors; +import javax.annotation.Nullable; import java.util.HashSet; +import java.util.Objects; import java.util.Set; @Getter @@ -44,7 +46,7 @@ public final class Team { @Getter(AccessLevel.PACKAGE) private final Set entities; - @Setter private NameTagVisibility nameTagVisibility; + @Setter @Nullable private NameTagVisibility nameTagVisibility; @Setter private TeamColor color; private final TeamData currentData; @@ -187,6 +189,11 @@ 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 @@ -199,6 +206,10 @@ public final class Team { }; } + public NameTagVisibility getNameTagVisibility() { + return Objects.requireNonNullElse(this.nameTagVisibility, NameTagVisibility.ALWAYS); + } + @Override public int hashCode() { return id.hashCode();