Fix offset team colors

Fixes #2674
This commit is contained in:
Camotoy 2021-12-11 16:05:12 -05:00
parent 9ba6ef51ac
commit 892855415b
No known key found for this signature in database
GPG key ID: 7EEFB66FE798081F
4 changed files with 8 additions and 13 deletions

View file

@ -155,7 +155,7 @@
<dependency> <dependency>
<groupId>com.github.GeyserMC</groupId> <groupId>com.github.GeyserMC</groupId>
<artifactId>MCProtocolLib</artifactId> <artifactId>MCProtocolLib</artifactId>
<version>a991afe</version> <version>c247b1f</version>
<scope>compile</scope> <scope>compile</scope>
<exclusions> <exclusions>
<exclusion> <exclusion>

View file

@ -47,17 +47,16 @@ import com.nukkitx.protocol.bedrock.packet.*;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import net.kyori.adventure.text.Component; 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.EntityDefinitions;
import org.geysermc.geyser.entity.type.Entity;
import org.geysermc.geyser.entity.type.LivingEntity; import org.geysermc.geyser.entity.type.LivingEntity;
import org.geysermc.geyser.entity.type.living.animal.tameable.ParrotEntity; 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.Objective;
import org.geysermc.geyser.scoreboard.Score; import org.geysermc.geyser.scoreboard.Score;
import org.geysermc.geyser.scoreboard.Team; import org.geysermc.geyser.scoreboard.Team;
import org.geysermc.geyser.scoreboard.UpdateType; import org.geysermc.geyser.scoreboard.UpdateType;
import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.translator.text.MessageTranslator;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.Collections; import java.util.Collections;
@ -352,16 +351,12 @@ public class PlayerEntity extends LivingEntity {
if (team != null) { if (team != null) {
if (team.isVisibleFor(session.getPlayerEntity().getUsername())) { if (team.isVisibleFor(session.getPlayerEntity().getUsername())) {
TeamColor color = team.getColor(); TeamColor color = team.getColor();
String chatColor; String chatColor = MessageTranslator.toChatColor(color);;
if (color == TeamColor.NONE) {
chatColor = ChatColor.RESET;
} else {
chatColor = MessageTranslator.toChatColor(color);
}
// We have to emulate what modern Java text already does for us and add the color to each section // 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 prefix = team.getCurrentData().getPrefix();
String suffix = team.getCurrentData().getSuffix(); String suffix = team.getCurrentData().getSuffix();
newDisplayName = chatColor + prefix + chatColor + this.username + chatColor + suffix; newDisplayName = chatColor + prefix + chatColor + this.username + chatColor + suffix;
System.out.println(newDisplayName);
} else { } else {
// The name is not visible to the session player; clear name // The name is not visible to the session player; clear name
newDisplayName = ""; newDisplayName = "";

View file

@ -72,7 +72,7 @@ public class JavaSetPlayerTeamTranslator extends PacketTranslator<ClientboundSet
if (packet.getPlayers().length != 0) { if (packet.getPlayers().length != 0) {
if ((team.getNameTagVisibility() != NameTagVisibility.ALWAYS && !team.isVisibleFor(session.getPlayerEntity().getUsername())) if ((team.getNameTagVisibility() != NameTagVisibility.ALWAYS && !team.isVisibleFor(session.getPlayerEntity().getUsername()))
|| team.getColor() != TeamColor.NONE || team.getColor() != TeamColor.RESET
|| !team.getCurrentData().getPrefix().isEmpty() || !team.getCurrentData().getPrefix().isEmpty()
|| !team.getCurrentData().getSuffix().isEmpty()) { || !team.getCurrentData().getSuffix().isEmpty()) {
// Something is here that would modify entity names // Something is here that would modify entity names

View file

@ -60,7 +60,7 @@ public class MessageTranslator {
private static final String RESET = BASE + "r"; private static final String RESET = BASE + "r";
static { static {
TEAM_COLORS.put(TeamColor.NONE, ""); TEAM_COLORS.put(TeamColor.RESET, RESET);
TEAM_COLORS.put(TeamColor.BLACK, BASE + "0"); TEAM_COLORS.put(TeamColor.BLACK, BASE + "0");
TEAM_COLORS.put(TeamColor.DARK_BLUE, BASE + "1"); TEAM_COLORS.put(TeamColor.DARK_BLUE, BASE + "1");