mirror of
https://github.com/ViaVersion/ViaBackwards.git
synced 2024-11-25 12:45:35 +01:00
Throw away Bungee Chat
This commit is contained in:
parent
70b4e74b52
commit
ea59ab372e
@ -1,6 +1,6 @@
|
|||||||
object Versions {
|
object Versions {
|
||||||
// ViaVersion
|
// ViaVersion
|
||||||
const val viaversion = "3.3.0-21w08a-gradle"
|
const val viaversion = "3.3.0-21w08b"
|
||||||
|
|
||||||
// Common
|
// Common
|
||||||
const val netty = "4.0.20.Final"
|
const val netty = "4.0.20.Final"
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package nl.matsv.viabackwards.api.data;
|
package nl.matsv.viabackwards.api.data;
|
||||||
|
|
||||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ChatRewriter;
|
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ChatRewriter;
|
||||||
import us.myles.viaversion.libs.bungeecordchat.api.ChatColor;
|
|
||||||
|
|
||||||
public class MappedItem {
|
public class MappedItem {
|
||||||
|
|
||||||
@ -10,7 +9,7 @@ public class MappedItem {
|
|||||||
|
|
||||||
public MappedItem(int id, String name) {
|
public MappedItem(int id, String name) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.jsonName = ChatRewriter.legacyTextToJson(ChatColor.RESET + name).toString();
|
this.jsonName = ChatRewriter.legacyTextToJsonString(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getId() {
|
public int getId() {
|
||||||
|
@ -2,7 +2,6 @@ package nl.matsv.viabackwards.api.data;
|
|||||||
|
|
||||||
import nl.matsv.viabackwards.utils.Block;
|
import nl.matsv.viabackwards.utils.Block;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
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.CompoundTag;
|
||||||
|
|
||||||
public class MappedLegacyBlockItem {
|
public class MappedLegacyBlockItem {
|
||||||
@ -16,7 +15,7 @@ public class MappedLegacyBlockItem {
|
|||||||
public MappedLegacyBlockItem(int id, short data, @Nullable String name, boolean block) {
|
public MappedLegacyBlockItem(int id, short data, @Nullable String name, boolean block) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.data = data;
|
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;
|
this.block = block ? new Block(id, data) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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.chunks.ChunkSection;
|
||||||
import us.myles.ViaVersion.api.minecraft.item.Item;
|
import us.myles.ViaVersion.api.minecraft.item.Item;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ChatRewriter;
|
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.Int2ObjectMap;
|
||||||
import us.myles.viaversion.libs.fastutil.ints.Int2ObjectOpenHashMap;
|
import us.myles.viaversion.libs.fastutil.ints.Int2ObjectOpenHashMap;
|
||||||
import us.myles.viaversion.libs.gson.JsonElement;
|
import us.myles.viaversion.libs.gson.JsonElement;
|
||||||
@ -240,7 +239,7 @@ public abstract class LegacyBlockItemRewriter<T extends BackwardsProtocol> exten
|
|||||||
protected CompoundTag getNamedTag(String text) {
|
protected CompoundTag getNamedTag(String text) {
|
||||||
CompoundTag tag = new CompoundTag("");
|
CompoundTag tag = new CompoundTag("");
|
||||||
tag.put(new CompoundTag("display"));
|
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));
|
((CompoundTag) tag.get("display")).put(new StringTag("Name", jsonNameFormat ? ChatRewriter.legacyTextToJson(text).toString() : text));
|
||||||
return tag;
|
return tag;
|
||||||
}
|
}
|
||||||
|
@ -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.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.ServerboundPackets1_9_3;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
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.CompoundTag;
|
||||||
import us.myles.viaversion.libs.opennbt.tag.builtin.ListTag;
|
import us.myles.viaversion.libs.opennbt.tag.builtin.ListTag;
|
||||||
import us.myles.viaversion.libs.opennbt.tag.builtin.StringTag;
|
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);
|
int endNonExistingFormula = 2 + 3 * (storage.isChested() ? 5 : 0);
|
||||||
|
|
||||||
if (slotId >= startNonExistingFormula && slotId < endNonExistingFormula)
|
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)
|
if (slotId == 1)
|
||||||
return null;
|
return null;
|
||||||
return current;
|
return current;
|
||||||
|
@ -17,11 +17,10 @@ import us.myles.ViaVersion.api.remapper.ValueTransformer;
|
|||||||
import us.myles.ViaVersion.api.type.Type;
|
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.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.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.JsonElement;
|
||||||
import us.myles.viaversion.libs.gson.JsonObject;
|
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 {
|
public class PlayerPackets1_11 {
|
||||||
private static final ValueTransformer<Short, Float> TO_NEW_FLOAT = new ValueTransformer<Short, Float>(Type.FLOAT) {
|
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());
|
wrapper.setId(ClientboundPackets1_9_3.CHAT_MESSAGE.ordinal());
|
||||||
|
|
||||||
// https://bugs.mojang.com/browse/MC-119145to
|
// https://bugs.mojang.com/browse/MC-119145to
|
||||||
BaseComponent[] parsed = ComponentSerializer.parse(message.toString());
|
String legacy = LegacyComponentSerializer.legacySection().serialize(GsonComponentSerializer.gson().deserialize(message.toString()));
|
||||||
String legacy = TextComponent.toLegacyText(parsed);
|
|
||||||
message = new JsonObject();
|
message = new JsonObject();
|
||||||
message.getAsJsonObject().addProperty("text", legacy);
|
message.getAsJsonObject().addProperty("text", legacy);
|
||||||
|
|
||||||
|
@ -17,7 +17,6 @@ import us.myles.ViaVersion.api.data.StoredObject;
|
|||||||
import us.myles.ViaVersion.api.data.UserConnection;
|
import us.myles.ViaVersion.api.data.UserConnection;
|
||||||
import us.myles.ViaVersion.api.type.Type;
|
import us.myles.ViaVersion.api.type.Type;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.Protocol1_9To1_8;
|
import us.myles.ViaVersion.protocols.protocol1_9to1_8.Protocol1_9To1_8;
|
||||||
import us.myles.viaversion.libs.bungeecordchat.api.ChatColor;
|
|
||||||
|
|
||||||
public class ShoulderTracker extends StoredObject {
|
public class ShoulderTracker extends StoredObject {
|
||||||
private int entityId;
|
private int entityId;
|
||||||
@ -48,26 +47,28 @@ public class ShoulderTracker extends StoredObject {
|
|||||||
|
|
||||||
// Empty spaces because the non-json formatting is weird
|
// Empty spaces because the non-json formatting is weird
|
||||||
builder.append(" ");
|
builder.append(" ");
|
||||||
if (leftShoulder == null)
|
if (leftShoulder == null) {
|
||||||
builder.append(ChatColor.RED).append(ChatColor.BOLD).append("Nothing");
|
builder.append("§4§lNothing");
|
||||||
else
|
} else {
|
||||||
builder.append(ChatColor.DARK_GREEN).append(ChatColor.BOLD).append(getName(leftShoulder));
|
builder.append("§2§l").append(getName(leftShoulder));
|
||||||
|
}
|
||||||
|
|
||||||
builder.append(ChatColor.DARK_GRAY).append(ChatColor.BOLD).append(" <- ")
|
builder.append("§8§l <- §7§lShoulders§8§l -> ");
|
||||||
.append(ChatColor.GRAY).append(ChatColor.BOLD).append("Shoulders")
|
|
||||||
.append(ChatColor.DARK_GRAY).append(ChatColor.BOLD).append(" -> ");
|
|
||||||
|
|
||||||
if (rightShoulder == null)
|
if (rightShoulder == null) {
|
||||||
builder.append(ChatColor.RED).append(ChatColor.BOLD).append("Nothing");
|
builder.append("§4§lNothing");
|
||||||
else
|
} else {
|
||||||
builder.append(ChatColor.DARK_GREEN).append(ChatColor.BOLD).append(getName(rightShoulder));
|
builder.append("§2§l").append(getName(rightShoulder));
|
||||||
|
}
|
||||||
|
|
||||||
return builder.toString();
|
return builder.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getName(String current) {
|
private String getName(String current) {
|
||||||
if (current.startsWith("minecraft:"))
|
if (current.startsWith("minecraft:")) {
|
||||||
current = current.substring(10);
|
current = current.substring(10);
|
||||||
|
}
|
||||||
|
|
||||||
String[] array = current.split("_");
|
String[] array = current.split("_");
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
|
|
||||||
|
@ -576,7 +576,7 @@ public class BlockItemPackets1_13 extends nl.matsv.viabackwards.api.rewriters.It
|
|||||||
StringTag name = display.get("Name");
|
StringTag name = display.get("Name");
|
||||||
if (name instanceof StringTag) {
|
if (name instanceof StringTag) {
|
||||||
display.put(new StringTag(extraNbtTag + "|Name", name.getValue()));
|
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");
|
StringTag name = displayTag.get("Name");
|
||||||
if (name instanceof StringTag) {
|
if (name instanceof StringTag) {
|
||||||
StringTag via = displayTag.remove(extraNbtTag + "|Name");
|
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()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -325,7 +325,7 @@ public class EntityPackets1_13 extends LegacyEntityRewriter<Protocol1_12_2To1_13
|
|||||||
Metadata meta = e.getData();
|
Metadata meta = e.getData();
|
||||||
String value = meta.getValue().toString();
|
String value = meta.getValue().toString();
|
||||||
if (value.isEmpty()) return meta;
|
if (value.isEmpty()) return meta;
|
||||||
meta.setValue(ChatRewriter.jsonTextToLegacy(value));
|
meta.setValue(ChatRewriter.jsonToLegacyText(value));
|
||||||
return meta;
|
return meta;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -208,7 +208,7 @@ public class PlayerPacket1_13 extends Rewriter<Protocol1_12_2To1_13> {
|
|||||||
byte mode = wrapper.get(Type.BYTE, 0);
|
byte mode = wrapper.get(Type.BYTE, 0);
|
||||||
if (mode == 0 || mode == 2) {
|
if (mode == 0 || mode == 2) {
|
||||||
String value = wrapper.read(Type.COMPONENT).toString();
|
String value = wrapper.read(Type.COMPONENT).toString();
|
||||||
value = ChatRewriter.jsonTextToLegacy(value);
|
value = ChatRewriter.jsonToLegacyText(value);
|
||||||
if (value.length() > 32) {
|
if (value.length() > 32) {
|
||||||
value = value.substring(0, 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);
|
byte action = wrapper.get(Type.BYTE, 0);
|
||||||
if (action == 0 || action == 2) {
|
if (action == 0 || action == 2) {
|
||||||
String displayName = wrapper.read(Type.STRING);
|
String displayName = wrapper.read(Type.STRING);
|
||||||
displayName = ChatRewriter.jsonTextToLegacy(displayName);
|
displayName = ChatRewriter.jsonToLegacyText(displayName);
|
||||||
displayName = ChatUtil.removeUnusedColor(displayName, 'f');
|
displayName = ChatUtil.removeUnusedColor(displayName, 'f');
|
||||||
if (displayName.length() > 32) {
|
if (displayName.length() > 32) {
|
||||||
displayName = displayName.substring(0, 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 prefixComponent = wrapper.read(Type.COMPONENT);
|
||||||
JsonElement suffixComponent = 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()) {
|
if (ViaBackwards.getConfig().addTeamColorTo1_13Prefix()) {
|
||||||
prefix += "§" + (colour > -1 && colour <= 15 ? Integer.toHexString(colour) : "r");
|
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.length() > 16) prefix = prefix.substring(0, 16);
|
||||||
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.jsonToLegacyText(suffixComponent.toString());
|
||||||
suffix = ChatUtil.removeUnusedColor(suffix, '\0'); // Don't remove white coloring
|
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);
|
||||||
|
@ -531,7 +531,7 @@ public class BlockItemPackets1_14 extends nl.matsv.viabackwards.api.rewriters.It
|
|||||||
|
|
||||||
CompoundTag tag = item.getTag();
|
CompoundTag tag = item.getTag();
|
||||||
if (tag != null) {
|
if (tag != null) {
|
||||||
// Display Name now uses JSON
|
// Lore now uses JSON
|
||||||
if (tag.get("display") instanceof CompoundTag) {
|
if (tag.get("display") instanceof CompoundTag) {
|
||||||
CompoundTag display = tag.get("display");
|
CompoundTag display = tag.get("display");
|
||||||
if (((CompoundTag) tag.get("display")).get("Lore") instanceof ListTag) {
|
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();
|
String value = ((StringTag) loreEntry).getValue();
|
||||||
if (value != null && !value.isEmpty()) {
|
if (value != null && !value.isEmpty()) {
|
||||||
((StringTag) loreEntry).setValue(ChatRewriter.jsonTextToLegacy(value));
|
((StringTag) loreEntry).setValue(ChatRewriter.jsonToLegacyText(value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user