mirror of
https://github.com/ViaVersion/ViaVersion.git
synced 2024-11-22 18:15:39 +01: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
This commit is contained in:
parent
3ee94415a9
commit
f91ddb2521
@ -44,35 +44,38 @@ public class ChatRewriter {
|
||||
builder = new StringBuilder();
|
||||
components.add(old);
|
||||
}
|
||||
switch (format) {
|
||||
case BOLD:
|
||||
component.setBold(true);
|
||||
break;
|
||||
case ITALIC:
|
||||
component.setItalic(true);
|
||||
break;
|
||||
case UNDERLINE:
|
||||
component.setUnderlined(true);
|
||||
break;
|
||||
case STRIKETHROUGH:
|
||||
component.setStrikethrough(true);
|
||||
break;
|
||||
case MAGIC:
|
||||
component.setObfuscated(true);
|
||||
break;
|
||||
case RESET:
|
||||
format = defaultColor;
|
||||
default:
|
||||
component = new TextComponent();
|
||||
component.setColor(format);
|
||||
// ViaVersion start
|
||||
component.setBold(false);
|
||||
component.setItalic(false);
|
||||
component.setUnderlined(false);
|
||||
component.setStrikethrough(false);
|
||||
component.setObfuscated(false);
|
||||
// ViaVersion end
|
||||
break;
|
||||
if (ChatColor.BOLD.equals(format)) {
|
||||
component.setBold(true);
|
||||
} else if (ChatColor.ITALIC.equals(format)) {
|
||||
component.setItalic(true);
|
||||
} else if (ChatColor.UNDERLINE.equals(format)) {
|
||||
component.setUnderlined(true);
|
||||
} else if (ChatColor.STRIKETHROUGH.equals(format)) {
|
||||
component.setStrikethrough(true);
|
||||
} else if (ChatColor.MAGIC.equals(format)) {
|
||||
component.setObfuscated(true);
|
||||
} else if (ChatColor.RESET.equals(format)) {
|
||||
format = defaultColor;
|
||||
|
||||
component = new TextComponent();
|
||||
component.setColor(format);
|
||||
// ViaVersion start
|
||||
component.setBold(false);
|
||||
component.setItalic(false);
|
||||
component.setUnderlined(false);
|
||||
component.setStrikethrough(false);
|
||||
component.setObfuscated(false);
|
||||
// ViaVersion end
|
||||
} else {
|
||||
component = new TextComponent();
|
||||
component.setColor(format);
|
||||
// ViaVersion start
|
||||
component.setBold(false);
|
||||
component.setItalic(false);
|
||||
component.setUnderlined(false);
|
||||
component.setStrikethrough(false);
|
||||
component.setObfuscated(false);
|
||||
// ViaVersion end
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package us.myles.ViaVersion.protocols.protocol1_13to1_12_2;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParseException;
|
||||
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.util.GsonUtil;
|
||||
|
||||
import java.util.EnumMap;
|
||||
import java.util.HashMap;
|
||||
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> {
|
||||
|
||||
@ -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.
|
||||
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 {
|
||||
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) {
|
||||
char c = input.charAt(index + 1);
|
||||
ChatColor color = ChatColor.getByChar(c);
|
||||
|
||||
if (color != null) {
|
||||
switch (color) {
|
||||
case MAGIC:
|
||||
case BOLD:
|
||||
case STRIKETHROUGH:
|
||||
case UNDERLINE:
|
||||
case ITALIC:
|
||||
case RESET:
|
||||
break;
|
||||
default:
|
||||
return color;
|
||||
}
|
||||
if (color != null && !FORMATTING_CODES.contains(color)) {
|
||||
return color;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user