Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-12-26 16:12:46 +01:00
Fix json data in chat
Dieser Commit ist enthalten in:
Ursprung
65f61ec703
Commit
47cadc7689
@ -26,8 +26,8 @@
|
||||
package org.geysermc.connector.network.translators.inventory;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack;
|
||||
import com.github.steveice10.mc.protocol.data.message.Message;
|
||||
import com.github.steveice10.mc.protocol.data.message.MessageSerializer;
|
||||
import com.github.steveice10.mc.protocol.data.message.TextMessage;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.window.ClientRenameItemPacket;
|
||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||
import com.nukkitx.protocol.bedrock.data.ContainerId;
|
||||
@ -130,8 +130,8 @@ public class AnvilInventoryTranslator extends BlockInventoryTranslator {
|
||||
CompoundTag displayTag = tag.get("display");
|
||||
if (displayTag != null) {
|
||||
String itemName = displayTag.get("Name").getValue().toString();
|
||||
Message message = MessageSerializer.fromString(itemName);
|
||||
rename = message.toString();
|
||||
TextMessage message = (TextMessage) MessageSerializer.fromString(itemName);
|
||||
rename = message.getText();
|
||||
} else {
|
||||
rename = "";
|
||||
}
|
||||
|
@ -29,6 +29,7 @@ package org.geysermc.connector.ping;
|
||||
import com.github.steveice10.mc.protocol.MinecraftConstants;
|
||||
import com.github.steveice10.mc.protocol.MinecraftProtocol;
|
||||
import com.github.steveice10.mc.protocol.data.SubProtocol;
|
||||
import com.github.steveice10.mc.protocol.data.message.TextMessage;
|
||||
import com.github.steveice10.mc.protocol.data.status.handler.ServerInfoHandler;
|
||||
import com.github.steveice10.packetlib.Client;
|
||||
import com.github.steveice10.packetlib.tcp.TcpSessionFactory;
|
||||
@ -77,7 +78,7 @@ public class GeyserLegacyPingPassthrough implements IGeyserPingPassthrough, Runn
|
||||
try {
|
||||
this.client = new Client(connector.getConfig().getRemote().getAddress(), connector.getConfig().getRemote().getPort(), new MinecraftProtocol(SubProtocol.STATUS), new TcpSessionFactory());
|
||||
this.client.getSession().setFlag(MinecraftConstants.SERVER_INFO_HANDLER_KEY, (ServerInfoHandler) (session, info) -> {
|
||||
this.pingInfo = new GeyserPingInfo(info.getDescription().toString(), info.getPlayerInfo().getOnlinePlayers(), info.getPlayerInfo().getMaxPlayers());
|
||||
this.pingInfo = new GeyserPingInfo(((TextMessage) info.getDescription()).getText(), info.getPlayerInfo().getOnlinePlayers(), info.getPlayerInfo().getMaxPlayers());
|
||||
this.client.getSession().disconnect(null);
|
||||
});
|
||||
|
||||
|
@ -28,6 +28,7 @@ package org.geysermc.connector.utils;
|
||||
import com.github.steveice10.mc.protocol.data.game.scoreboard.TeamColor;
|
||||
import com.github.steveice10.mc.protocol.data.message.Message;
|
||||
import com.github.steveice10.mc.protocol.data.message.MessageSerializer;
|
||||
import com.github.steveice10.mc.protocol.data.message.TextMessage;
|
||||
import com.github.steveice10.mc.protocol.data.message.TranslationMessage;
|
||||
import com.github.steveice10.mc.protocol.data.message.style.ChatColor;
|
||||
import com.github.steveice10.mc.protocol.data.message.style.ChatFormat;
|
||||
@ -98,7 +99,7 @@ public class MessageUtils {
|
||||
message = MessageSerializer.fromJson(formatJson(object));
|
||||
}
|
||||
|
||||
String messageText = message.toString();
|
||||
String messageText = (message instanceof TranslationMessage) ? ((TranslationMessage) message).getKey() : ((TextMessage) message).getText();
|
||||
if (locale != null && shouldTranslate) {
|
||||
messageText = LocaleUtils.getLocaleString(messageText, locale);
|
||||
}
|
||||
@ -135,8 +136,8 @@ public class MessageUtils {
|
||||
}
|
||||
|
||||
public static String getBedrockMessage(Message message) {
|
||||
if (isMessage(message.toString())) {
|
||||
return getBedrockMessage(message.toString());
|
||||
if (isMessage(((TextMessage) message).getText())) {
|
||||
return getBedrockMessage(((TextMessage) message).getText());
|
||||
} else {
|
||||
return getBedrockMessage(MessageSerializer.toJsonString(message));
|
||||
}
|
||||
@ -276,7 +277,7 @@ public class MessageUtils {
|
||||
base += "f";
|
||||
break;
|
||||
case RESET:
|
||||
case NONE:
|
||||
//case NONE:
|
||||
base += "r";
|
||||
break;
|
||||
default:
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren