Throw away Bungee Chat

This commit is contained in:
KennyTV 2020-11-24 10:56:24 +01:00
parent 70b4e74b52
commit ea59ab372e
No known key found for this signature in database
GPG Key ID: 6BE3B555EBC5982B
11 changed files with 31 additions and 36 deletions

View File

@ -1,6 +1,6 @@
object Versions {
// ViaVersion
const val viaversion = "3.3.0-21w08a-gradle"
const val viaversion = "3.3.0-21w08b"
// Common
const val netty = "4.0.20.Final"

View File

@ -1,7 +1,6 @@
package nl.matsv.viabackwards.api.data;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ChatRewriter;
import us.myles.viaversion.libs.bungeecordchat.api.ChatColor;
public class MappedItem {
@ -10,7 +9,7 @@ public class MappedItem {
public MappedItem(int id, String name) {
this.id = id;
this.jsonName = ChatRewriter.legacyTextToJson(ChatColor.RESET + name).toString();
this.jsonName = ChatRewriter.legacyTextToJsonString(name);
}
public int getId() {

View File

@ -2,7 +2,6 @@ package nl.matsv.viabackwards.api.data;
import nl.matsv.viabackwards.utils.Block;
import org.jetbrains.annotations.Nullable;
import us.myles.viaversion.libs.bungeecordchat.api.ChatColor;
import us.myles.viaversion.libs.opennbt.tag.builtin.CompoundTag;
public class MappedLegacyBlockItem {
@ -16,7 +15,7 @@ public class MappedLegacyBlockItem {
public MappedLegacyBlockItem(int id, short data, @Nullable String name, boolean block) {
this.id = id;
this.data = data;
this.name = name != null ? ChatColor.RESET + name : null;
this.name = name != null ? "§r" + name : null;
this.block = block ? new Block(id, data) : null;
}

View File

@ -20,7 +20,6 @@ import us.myles.ViaVersion.api.minecraft.chunks.Chunk;
import us.myles.ViaVersion.api.minecraft.chunks.ChunkSection;
import us.myles.ViaVersion.api.minecraft.item.Item;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ChatRewriter;
import us.myles.viaversion.libs.bungeecordchat.api.ChatColor;
import us.myles.viaversion.libs.fastutil.ints.Int2ObjectMap;
import us.myles.viaversion.libs.fastutil.ints.Int2ObjectOpenHashMap;
import us.myles.viaversion.libs.gson.JsonElement;
@ -240,7 +239,7 @@ public abstract class LegacyBlockItemRewriter<T extends BackwardsProtocol> exten
protected CompoundTag getNamedTag(String text) {
CompoundTag tag = new CompoundTag("");
tag.put(new CompoundTag("display"));
text = ChatColor.RESET + text;
text = "§r" + text;
((CompoundTag) tag.get("display")).put(new StringTag("Name", jsonNameFormat ? ChatRewriter.legacyTextToJson(text).toString() : text));
return tag;
}

View File

@ -33,7 +33,6 @@ import us.myles.ViaVersion.protocols.protocol1_9_1_2to1_9_3_4.types.Chunk1_9_3_4
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3;
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3;
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
import us.myles.viaversion.libs.bungeecordchat.api.ChatColor;
import us.myles.viaversion.libs.opennbt.tag.builtin.CompoundTag;
import us.myles.viaversion.libs.opennbt.tag.builtin.ListTag;
import us.myles.viaversion.libs.opennbt.tag.builtin.StringTag;
@ -449,7 +448,7 @@ public class BlockItemPackets1_11 extends LegacyBlockItemRewriter<Protocol1_10To
int endNonExistingFormula = 2 + 3 * (storage.isChested() ? 5 : 0);
if (slotId >= startNonExistingFormula && slotId < endNonExistingFormula)
return new Item(166, (byte) 1, (short) 0, getNamedTag(ChatColor.RED + "SLOT DISABLED"));
return new Item(166, (byte) 1, (short) 0, getNamedTag("§4SLOT DISABLED"));
if (slotId == 1)
return null;
return current;

View File

@ -17,11 +17,10 @@ import us.myles.ViaVersion.api.remapper.ValueTransformer;
import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3;
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3;
import us.myles.viaversion.libs.bungeecordchat.api.chat.BaseComponent;
import us.myles.viaversion.libs.bungeecordchat.api.chat.TextComponent;
import us.myles.viaversion.libs.bungeecordchat.chat.ComponentSerializer;
import us.myles.viaversion.libs.gson.JsonElement;
import us.myles.viaversion.libs.gson.JsonObject;
import us.myles.viaversion.libs.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
import us.myles.viaversion.libs.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
public class PlayerPackets1_11 {
private static final ValueTransformer<Short, Float> TO_NEW_FLOAT = new ValueTransformer<Short, Float>(Type.FLOAT) {
@ -47,8 +46,7 @@ public class PlayerPackets1_11 {
wrapper.setId(ClientboundPackets1_9_3.CHAT_MESSAGE.ordinal());
// https://bugs.mojang.com/browse/MC-119145to
BaseComponent[] parsed = ComponentSerializer.parse(message.toString());
String legacy = TextComponent.toLegacyText(parsed);
String legacy = LegacyComponentSerializer.legacySection().serialize(GsonComponentSerializer.gson().deserialize(message.toString()));
message = new JsonObject();
message.getAsJsonObject().addProperty("text", legacy);

View File

@ -17,7 +17,6 @@ import us.myles.ViaVersion.api.data.StoredObject;
import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.protocols.protocol1_9to1_8.Protocol1_9To1_8;
import us.myles.viaversion.libs.bungeecordchat.api.ChatColor;
public class ShoulderTracker extends StoredObject {
private int entityId;
@ -48,26 +47,28 @@ public class ShoulderTracker extends StoredObject {
// Empty spaces because the non-json formatting is weird
builder.append(" ");
if (leftShoulder == null)
builder.append(ChatColor.RED).append(ChatColor.BOLD).append("Nothing");
else
builder.append(ChatColor.DARK_GREEN).append(ChatColor.BOLD).append(getName(leftShoulder));
if (leftShoulder == null) {
builder.append("§4§lNothing");
} else {
builder.append("§2§l").append(getName(leftShoulder));
}
builder.append(ChatColor.DARK_GRAY).append(ChatColor.BOLD).append(" <- ")
.append(ChatColor.GRAY).append(ChatColor.BOLD).append("Shoulders")
.append(ChatColor.DARK_GRAY).append(ChatColor.BOLD).append(" -> ");
builder.append("§8§l <- §7§lShoulders§8§l -> ");
if (rightShoulder == null)
builder.append(ChatColor.RED).append(ChatColor.BOLD).append("Nothing");
else
builder.append(ChatColor.DARK_GREEN).append(ChatColor.BOLD).append(getName(rightShoulder));
if (rightShoulder == null) {
builder.append("§4§lNothing");
} else {
builder.append("§2§l").append(getName(rightShoulder));
}
return builder.toString();
}
private String getName(String current) {
if (current.startsWith("minecraft:"))
if (current.startsWith("minecraft:")) {
current = current.substring(10);
}
String[] array = current.split("_");
StringBuilder builder = new StringBuilder();

View File

@ -576,7 +576,7 @@ public class BlockItemPackets1_13 extends nl.matsv.viabackwards.api.rewriters.It
StringTag name = display.get("Name");
if (name instanceof StringTag) {
display.put(new StringTag(extraNbtTag + "|Name", name.getValue()));
name.setValue(ChatRewriter.jsonTextToLegacy(name.getValue()));
name.setValue(ChatRewriter.jsonToLegacyText(name.getValue()));
}
}
@ -777,7 +777,7 @@ public class BlockItemPackets1_13 extends nl.matsv.viabackwards.api.rewriters.It
StringTag name = displayTag.get("Name");
if (name instanceof StringTag) {
StringTag via = displayTag.remove(extraNbtTag + "|Name");
name.setValue(via != null ? via.getValue() : ChatRewriter.legacyTextToJson(name.getValue()).toString());
name.setValue(via != null ? via.getValue() : ChatRewriter.legacyTextToJsonString(name.getValue()));
}
}

View File

@ -325,7 +325,7 @@ public class EntityPackets1_13 extends LegacyEntityRewriter<Protocol1_12_2To1_13
Metadata meta = e.getData();
String value = meta.getValue().toString();
if (value.isEmpty()) return meta;
meta.setValue(ChatRewriter.jsonTextToLegacy(value));
meta.setValue(ChatRewriter.jsonToLegacyText(value));
return meta;
});

View File

@ -208,7 +208,7 @@ public class PlayerPacket1_13 extends Rewriter<Protocol1_12_2To1_13> {
byte mode = wrapper.get(Type.BYTE, 0);
if (mode == 0 || mode == 2) {
String value = wrapper.read(Type.COMPONENT).toString();
value = ChatRewriter.jsonTextToLegacy(value);
value = ChatRewriter.jsonToLegacyText(value);
if (value.length() > 32) {
value = value.substring(0, 32);
}
@ -233,7 +233,7 @@ public class PlayerPacket1_13 extends Rewriter<Protocol1_12_2To1_13> {
byte action = wrapper.get(Type.BYTE, 0);
if (action == 0 || action == 2) {
String displayName = wrapper.read(Type.STRING);
displayName = ChatRewriter.jsonTextToLegacy(displayName);
displayName = ChatRewriter.jsonToLegacyText(displayName);
displayName = ChatUtil.removeUnusedColor(displayName, 'f');
if (displayName.length() > 32) {
displayName = displayName.substring(0, 32);
@ -252,7 +252,7 @@ public class PlayerPacket1_13 extends Rewriter<Protocol1_12_2To1_13> {
JsonElement prefixComponent = wrapper.read(Type.COMPONENT);
JsonElement suffixComponent = wrapper.read(Type.COMPONENT);
String prefix = prefixComponent == null || prefixComponent.isJsonNull() ? "" : ChatRewriter.jsonTextToLegacy(prefixComponent.toString());
String prefix = prefixComponent == null || prefixComponent.isJsonNull() ? "" : ChatRewriter.jsonToLegacyText(prefixComponent.toString());
if (ViaBackwards.getConfig().addTeamColorTo1_13Prefix()) {
prefix += "§" + (colour > -1 && colour <= 15 ? Integer.toHexString(colour) : "r");
}
@ -261,7 +261,7 @@ public class PlayerPacket1_13 extends Rewriter<Protocol1_12_2To1_13> {
if (prefix.length() > 16) prefix = prefix.substring(0, 16);
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.jsonToLegacyText(suffixComponent.toString());
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);

View File

@ -531,7 +531,7 @@ public class BlockItemPackets1_14 extends nl.matsv.viabackwards.api.rewriters.It
CompoundTag tag = item.getTag();
if (tag != null) {
// Display Name now uses JSON
// Lore now uses JSON
if (tag.get("display") instanceof CompoundTag) {
CompoundTag display = tag.get("display");
if (((CompoundTag) tag.get("display")).get("Lore") instanceof ListTag) {
@ -545,7 +545,7 @@ public class BlockItemPackets1_14 extends nl.matsv.viabackwards.api.rewriters.It
String value = ((StringTag) loreEntry).getValue();
if (value != null && !value.isEmpty()) {
((StringTag) loreEntry).setValue(ChatRewriter.jsonTextToLegacy(value));
((StringTag) loreEntry).setValue(ChatRewriter.jsonToLegacyText(value));
}
}
}