From 3734465e0b4d537ff956d1bac594170763a9951b Mon Sep 17 00:00:00 2001 From: Pim van der Loos Date: Tue, 5 Jan 2021 13:21:02 +0100 Subject: [PATCH] Improve checking if player is temporary - Now using ProtocolLib's event#isPlayerTemporary() to check if the player in a PacketEvent is a temporary one instead of relying on the implementation of temporary players. --- .../packetlisteners/PacketListenerInventory.java | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/main/java/me/libraryaddict/disguise/utilities/packets/packetlisteners/PacketListenerInventory.java b/src/main/java/me/libraryaddict/disguise/utilities/packets/packetlisteners/PacketListenerInventory.java index 4c7ecffc..0cefdce9 100644 --- a/src/main/java/me/libraryaddict/disguise/utilities/packets/packetlisteners/PacketListenerInventory.java +++ b/src/main/java/me/libraryaddict/disguise/utilities/packets/packetlisteners/PacketListenerInventory.java @@ -8,7 +8,6 @@ import com.comphenix.protocol.events.PacketAdapter; import com.comphenix.protocol.events.PacketContainer; import com.comphenix.protocol.events.PacketEvent; import com.comphenix.protocol.reflect.StructureModifier; -import com.comphenix.protocol.utility.ByteBuddyGenerated; import me.libraryaddict.disguise.DisguiseAPI; import me.libraryaddict.disguise.LibsDisguises; import me.libraryaddict.disguise.disguisetypes.Disguise; @@ -37,15 +36,12 @@ public class PacketListenerInventory extends PacketAdapter { @Override public void onPacketReceiving(final PacketEvent event) { - if (event.isCancelled()) + if (event.isCancelled() || event.isPlayerTemporary()) return; final Player player = event.getPlayer(); - if (player.getName().contains("UNKNOWN[")) // If the player is temporary - return; - - if (player instanceof ByteBuddyGenerated || player.getVehicle() != null) { + if (player.getVehicle() != null) { return; } @@ -251,7 +247,7 @@ public class PacketListenerInventory extends PacketAdapter { Player player = event.getPlayer(); // If the inventory is the players inventory - if (player instanceof ByteBuddyGenerated || player.getVehicle() != null || + if (event.isPlayerTemporary() || player.getVehicle() != null || event.getPacket().getIntegers().read(0) != 0) { return; }