5.0.0 chat packet
Olzie-12 opened this issue ยท 2 comments
This issue is not solved in a development build
Describe the bug
5.0.0 isn't triggering the chat packet, but for 1.18.2 its triggering the chat packet.
To Reproduce
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(this.plugin, PacketType.Play.Server.CHAT) {
@Override
public void onPacketSending(PacketEvent event) {
Player player = event.getPlayer();
Bukkit.broadcastMessage("Packet sent to " + player.getName());
if (event.getPacketType() != PacketType.Play.Server.CHAT) return;
// This is the message sent in a json format. For example: {"text":"This is an example"}
WrappedChatComponent json = event.getPacket().getChatComponents().read(0);
String normalText = ChatColor.stripColor(TextComponent.toLegacyText(ComponentSerializer.parse(json.getJson())));
String[] split = normalText.split(" ");
if (split.length >= 2 && split[1].equals("has") && blockedWords.stream().anyMatch(normalText::contains)) {
event.setCancelled(true);
}
}
});
the working code, but doesn't print out the broadcast message on 5.0.0
Expected behavior
Its meant to broadcast the message.
Screenshots
If applicable, add screenshots to help explain your problem.
Version Info
https://haste.olziedev.com/dotivorumu.kotlin
Additional context
Add any other context about the problem here.
With the update of mc 1.19 (wild update) you need to use PacketType.Play.Server.SYSTEM_CHAT
instead, bit it seems still like some messages are not send as package anymore