diff --git a/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/PacketsHandler.java b/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/PacketsHandler.java index 166bdcc2..9d8b5a3a 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/PacketsHandler.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/PacketsHandler.java @@ -10,9 +10,10 @@ import me.libraryaddict.disguise.disguisetypes.Disguise; import me.libraryaddict.disguise.disguisetypes.DisguiseType; import me.libraryaddict.disguise.utilities.DisguiseUtilities; import me.libraryaddict.disguise.utilities.LibsPremium; -import me.libraryaddict.disguise.utilities.packets.packethandlers.PacketHandlerAnimationCollect; import me.libraryaddict.disguise.utilities.packets.packethandlers.PacketHandlerAttachEntity; import me.libraryaddict.disguise.utilities.packets.packethandlers.PacketHandlerAttributes; +import me.libraryaddict.disguise.utilities.packets.packethandlers.PacketHandlerCollectItem; +import me.libraryaddict.disguise.utilities.packets.packethandlers.PacketHandlerEntityAnimation; import me.libraryaddict.disguise.utilities.packets.packethandlers.PacketHandlerEntityStatus; import me.libraryaddict.disguise.utilities.packets.packethandlers.PacketHandlerEquipment; import me.libraryaddict.disguise.utilities.packets.packethandlers.PacketHandlerHeadLook; @@ -40,8 +41,9 @@ public class PacketsHandler { List packetHandlers = new ArrayList<>(); packetHandlers.add(new PacketHandlerAttributes()); - packetHandlers.add(new PacketHandlerAnimationCollect()); + packetHandlers.add(new PacketHandlerCollectItem()); packetHandlers.add(new PacketHandlerEntityStatus()); + packetHandlers.add(new PacketHandlerEntityAnimation()); if (DisguiseConfig.isEquipmentPacketsEnabled()) { packetHandlers.add(new PacketHandlerEquipment()); diff --git a/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerAnimationCollect.java b/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerCollectItem.java similarity index 87% rename from plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerAnimationCollect.java rename to plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerCollectItem.java index d4f615f6..694dddc5 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerAnimationCollect.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerCollectItem.java @@ -8,10 +8,10 @@ import me.libraryaddict.disguise.utilities.packets.LibsPackets; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; -public class PacketHandlerAnimationCollect implements IPacketHandler { +public class PacketHandlerCollectItem implements IPacketHandler { @Override public PacketTypeCommon[] getHandledPackets() { - return new PacketTypeCommon[]{PacketType.Play.Server.COLLECT_ITEM, PacketType.Play.Server.ENTITY_ANIMATION}; + return new PacketTypeCommon[]{PacketType.Play.Server.COLLECT_ITEM}; } @Override diff --git a/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerEntityAnimation.java b/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerEntityAnimation.java new file mode 100644 index 00000000..791efcaf --- /dev/null +++ b/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerEntityAnimation.java @@ -0,0 +1,38 @@ +package me.libraryaddict.disguise.utilities.packets.packethandlers; + +import com.github.retrooper.packetevents.protocol.packettype.PacketType; +import com.github.retrooper.packetevents.protocol.packettype.PacketTypeCommon; +import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerEntityAnimation; +import me.libraryaddict.disguise.disguisetypes.Disguise; +import me.libraryaddict.disguise.utilities.packets.IPacketHandler; +import me.libraryaddict.disguise.utilities.packets.LibsPackets; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; + +public class PacketHandlerEntityAnimation implements IPacketHandler { + @Override + public PacketTypeCommon[] getHandledPackets() { + return new PacketTypeCommon[]{PacketType.Play.Server.ENTITY_ANIMATION}; + } + + @Override + public void handle(Disguise disguise, LibsPackets packets, Player observer, Entity entity) { + // All misc disguises cannot have animation events + if (disguise.isMiscDisguise()) { + packets.clear(); + return; + } + + // If this animation isn't a wake up, then don't need to handle + if (packets.getOriginalPacket().getType() != WrapperPlayServerEntityAnimation.EntityAnimationType.WAKE_UP) { + return; + } + + // Player disguises can play the animation + if (disguise.isPlayerDisguise()) { + return; + } + + packets.clear(); + } +}