mirror of
https://github.com/dmulloy2/ProtocolLib.git
synced 2024-11-27 13:15:52 +01:00
use correct packet for chat extensions on 1.19+ (#1824)
This commit is contained in:
parent
8876ce323b
commit
2be216899a
@ -17,15 +17,16 @@
|
||||
|
||||
package com.comphenix.protocol.utility;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.comphenix.protocol.PacketType;
|
||||
import com.comphenix.protocol.ProtocolManager;
|
||||
import com.comphenix.protocol.events.PacketContainer;
|
||||
import com.comphenix.protocol.wrappers.EnumWrappers;
|
||||
import com.comphenix.protocol.wrappers.WrappedChatComponent;
|
||||
import com.google.common.base.Strings;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -56,7 +57,15 @@ public final class ChatExtensions {
|
||||
List<PacketContainer> packets = new ArrayList<>();
|
||||
WrappedChatComponent[] components = WrappedChatComponent.fromChatMessage(message);
|
||||
for (WrappedChatComponent component : components) {
|
||||
PacketContainer packet = new PacketContainer(PacketType.Play.Server.CHAT);
|
||||
PacketContainer packet;
|
||||
if (MinecraftVersion.WILD_UPDATE.atOrAbove()) {
|
||||
// since 1.19 system chat is extracted into a separate packet
|
||||
packet = new PacketContainer(PacketType.Play.Server.SYSTEM_CHAT);
|
||||
|
||||
packet.getStrings().write(0, component.getJson());
|
||||
packet.getBooleans().write(0, false);
|
||||
} else {
|
||||
packet = new PacketContainer(PacketType.Play.Server.CHAT);
|
||||
packet.getChatComponents().write(0, component);
|
||||
|
||||
// 1.12+
|
||||
@ -65,6 +74,7 @@ public final class ChatExtensions {
|
||||
packet.getBytes().writeSafely(0, (byte) 1);
|
||||
// 1.16+
|
||||
packet.getUUIDs().writeSafely(0, SERVER_UUID);
|
||||
}
|
||||
|
||||
packets.add(packet);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user