3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-12-26 16:12:46 +01:00

Fix RGB colors on signs causing chunk issues, fix items names not being displayed correctly

Dieser Commit ist enthalten in:
rtm516 2020-07-06 23:36:04 +01:00
Ursprung 545dfa38f0
Commit ba736575f7
4 geänderte Dateien mit 28 neuen und 29 gelöschten Zeilen

Datei anzeigen

@ -127,20 +127,20 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>net.kyori</groupId> <groupId>net.kyori</groupId>
<artifactId>text-api</artifactId> <artifactId>adventure-api</artifactId>
<version>3.0.3</version> <version>4.0.0-SNAPSHOT</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>net.kyori</groupId> <groupId>net.kyori</groupId>
<artifactId>text-serializer-gson</artifactId> <artifactId>adventure-text-serializer-gson</artifactId>
<version>3.0.3</version> <version>4.0.0-SNAPSHOT</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>net.kyori</groupId> <groupId>net.kyori</groupId>
<artifactId>text-serializer-legacy</artifactId> <artifactId>adventure-text-serializer-legacy</artifactId>
<version>3.0.3</version> <version>4.0.0-SNAPSHOT</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
</dependencies> </dependencies>

Datei anzeigen

@ -28,17 +28,7 @@ package org.geysermc.connector.network.translators.item;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack; import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack;
import com.github.steveice10.mc.protocol.data.message.MessageSerializer; import com.github.steveice10.mc.protocol.data.message.MessageSerializer;
import com.github.steveice10.opennbt.tag.builtin.ByteArrayTag; import com.github.steveice10.opennbt.tag.builtin.*;
import com.github.steveice10.opennbt.tag.builtin.ByteTag;
import com.github.steveice10.opennbt.tag.builtin.DoubleTag;
import com.github.steveice10.opennbt.tag.builtin.FloatTag;
import com.github.steveice10.opennbt.tag.builtin.IntArrayTag;
import com.github.steveice10.opennbt.tag.builtin.IntTag;
import com.github.steveice10.opennbt.tag.builtin.ListTag;
import com.github.steveice10.opennbt.tag.builtin.LongArrayTag;
import com.github.steveice10.opennbt.tag.builtin.LongTag;
import com.github.steveice10.opennbt.tag.builtin.ShortTag;
import com.github.steveice10.opennbt.tag.builtin.StringTag;
import com.nukkitx.nbt.NbtList; import com.nukkitx.nbt.NbtList;
import com.nukkitx.nbt.NbtMap; import com.nukkitx.nbt.NbtMap;
import com.nukkitx.nbt.NbtMapBuilder; import com.nukkitx.nbt.NbtMapBuilder;
@ -46,11 +36,14 @@ import com.nukkitx.nbt.NbtType;
import com.nukkitx.protocol.bedrock.data.inventory.ItemData; import com.nukkitx.protocol.bedrock.data.inventory.ItemData;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap; import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import net.kyori.adventure.text.TextComponent;
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
import org.geysermc.connector.GeyserConnector; import org.geysermc.connector.GeyserConnector;
import org.geysermc.connector.network.session.GeyserSession; import org.geysermc.connector.network.session.GeyserSession;
import org.geysermc.connector.network.translators.ItemRemapper; import org.geysermc.connector.network.translators.ItemRemapper;
import org.geysermc.connector.utils.MessageUtils;
import org.geysermc.connector.utils.LanguageUtils; import org.geysermc.connector.utils.LanguageUtils;
import org.geysermc.connector.utils.MessageUtils;
import org.reflections.Reflections; import org.reflections.Reflections;
import java.util.*; import java.util.*;
@ -167,6 +160,12 @@ public abstract class ItemTranslator {
if (display != null) { if (display != null) {
String name = display.getString("Name"); String name = display.getString("Name");
// If its not a message convert it
if (!MessageUtils.isMessage(name)) {
TextComponent component = LegacyComponentSerializer.legacy().deserialize(name);
name = GsonComponentSerializer.gson().serialize(component);
}
// Check if its a message to translate // Check if its a message to translate
if (MessageUtils.isMessage(name)) { if (MessageUtils.isMessage(name)) {
// Get the translated name // Get the translated name

Datei anzeigen

@ -29,13 +29,13 @@ import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.github.steveice10.opennbt.tag.builtin.ListTag; import com.github.steveice10.opennbt.tag.builtin.ListTag;
import com.github.steveice10.opennbt.tag.builtin.StringTag; import com.github.steveice10.opennbt.tag.builtin.StringTag;
import com.github.steveice10.opennbt.tag.builtin.Tag; import com.github.steveice10.opennbt.tag.builtin.Tag;
import net.kyori.text.Component; import net.kyori.adventure.text.Component;
import net.kyori.text.TextComponent; import net.kyori.adventure.text.TextComponent;
import net.kyori.text.serializer.gson.GsonComponentSerializer; import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
import net.kyori.text.serializer.legacy.LegacyComponentSerializer; import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
import org.geysermc.connector.network.translators.ItemRemapper; import org.geysermc.connector.network.translators.ItemRemapper;
import org.geysermc.connector.network.translators.item.NbtItemStackTranslator;
import org.geysermc.connector.network.translators.item.ItemEntry; import org.geysermc.connector.network.translators.item.ItemEntry;
import org.geysermc.connector.network.translators.item.NbtItemStackTranslator;
import org.geysermc.connector.utils.MessageUtils; import org.geysermc.connector.utils.MessageUtils;
import java.util.ArrayList; import java.util.ArrayList;
@ -101,7 +101,7 @@ public class BasicItemTranslator extends NbtItemStackTranslator {
message = message.replaceFirst("§r", ""); message = message.replaceFirst("§r", "");
} }
Component component = TextComponent.of(message); Component component = TextComponent.of(message);
return GsonComponentSerializer.INSTANCE.serialize(component); return GsonComponentSerializer.gson().serialize(component);
} }
private String toBedrockMessage(StringTag tag) { private String toBedrockMessage(StringTag tag) {

Datei anzeigen

@ -35,9 +35,9 @@ import com.github.steveice10.mc.protocol.data.message.style.ChatFormat;
import com.github.steveice10.mc.protocol.data.message.style.MessageStyle; import com.github.steveice10.mc.protocol.data.message.style.MessageStyle;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import com.google.gson.JsonParser; import com.google.gson.JsonParser;
import net.kyori.text.Component; import net.kyori.adventure.text.Component;
import net.kyori.text.serializer.gson.GsonComponentSerializer; import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
import net.kyori.text.serializer.legacy.LegacyComponentSerializer; import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
import org.geysermc.connector.network.session.GeyserSession; import org.geysermc.connector.network.session.GeyserSession;
import java.util.*; import java.util.*;
@ -263,12 +263,12 @@ public class MessageUtils {
} }
public static Component phraseJavaMessage(String message) { public static Component phraseJavaMessage(String message) {
return GsonComponentSerializer.INSTANCE.deserialize(message); return GsonComponentSerializer.gson().deserialize(message);
} }
public static String getJavaMessage(String message) { public static String getJavaMessage(String message) {
Component component = LegacyComponentSerializer.legacy().deserialize(message); Component component = LegacyComponentSerializer.legacy().deserialize(message);
return GsonComponentSerializer.INSTANCE.serialize(component); return GsonComponentSerializer.gson().serialize(component);
} }
/** /**