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);
|
String displayName = wrapper.read(Type.STRING);
|
||||||
displayName = ChatRewriter.jsonTextToLegacy(displayName);
|
displayName = ChatRewriter.jsonTextToLegacy(displayName);
|
||||||
displayName = ChatUtil.removeUnusedColor(displayName, 'f');
|
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);
|
wrapper.write(Type.STRING, displayName);
|
||||||
|
|
||||||
byte flags = wrapper.read(Type.BYTE);
|
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);
|
if (prefix.endsWith("§")) prefix = prefix.substring(0, prefix.length() - 1);
|
||||||
|
|
||||||
String suffix = suffixComponent == null || suffixComponent.isJsonNull() ? "" : ChatRewriter.jsonTextToLegacy(suffixComponent.toString());
|
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.length() > 16) suffix = suffix.substring(0, 16);
|
||||||
if (suffix.endsWith("§")) suffix = suffix.substring(0, suffix.length() - 1);
|
if (suffix.endsWith("§")) suffix = suffix.substring(0, suffix.length() - 1);
|
||||||
|
|
||||||
wrapper.write(Type.STRING, prefix);
|
wrapper.write(Type.STRING, prefix);
|
||||||
wrapper.write(Type.STRING, suffix);
|
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);
|
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");
|
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) {
|
if (meta.getIndex() == 15) {
|
||||||
meta.getData().setId(16);
|
meta.getData().setId(16);
|
||||||
} else if (meta.getIndex() == 16) {
|
} else if (meta.getIndex() == 16) {
|
||||||
|
@ -12,6 +12,7 @@ public class ChatUtil {
|
|||||||
|
|
||||||
public static String removeUnusedColor(String legacy, char defaultColor, boolean isPrefix) {
|
public static String removeUnusedColor(String legacy, char defaultColor, boolean isPrefix) {
|
||||||
if (legacy == null) return null;
|
if (legacy == null) return null;
|
||||||
|
|
||||||
Pattern pattern = isPrefix ? UNUSED_COLOR_PATTERN_PREFIX : UNUSED_COLOR_PATTERN;
|
Pattern pattern = isPrefix ? UNUSED_COLOR_PATTERN_PREFIX : UNUSED_COLOR_PATTERN;
|
||||||
legacy = pattern.matcher(legacy).replaceAll("$1$2");
|
legacy = pattern.matcher(legacy).replaceAll("$1$2");
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
@ -22,10 +23,12 @@ public class ChatUtil {
|
|||||||
builder.append(current);
|
builder.append(current);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
current = legacy.charAt(++i);
|
current = legacy.charAt(++i);
|
||||||
if (current == last) continue;
|
if (current != last) {
|
||||||
builder.append('§').append(current);
|
builder.append('§').append(current);
|
||||||
last = current;
|
last = current;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return builder.toString();
|
return builder.toString();
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren