diff --git a/buildSrc/src/main/kotlin/Versions.kt b/buildSrc/src/main/kotlin/Versions.kt index f4f75066..620f44f4 100644 --- a/buildSrc/src/main/kotlin/Versions.kt +++ b/buildSrc/src/main/kotlin/Versions.kt @@ -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" diff --git a/common/src/main/java/nl/matsv/viabackwards/api/data/MappedItem.java b/common/src/main/java/nl/matsv/viabackwards/api/data/MappedItem.java index 191f8a1b..af34c63f 100644 --- a/common/src/main/java/nl/matsv/viabackwards/api/data/MappedItem.java +++ b/common/src/main/java/nl/matsv/viabackwards/api/data/MappedItem.java @@ -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() { diff --git a/common/src/main/java/nl/matsv/viabackwards/api/data/MappedLegacyBlockItem.java b/common/src/main/java/nl/matsv/viabackwards/api/data/MappedLegacyBlockItem.java index a2732477..48c1c193 100644 --- a/common/src/main/java/nl/matsv/viabackwards/api/data/MappedLegacyBlockItem.java +++ b/common/src/main/java/nl/matsv/viabackwards/api/data/MappedLegacyBlockItem.java @@ -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; } diff --git a/common/src/main/java/nl/matsv/viabackwards/api/rewriters/LegacyBlockItemRewriter.java b/common/src/main/java/nl/matsv/viabackwards/api/rewriters/LegacyBlockItemRewriter.java index 8d3fef0c..7c7c0a22 100644 --- a/common/src/main/java/nl/matsv/viabackwards/api/rewriters/LegacyBlockItemRewriter.java +++ b/common/src/main/java/nl/matsv/viabackwards/api/rewriters/LegacyBlockItemRewriter.java @@ -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 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; } diff --git a/common/src/main/java/nl/matsv/viabackwards/protocol/protocol1_10to1_11/packets/BlockItemPackets1_11.java b/common/src/main/java/nl/matsv/viabackwards/protocol/protocol1_10to1_11/packets/BlockItemPackets1_11.java index a758cb74..713c83f4 100644 --- a/common/src/main/java/nl/matsv/viabackwards/protocol/protocol1_10to1_11/packets/BlockItemPackets1_11.java +++ b/common/src/main/java/nl/matsv/viabackwards/protocol/protocol1_10to1_11/packets/BlockItemPackets1_11.java @@ -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= 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; diff --git a/common/src/main/java/nl/matsv/viabackwards/protocol/protocol1_10to1_11/packets/PlayerPackets1_11.java b/common/src/main/java/nl/matsv/viabackwards/protocol/protocol1_10to1_11/packets/PlayerPackets1_11.java index 97f9ae61..2b48aaed 100644 --- a/common/src/main/java/nl/matsv/viabackwards/protocol/protocol1_10to1_11/packets/PlayerPackets1_11.java +++ b/common/src/main/java/nl/matsv/viabackwards/protocol/protocol1_10to1_11/packets/PlayerPackets1_11.java @@ -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 TO_NEW_FLOAT = new ValueTransformer(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); diff --git a/common/src/main/java/nl/matsv/viabackwards/protocol/protocol1_11_1to1_12/data/ShoulderTracker.java b/common/src/main/java/nl/matsv/viabackwards/protocol/protocol1_11_1to1_12/data/ShoulderTracker.java index c2941f10..0eb4d6a4 100644 --- a/common/src/main/java/nl/matsv/viabackwards/protocol/protocol1_11_1to1_12/data/ShoulderTracker.java +++ b/common/src/main/java/nl/matsv/viabackwards/protocol/protocol1_11_1to1_12/data/ShoulderTracker.java @@ -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(); diff --git a/common/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/packets/BlockItemPackets1_13.java b/common/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/packets/BlockItemPackets1_13.java index d45998ac..4ccc2cda 100644 --- a/common/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/packets/BlockItemPackets1_13.java +++ b/common/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/packets/BlockItemPackets1_13.java @@ -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())); } } diff --git a/common/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/packets/EntityPackets1_13.java b/common/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/packets/EntityPackets1_13.java index 2641e755..dd0adc53 100644 --- a/common/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/packets/EntityPackets1_13.java +++ b/common/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/packets/EntityPackets1_13.java @@ -325,7 +325,7 @@ public class EntityPackets1_13 extends LegacyEntityRewriter { 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 { 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 { 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 { 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); diff --git a/common/src/main/java/nl/matsv/viabackwards/protocol/protocol1_13_2to1_14/packets/BlockItemPackets1_14.java b/common/src/main/java/nl/matsv/viabackwards/protocol/protocol1_13_2to1_14/packets/BlockItemPackets1_14.java index 67ea055c..d207a252 100644 --- a/common/src/main/java/nl/matsv/viabackwards/protocol/protocol1_13_2to1_14/packets/BlockItemPackets1_14.java +++ b/common/src/main/java/nl/matsv/viabackwards/protocol/protocol1_13_2to1_14/packets/BlockItemPackets1_14.java @@ -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)); } } }