Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-26 16:12:42 +01:00
color rewriting changes
Dieser Commit ist enthalten in:
Ursprung
e6922eae46
Commit
437b02c961
@ -47,7 +47,8 @@ public class Protocol1_13To1_12_2 extends Protocol {
|
||||
}
|
||||
};
|
||||
|
||||
public static final PacketHandler SEND_DECLARE_COMMANDS_AND_TAGS = new PacketHandler() { // *insert here a good name*
|
||||
public static final PacketHandler SEND_DECLARE_COMMANDS_AND_TAGS =
|
||||
new PacketHandler() { // *insert here a good name*
|
||||
@Override
|
||||
public void handle(PacketWrapper w) throws Exception {
|
||||
// Send fake declare commands
|
||||
@ -99,27 +100,26 @@ public class Protocol1_13To1_12_2 extends Protocol {
|
||||
|
||||
// @formatter:off
|
||||
// These are arbitrary rewrite values, it just needs an invalid color code character.
|
||||
protected static EnumMap<ChatColor, String> SCOREBOARD_TEAM_NAME_REWRITE = new EnumMap<ChatColor, String>(ChatColor.class) {{
|
||||
put(ChatColor.BLACK, ChatColor.COLOR_CHAR + "g");
|
||||
put(ChatColor.DARK_BLUE, ChatColor.COLOR_CHAR + "h");
|
||||
put(ChatColor.DARK_GREEN, ChatColor.COLOR_CHAR + "i");
|
||||
put(ChatColor.DARK_AQUA, ChatColor.COLOR_CHAR + "j");
|
||||
put(ChatColor.DARK_RED, ChatColor.COLOR_CHAR + "p");
|
||||
put(ChatColor.DARK_PURPLE, ChatColor.COLOR_CHAR + "q");
|
||||
put(ChatColor.GOLD, ChatColor.COLOR_CHAR + "s");
|
||||
put(ChatColor.GRAY, ChatColor.COLOR_CHAR + "t");
|
||||
put(ChatColor.DARK_GRAY, ChatColor.COLOR_CHAR + "u");
|
||||
put(ChatColor.BLUE, ChatColor.COLOR_CHAR + "v");
|
||||
put(ChatColor.GREEN, ChatColor.COLOR_CHAR + "w");
|
||||
put(ChatColor.AQUA, ChatColor.COLOR_CHAR + "x");
|
||||
put(ChatColor.RED, ChatColor.COLOR_CHAR + "y");
|
||||
put(ChatColor.LIGHT_PURPLE, ChatColor.COLOR_CHAR + "z");
|
||||
put(ChatColor.YELLOW, ChatColor.COLOR_CHAR + "!");
|
||||
put(ChatColor.WHITE, ChatColor.COLOR_CHAR + "?");
|
||||
}};
|
||||
protected static EnumMap<ChatColor, Character> SCOREBOARD_TEAM_NAME_REWRITE = new EnumMap<>(ChatColor.class);
|
||||
// @formatter:on
|
||||
|
||||
static {
|
||||
SCOREBOARD_TEAM_NAME_REWRITE.put(ChatColor.BLACK, 'g');
|
||||
SCOREBOARD_TEAM_NAME_REWRITE.put(ChatColor.DARK_BLUE, 'h');
|
||||
SCOREBOARD_TEAM_NAME_REWRITE.put(ChatColor.DARK_GREEN, 'i');
|
||||
SCOREBOARD_TEAM_NAME_REWRITE.put(ChatColor.DARK_AQUA, 'j');
|
||||
SCOREBOARD_TEAM_NAME_REWRITE.put(ChatColor.DARK_RED, 'p');
|
||||
SCOREBOARD_TEAM_NAME_REWRITE.put(ChatColor.DARK_PURPLE, 'q');
|
||||
SCOREBOARD_TEAM_NAME_REWRITE.put(ChatColor.GOLD, 's');
|
||||
SCOREBOARD_TEAM_NAME_REWRITE.put(ChatColor.GRAY, 't');
|
||||
SCOREBOARD_TEAM_NAME_REWRITE.put(ChatColor.DARK_GRAY, 'u');
|
||||
SCOREBOARD_TEAM_NAME_REWRITE.put(ChatColor.BLUE, 'v');
|
||||
SCOREBOARD_TEAM_NAME_REWRITE.put(ChatColor.GREEN, 'w');
|
||||
SCOREBOARD_TEAM_NAME_REWRITE.put(ChatColor.AQUA, 'x');
|
||||
SCOREBOARD_TEAM_NAME_REWRITE.put(ChatColor.RED, 'y');
|
||||
SCOREBOARD_TEAM_NAME_REWRITE.put(ChatColor.LIGHT_PURPLE, 'z');
|
||||
SCOREBOARD_TEAM_NAME_REWRITE.put(ChatColor.YELLOW, '!');
|
||||
SCOREBOARD_TEAM_NAME_REWRITE.put(ChatColor.WHITE, '?');
|
||||
MappingData.init();
|
||||
}
|
||||
|
||||
@ -933,14 +933,13 @@ public class Protocol1_13To1_12_2 extends Protocol {
|
||||
// will just send colour as 'invisible' character
|
||||
if (ChatColor.stripColor(name).length() == 0) {
|
||||
StringBuilder newName = new StringBuilder();
|
||||
for (int i = 0; i < name.length() / 2; i++) {
|
||||
ChatColor color = ChatColor.getByChar(name.charAt(i * 2 + 1));
|
||||
String rewrite = SCOREBOARD_TEAM_NAME_REWRITE.get(color);
|
||||
if (rewrite != null) { // just in case, should never happen
|
||||
newName.append(rewrite);
|
||||
} else {
|
||||
newName.append(name);
|
||||
for (int i = 1; i < name.length(); i += 2) {
|
||||
char colorChar = name.charAt(i);
|
||||
Character rewrite = SCOREBOARD_TEAM_NAME_REWRITE.get(ChatColor.getByChar(colorChar));
|
||||
if (rewrite == null) {
|
||||
rewrite = colorChar;
|
||||
}
|
||||
newName.append('§').append(rewrite);
|
||||
}
|
||||
name = newName.toString();
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren