So the code I have is the following
For example, I executed a command "plugman", it will display a text like this
What I want to do is, get the exact same string from the packet
But currently I can only get this
Is there any way to parse the message above to the exact text that the player receives?
Code:
private ProtocolManager protocolManager;
public void onEnable() {
protocolManager = ProtocolLibrary.getProtocolManager();
protocolManager.addPacketListener(new PacketAdapter(this, PacketType.Play.Server.CHAT) {
@Override
public void onPacketSending(PacketEvent event) {
PacketContainer packet = event.getPacket();
StructureModifier<WrappedChatComponent> chatComponents = packet.getChatComponents();
String jsonText = chatComponents.read(0).getJson();
Bukkit.getServer().getLogger().info(jsonText);
}
});
}
For example, I executed a command "plugman", it will display a text like this
Code:
[PlugMan] You do not have permission to do this.
But currently I can only get this
Code:
{"extra":[{"color":"gray","text":"["},{"color":"green","text":"
PlugMan"},{"color":"gray","text":"] "},{"color":"red","text":"You do not have pe
rmission to do this."}],"text":""}
Is there any way to parse the message above to the exact text that the player receives?