3
0
Mirror von https://github.com/ViaVersion/ViaBackwards.git synchronisiert 2024-12-26 16:12:43 +01:00

Don't remove white chatcolor in 1.13->1.12 suffix

Fixes #236
Dieser Commit ist enthalten in:
KennyTV 2020-07-26 09:28:06 +02:00
Ursprung 58256b5b64
Commit 831b8ad5ad
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 6BE3B555EBC5982B
3 geänderte Dateien mit 12 neuen und 6 gelöschten Zeilen

Datei anzeigen

@ -236,7 +236,9 @@ public class PlayerPacket1_13 extends Rewriter<Protocol1_12_2To1_13> {
String displayName = wrapper.read(Type.STRING);
displayName = ChatRewriter.jsonTextToLegacy(displayName);
displayName = ChatUtil.removeUnusedColor(displayName, 'f');
if (displayName.length() > 32) displayName = displayName.substring(0, 32);
if (displayName.length() > 32) {
displayName = displayName.substring(0, 32);
}
wrapper.write(Type.STRING, displayName);
byte flags = wrapper.read(Type.BYTE);
@ -261,9 +263,10 @@ public class PlayerPacket1_13 extends Rewriter<Protocol1_12_2To1_13> {
if (prefix.endsWith("§")) prefix = prefix.substring(0, prefix.length() - 1);
String suffix = suffixComponent == null || suffixComponent.isJsonNull() ? "" : ChatRewriter.jsonTextToLegacy(suffixComponent.toString());
suffix = ChatUtil.removeUnusedColor(suffix, 'f');
suffix = ChatUtil.removeUnusedColor(suffix, '\0'); // Don't remove white coloring
if (suffix.length() > 16) suffix = suffix.substring(0, 16);
if (suffix.endsWith("§")) suffix = suffix.substring(0, suffix.length() - 1);
wrapper.write(Type.STRING, prefix);
wrapper.write(Type.STRING, suffix);

Datei anzeigen

@ -91,7 +91,7 @@ public class EntityPackets1_16_2 extends EntityRewriter<Protocol1_16_1To1_16_2>
mapTypes(Entity1_16_2Types.EntityType.values(), Entity1_16Types.EntityType.class);
mapEntity(Entity1_16_2Types.EntityType.PIGLIN_BRUTE, Entity1_16_2Types.EntityType.PIGLIN).jsonName("Piglin Brute");
registerMetaHandler().filter(Entity1_16_2Types.EntityType.ABSTRACT_PIGLIN).handle(meta -> {
registerMetaHandler().filter(Entity1_16_2Types.EntityType.ABSTRACT_PIGLIN, true).handle(meta -> {
if (meta.getIndex() == 15) {
meta.getData().setId(16);
} else if (meta.getIndex() == 16) {

Datei anzeigen

@ -12,6 +12,7 @@ public class ChatUtil {
public static String removeUnusedColor(String legacy, char defaultColor, boolean isPrefix) {
if (legacy == null) return null;
Pattern pattern = isPrefix ? UNUSED_COLOR_PATTERN_PREFIX : UNUSED_COLOR_PATTERN;
legacy = pattern.matcher(legacy).replaceAll("$1$2");
StringBuilder builder = new StringBuilder();
@ -22,10 +23,12 @@ public class ChatUtil {
builder.append(current);
continue;
}
current = legacy.charAt(++i);
if (current == last) continue;
builder.append('§').append(current);
last = current;
if (current != last) {
builder.append('§').append(current);
last = current;
}
}
return builder.toString();
}