From 892855415b9bdde4d9484f100aee09c39da3d1de Mon Sep 17 00:00:00 2001 From: Camotoy <20743703+Camotoy@users.noreply.github.com> Date: Sat, 11 Dec 2021 16:05:12 -0500 Subject: [PATCH] Fix offset team colors Fixes #2674 --- core/pom.xml | 2 +- .../geyser/entity/type/player/PlayerEntity.java | 15 +++++---------- .../scoreboard/JavaSetPlayerTeamTranslator.java | 2 +- .../geyser/translator/text/MessageTranslator.java | 2 +- 4 files changed, 8 insertions(+), 13 deletions(-) diff --git a/core/pom.xml b/core/pom.xml index ec41b6d72..de264f908 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -155,7 +155,7 @@ com.github.GeyserMC MCProtocolLib - a991afe + c247b1f compile diff --git a/core/src/main/java/org/geysermc/geyser/entity/type/player/PlayerEntity.java b/core/src/main/java/org/geysermc/geyser/entity/type/player/PlayerEntity.java index 8737ef847..ac7d12717 100644 --- a/core/src/main/java/org/geysermc/geyser/entity/type/player/PlayerEntity.java +++ b/core/src/main/java/org/geysermc/geyser/entity/type/player/PlayerEntity.java @@ -47,17 +47,16 @@ import com.nukkitx.protocol.bedrock.packet.*; import lombok.Getter; import lombok.Setter; import net.kyori.adventure.text.Component; -import org.geysermc.geyser.text.ChatColor; -import org.geysermc.geyser.entity.type.Entity; import org.geysermc.geyser.entity.EntityDefinitions; +import org.geysermc.geyser.entity.type.Entity; import org.geysermc.geyser.entity.type.LivingEntity; import org.geysermc.geyser.entity.type.living.animal.tameable.ParrotEntity; -import org.geysermc.geyser.session.GeyserSession; -import org.geysermc.geyser.translator.text.MessageTranslator; import org.geysermc.geyser.scoreboard.Objective; import org.geysermc.geyser.scoreboard.Score; import org.geysermc.geyser.scoreboard.Team; import org.geysermc.geyser.scoreboard.UpdateType; +import org.geysermc.geyser.session.GeyserSession; +import org.geysermc.geyser.translator.text.MessageTranslator; import javax.annotation.Nullable; import java.util.Collections; @@ -352,16 +351,12 @@ public class PlayerEntity extends LivingEntity { if (team != null) { if (team.isVisibleFor(session.getPlayerEntity().getUsername())) { TeamColor color = team.getColor(); - String chatColor; - if (color == TeamColor.NONE) { - chatColor = ChatColor.RESET; - } else { - chatColor = MessageTranslator.toChatColor(color); - } + String chatColor = MessageTranslator.toChatColor(color);; // We have to emulate what modern Java text already does for us and add the color to each section String prefix = team.getCurrentData().getPrefix(); String suffix = team.getCurrentData().getSuffix(); newDisplayName = chatColor + prefix + chatColor + this.username + chatColor + suffix; + System.out.println(newDisplayName); } else { // The name is not visible to the session player; clear name newDisplayName = ""; diff --git a/core/src/main/java/org/geysermc/geyser/translator/protocol/java/scoreboard/JavaSetPlayerTeamTranslator.java b/core/src/main/java/org/geysermc/geyser/translator/protocol/java/scoreboard/JavaSetPlayerTeamTranslator.java index 5eba38196..5a0773bbe 100644 --- a/core/src/main/java/org/geysermc/geyser/translator/protocol/java/scoreboard/JavaSetPlayerTeamTranslator.java +++ b/core/src/main/java/org/geysermc/geyser/translator/protocol/java/scoreboard/JavaSetPlayerTeamTranslator.java @@ -72,7 +72,7 @@ public class JavaSetPlayerTeamTranslator extends PacketTranslator