3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-11-20 06:50:09 +01:00

Fix offset team colors

Fixes #2674
Dieser Commit ist enthalten in:
Camotoy 2021-12-11 16:05:12 -05:00
Ursprung 9ba6ef51ac
Commit 892855415b
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 7EEFB66FE798081F
4 geänderte Dateien mit 8 neuen und 13 gelöschten Zeilen

Datei anzeigen

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

Datei anzeigen

@ -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 = "";

Datei anzeigen

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

Datei anzeigen

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