3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-11-04 23:30:17 +01:00

Fix nameTagVisibility nullability

Dieser Commit ist enthalten in:
Camotoy 2023-03-14 07:44:52 -04:00
Ursprung 2436b2b1be
Commit 720c901535
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 7EEFB66FE798081F
2 geänderte Dateien mit 12 neuen und 2 gelöschten Zeilen

Datei anzeigen

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

Datei anzeigen

@ -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();