mirror of
https://github.com/libraryaddict/LibsDisguises.git
synced 2025-01-07 19:18:01 +01:00
Fix bed interactions kicking players, fixes #787
This commit is contained in:
parent
b692fa52cf
commit
3c99810f38
@ -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<IPacketHandler> 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());
|
||||
|
@ -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
|
@ -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<WrapperPlayServerEntityAnimation> {
|
||||
@Override
|
||||
public PacketTypeCommon[] getHandledPackets() {
|
||||
return new PacketTypeCommon[]{PacketType.Play.Server.ENTITY_ANIMATION};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(Disguise disguise, LibsPackets<WrapperPlayServerEntityAnimation> 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();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user