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.
This commit is contained in:
Pim van der Loos 2021-01-05 13:21:02 +01:00
parent 4adcc8aa53
commit 3734465e0b
No known key found for this signature in database
GPG Key ID: C16F020ADAE6D5A8

View File

@ -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;
}