From 5db33ffcf6c03c575a4d11a9de21de0293e37184 Mon Sep 17 00:00:00 2001 From: Andrew Date: Sun, 7 Jul 2013 02:34:12 +1200 Subject: [PATCH] Don't deep clone meta. Doing that already! Cancel attributes packet. Non-living dont send it.. --- src/me/libraryaddict/disguise/LibsDisguises.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/me/libraryaddict/disguise/LibsDisguises.java b/src/me/libraryaddict/disguise/LibsDisguises.java index 4a11a33d..41cde33e 100644 --- a/src/me/libraryaddict/disguise/LibsDisguises.java +++ b/src/me/libraryaddict/disguise/LibsDisguises.java @@ -29,6 +29,7 @@ import com.comphenix.protocol.ProtocolManager; import com.comphenix.protocol.events.ConnectionSide; import com.comphenix.protocol.events.ListenerPriority; import com.comphenix.protocol.events.PacketAdapter; +import com.comphenix.protocol.events.PacketContainer; import com.comphenix.protocol.events.PacketEvent; import com.comphenix.protocol.reflect.StructureModifier; @@ -57,7 +58,7 @@ public class LibsDisguises extends JavaPlugin implements Listener { Packets.Server.NAMED_ENTITY_SPAWN, Packets.Server.ENTITY_METADATA, Packets.Server.ARM_ANIMATION, Packets.Server.REL_ENTITY_MOVE_LOOK, Packets.Server.ENTITY_LOOK, Packets.Server.ENTITY_TELEPORT, Packets.Server.ADD_EXP_ORB, Packets.Server.VEHICLE_SPAWN, Packets.Server.MOB_SPAWN, - Packets.Server.ENTITY_PAINTING, Packets.Server.COLLECT) { + Packets.Server.ENTITY_PAINTING, Packets.Server.COLLECT, 44) { @Override public void onPacketSending(PacketEvent event) { try { @@ -66,9 +67,13 @@ public class LibsDisguises extends JavaPlugin implements Listener { org.bukkit.entity.Entity entity = entityModifer.read((Packets.Server.COLLECT == event.getPacketID() ? 1 : 0)); if (DisguiseAPI.isDisguised(entity)) { Disguise disguise = DisguiseAPI.getDisguise(entity); - if (event.getPacketID() == Packets.Server.ENTITY_METADATA) { - event.setPacket(event.getPacket().deepClone()); + if (event.getPacketID() == 44) { + if (disguise.getType().isMisc() && entity.getType().isAlive()) + event.setCancelled(true); + } else if (event.getPacketID() == Packets.Server.ENTITY_METADATA) { + event.setPacket(new PacketContainer(event.getPacketID())); StructureModifier mods = event.getPacket().getModifier(); + mods.write(0, entity.getEntityId()); mods.write(1, disguise.getWatcher() .convert((List) event.getPacket().getModifier().read(1)));