mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-12-23 15:00:37 +01:00
Fix nameTagVisibility nullability
This commit is contained in:
parent
2436b2b1be
commit
720c901535
2 changed files with 12 additions and 2 deletions
|
@ -858,7 +858,6 @@ public final class EntityDefinitions {
|
|||
{
|
||||
EntityDefinition<AbstractHorseEntity> 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)
|
||||
|
|
|
@ -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<String> 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();
|
||||
|
|
Loading…
Reference in a new issue