forked from GeyserMC/Geyser
Fix json data in chat
This commit is contained in:
parent
65f61ec703
commit
47cadc7689
3 changed files with 10 additions and 8 deletions
|
@ -26,8 +26,8 @@
|
||||||
package org.geysermc.connector.network.translators.inventory;
|
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.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.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.mc.protocol.packet.ingame.client.window.ClientRenameItemPacket;
|
||||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||||
import com.nukkitx.protocol.bedrock.data.ContainerId;
|
import com.nukkitx.protocol.bedrock.data.ContainerId;
|
||||||
|
@ -130,8 +130,8 @@ public class AnvilInventoryTranslator extends BlockInventoryTranslator {
|
||||||
CompoundTag displayTag = tag.get("display");
|
CompoundTag displayTag = tag.get("display");
|
||||||
if (displayTag != null) {
|
if (displayTag != null) {
|
||||||
String itemName = displayTag.get("Name").getValue().toString();
|
String itemName = displayTag.get("Name").getValue().toString();
|
||||||
Message message = MessageSerializer.fromString(itemName);
|
TextMessage message = (TextMessage) MessageSerializer.fromString(itemName);
|
||||||
rename = message.toString();
|
rename = message.getText();
|
||||||
} else {
|
} else {
|
||||||
rename = "";
|
rename = "";
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,7 @@ package org.geysermc.connector.ping;
|
||||||
import com.github.steveice10.mc.protocol.MinecraftConstants;
|
import com.github.steveice10.mc.protocol.MinecraftConstants;
|
||||||
import com.github.steveice10.mc.protocol.MinecraftProtocol;
|
import com.github.steveice10.mc.protocol.MinecraftProtocol;
|
||||||
import com.github.steveice10.mc.protocol.data.SubProtocol;
|
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.mc.protocol.data.status.handler.ServerInfoHandler;
|
||||||
import com.github.steveice10.packetlib.Client;
|
import com.github.steveice10.packetlib.Client;
|
||||||
import com.github.steveice10.packetlib.tcp.TcpSessionFactory;
|
import com.github.steveice10.packetlib.tcp.TcpSessionFactory;
|
||||||
|
@ -77,7 +78,7 @@ public class GeyserLegacyPingPassthrough implements IGeyserPingPassthrough, Runn
|
||||||
try {
|
try {
|
||||||
this.client = new Client(connector.getConfig().getRemote().getAddress(), connector.getConfig().getRemote().getPort(), new MinecraftProtocol(SubProtocol.STATUS), new TcpSessionFactory());
|
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.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);
|
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.game.scoreboard.TeamColor;
|
||||||
import com.github.steveice10.mc.protocol.data.message.Message;
|
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.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.TranslationMessage;
|
||||||
import com.github.steveice10.mc.protocol.data.message.style.ChatColor;
|
import com.github.steveice10.mc.protocol.data.message.style.ChatColor;
|
||||||
import com.github.steveice10.mc.protocol.data.message.style.ChatFormat;
|
import com.github.steveice10.mc.protocol.data.message.style.ChatFormat;
|
||||||
|
@ -98,7 +99,7 @@ public class MessageUtils {
|
||||||
message = MessageSerializer.fromJson(formatJson(object));
|
message = MessageSerializer.fromJson(formatJson(object));
|
||||||
}
|
}
|
||||||
|
|
||||||
String messageText = message.toString();
|
String messageText = (message instanceof TranslationMessage) ? ((TranslationMessage) message).getKey() : ((TextMessage) message).getText();
|
||||||
if (locale != null && shouldTranslate) {
|
if (locale != null && shouldTranslate) {
|
||||||
messageText = LocaleUtils.getLocaleString(messageText, locale);
|
messageText = LocaleUtils.getLocaleString(messageText, locale);
|
||||||
}
|
}
|
||||||
|
@ -135,8 +136,8 @@ public class MessageUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getBedrockMessage(Message message) {
|
public static String getBedrockMessage(Message message) {
|
||||||
if (isMessage(message.toString())) {
|
if (isMessage(((TextMessage) message).getText())) {
|
||||||
return getBedrockMessage(message.toString());
|
return getBedrockMessage(((TextMessage) message).getText());
|
||||||
} else {
|
} else {
|
||||||
return getBedrockMessage(MessageSerializer.toJsonString(message));
|
return getBedrockMessage(MessageSerializer.toJsonString(message));
|
||||||
}
|
}
|
||||||
|
@ -276,7 +277,7 @@ public class MessageUtils {
|
||||||
base += "f";
|
base += "f";
|
||||||
break;
|
break;
|
||||||
case RESET:
|
case RESET:
|
||||||
case NONE:
|
//case NONE:
|
||||||
base += "r";
|
base += "r";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Reference in a new issue