Mirror von
https://github.com/ViaVersion/ViaBackwards.git
synchronisiert 2024-09-07 13:22:54 +02:00
Ursprung
58256b5b64
Commit
831b8ad5ad
@ -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);
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -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();
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren