Convert plain to json instead of doing component conversion in DeathListener (#3821)

Closes https://github.com/ViaVersion/ViaVersion/issues/3817
This commit is contained in:
EnZaXD 2024-05-02 17:09:27 +02:00 committed by GitHub
parent d3af70d76c
commit c113e19d41
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -24,6 +24,7 @@ import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.bukkit.listeners.ViaBukkitListener;
import com.viaversion.viaversion.protocols.protocol1_9to1_8.ClientboundPackets1_9;
import com.viaversion.viaversion.protocols.protocol1_9to1_8.Protocol1_9To1_8;
import com.viaversion.viaversion.util.ComponentUtil;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -58,12 +59,12 @@ public class DeathListener extends ViaBukkitListener {
// If online
UserConnection userConnection = getUserConnection(p);
if (userConnection != null) {
PacketWrapper wrapper = PacketWrapper.create(ClientboundPackets1_9.COMBAT_EVENT, null, userConnection);
PacketWrapper wrapper = PacketWrapper.create(ClientboundPackets1_9.COMBAT_EVENT, userConnection);
try {
wrapper.write(Type.VAR_INT, 2); // Event - Entity dead
wrapper.write(Type.VAR_INT, p.getEntityId()); // Player ID
wrapper.write(Type.INT, p.getEntityId()); // Entity ID
Protocol1_9To1_8.STRING_TO_JSON.write(wrapper, msg); // Message
wrapper.write(Type.COMPONENT, ComponentUtil.plainToJson(msg)); // Message
wrapper.scheduleSend(Protocol1_9To1_8.class);
} catch (Exception e) {