3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-12-25 15:50:14 +01:00

JavaOpenWindowTranslator: Use MessageUtils for inventory name (#1416)

* JavaOpenWindowTranslator: Use MessageUtils for inventory name

* Remove important messaging
Dieser Commit ist enthalten in:
Camotoy 2020-10-17 23:13:04 -04:00 committet von GitHub
Ursprung 64f2233581
Commit ae70dbeece
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23

Datei anzeigen

@ -25,11 +25,9 @@
package org.geysermc.connector.network.translators.java.window;
import com.github.steveice10.mc.protocol.data.message.MessageSerializer;
import com.github.steveice10.mc.protocol.packet.ingame.client.window.ClientCloseWindowPacket;
import com.github.steveice10.mc.protocol.packet.ingame.server.window.ServerOpenWindowPacket;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import org.geysermc.connector.GeyserConnector;
import org.geysermc.connector.inventory.Inventory;
import org.geysermc.connector.network.session.GeyserSession;
import org.geysermc.connector.network.translators.PacketTranslator;
@ -37,6 +35,7 @@ import org.geysermc.connector.network.translators.Translator;
import org.geysermc.connector.network.translators.inventory.InventoryTranslator;
import org.geysermc.connector.utils.InventoryUtils;
import org.geysermc.connector.utils.LocaleUtils;
import org.geysermc.connector.utils.MessageUtils;
@Translator(packet = ServerOpenWindowPacket.class)
public class JavaOpenWindowTranslator extends PacketTranslator<ServerOpenWindowPacket> {
@ -58,18 +57,8 @@ public class JavaOpenWindowTranslator extends PacketTranslator<ServerOpenWindowP
return;
}
String name = packet.getName();
try {
JsonParser parser = new JsonParser();
JsonObject jsonObject = parser.parse(packet.getName()).getAsJsonObject();
if (jsonObject.has("text")) {
name = jsonObject.get("text").getAsString();
} else if (jsonObject.has("translate")) {
name = jsonObject.get("translate").getAsString();
}
} catch (Exception e) {
GeyserConnector.getInstance().getLogger().debug("JavaOpenWindowTranslator: " + e.toString());
}
String name = MessageUtils.getTranslatedBedrockMessage(MessageSerializer.fromString(packet.getName()),
session.getClientData().getLanguageCode());
name = LocaleUtils.getLocaleString(name, session.getClientData().getLanguageCode());