Skip to content

Commit

Permalink
Fix bed interactions kicking players, fixes #787
Browse files Browse the repository at this point in the history
  • Loading branch information
libraryaddict committed Dec 10, 2024
1 parent b692fa5 commit 3c99810
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@
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;
Expand Down Expand Up @@ -40,8 +41,9 @@ public void registerPacketHandlers() {
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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
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
Expand Down
Original file line number Diff line number Diff line change
@@ -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();
}
}

0 comments on commit 3c99810

Please sign in to comment.