3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-09-17 01:23:43 +02:00

Hotfix RGB Bungee legacy insertions

Fixes #1838
We should at some point completely remove the Bungee chat lib and handle everything with plain json ourselves
Dieser Commit ist enthalten in:
KennyTV 2020-06-25 09:57:26 +02:00
Ursprung 3ee94415a9
Commit f91ddb2521
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 6BE3B555EBC5982B
3 geänderte Dateien mit 41 neuen und 45 gelöschten Zeilen

Datei anzeigen

@ -44,35 +44,38 @@ public class ChatRewriter {
builder = new StringBuilder(); builder = new StringBuilder();
components.add(old); components.add(old);
} }
switch (format) { if (ChatColor.BOLD.equals(format)) {
case BOLD: component.setBold(true);
component.setBold(true); } else if (ChatColor.ITALIC.equals(format)) {
break; component.setItalic(true);
case ITALIC: } else if (ChatColor.UNDERLINE.equals(format)) {
component.setItalic(true); component.setUnderlined(true);
break; } else if (ChatColor.STRIKETHROUGH.equals(format)) {
case UNDERLINE: component.setStrikethrough(true);
component.setUnderlined(true); } else if (ChatColor.MAGIC.equals(format)) {
break; component.setObfuscated(true);
case STRIKETHROUGH: } else if (ChatColor.RESET.equals(format)) {
component.setStrikethrough(true); format = defaultColor;
break;
case MAGIC: component = new TextComponent();
component.setObfuscated(true); component.setColor(format);
break; // ViaVersion start
case RESET: component.setBold(false);
format = defaultColor; component.setItalic(false);
default: component.setUnderlined(false);
component = new TextComponent(); component.setStrikethrough(false);
component.setColor(format); component.setObfuscated(false);
// ViaVersion start // ViaVersion end
component.setBold(false); } else {
component.setItalic(false); component = new TextComponent();
component.setUnderlined(false); component.setColor(format);
component.setStrikethrough(false); // ViaVersion start
component.setObfuscated(false); component.setBold(false);
// ViaVersion end component.setItalic(false);
break; component.setUnderlined(false);
component.setStrikethrough(false);
component.setObfuscated(false);
// ViaVersion end
} }
continue; continue;
} }

Datei anzeigen

@ -1,5 +1,6 @@
package us.myles.ViaVersion.protocols.protocol1_13to1_12_2; package us.myles.ViaVersion.protocols.protocol1_13to1_12_2;
import com.google.common.collect.Sets;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import com.google.gson.JsonParseException; import com.google.gson.JsonParseException;
import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.ChatColor;
@ -40,8 +41,9 @@ import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.storage.TabCompleteTra
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld; import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
import us.myles.ViaVersion.util.GsonUtil; import us.myles.ViaVersion.util.GsonUtil;
import java.util.EnumMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Set;
public class Protocol1_13To1_12_2 extends Protocol<ClientboundPackets1_12_1, ClientboundPackets1_13, ServerboundPackets1_12_1, ServerboundPackets1_13> { public class Protocol1_13To1_12_2 extends Protocol<ClientboundPackets1_12_1, ClientboundPackets1_13, ServerboundPackets1_12_1, ServerboundPackets1_13> {
@ -111,7 +113,9 @@ public class Protocol1_13To1_12_2 extends Protocol<ClientboundPackets1_12_1, Cli
}; };
// These are arbitrary rewrite values, it just needs an invalid color code character. // These are arbitrary rewrite values, it just needs an invalid color code character.
protected static final EnumMap<ChatColor, Character> SCOREBOARD_TEAM_NAME_REWRITE = new EnumMap<>(ChatColor.class); protected static final Map<ChatColor, Character> SCOREBOARD_TEAM_NAME_REWRITE = new HashMap<>();
private static final Set<ChatColor> FORMATTING_CODES = Sets.newHashSet(ChatColor.MAGIC, ChatColor.BOLD, ChatColor.STRIKETHROUGH,
ChatColor.UNDERLINE, ChatColor.ITALIC, ChatColor.RESET);
static { static {
SCOREBOARD_TEAM_NAME_REWRITE.put(ChatColor.BLACK, 'g'); SCOREBOARD_TEAM_NAME_REWRITE.put(ChatColor.BLACK, 'g');
@ -1045,19 +1049,8 @@ public class Protocol1_13To1_12_2 extends Protocol<ClientboundPackets1_12_1, Cli
if (section == ChatColor.COLOR_CHAR && index < length - 1) { if (section == ChatColor.COLOR_CHAR && index < length - 1) {
char c = input.charAt(index + 1); char c = input.charAt(index + 1);
ChatColor color = ChatColor.getByChar(c); ChatColor color = ChatColor.getByChar(c);
if (color != null && !FORMATTING_CODES.contains(color)) {
if (color != null) { return color;
switch (color) {
case MAGIC:
case BOLD:
case STRIKETHROUGH:
case UNDERLINE:
case ITALIC:
case RESET:
break;
default:
return color;
}
} }
} }
} }

Datei anzeigen

@ -114,7 +114,7 @@
<dependency> <dependency>
<groupId>net.md-5</groupId> <groupId>net.md-5</groupId>
<artifactId>bungeecord-chat</artifactId> <artifactId>bungeecord-chat</artifactId>
<version>1.15-SNAPSHOT</version> <version>1.16-R0.2-SNAPSHOT</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>