From 9489d794d4c38501590f5d50290779cca2249f1a Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Tue, 3 Nov 2020 18:56:58 +1300 Subject: [PATCH] Try fix a ghost armor issue --- .../utilities/listeners/PlayerSkinHandler.java | 15 ++++++++++++--- .../packethandlers/PacketHandlerSpawn.java | 2 ++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/main/java/me/libraryaddict/disguise/utilities/listeners/PlayerSkinHandler.java b/src/main/java/me/libraryaddict/disguise/utilities/listeners/PlayerSkinHandler.java index 6f8e1146..78088c75 100644 --- a/src/main/java/me/libraryaddict/disguise/utilities/listeners/PlayerSkinHandler.java +++ b/src/main/java/me/libraryaddict/disguise/utilities/listeners/PlayerSkinHandler.java @@ -159,9 +159,7 @@ public class PlayerSkinHandler implements Listener { } public void handlePackets(Player player, PlayerDisguise disguise, LibsPackets packets) { - if (packets.getPackets().stream().anyMatch(p -> p.getType() == Server.NAMED_ENTITY_SPAWN)) { - return; - } + boolean spawn = packets.getPackets().stream().anyMatch(p -> p.getType() == Server.NAMED_ENTITY_SPAWN); List skins = getCache().getIfPresent(player); @@ -175,6 +173,17 @@ public class PlayerSkinHandler implements Listener { return; } + if (spawn) { + packets.getDelayedPacketsMap().entrySet().removeIf(entry -> { + entry.getValue() + .removeIf(packet -> packet.getType() == Server.ENTITY_EQUIPMENT && isRemove(skin, packet)); + + return entry.getValue().isEmpty(); + }); + + return; + } + packets.getPackets().removeIf(packet -> isRemove(skin, packet)); packets.getDelayedPacketsMap().entrySet().removeIf(entry -> { diff --git a/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerSpawn.java b/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerSpawn.java index 0aed4746..9bf54755 100644 --- a/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerSpawn.java +++ b/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerSpawn.java @@ -74,6 +74,7 @@ public class PacketHandlerSpawn implements IPacketHandler { */ private void constructSpawnPackets(final Player observer, LibsPackets packets, Entity disguisedEntity) { Disguise disguise = packets.getDisguise(); + boolean sendArmor = true; if (DisguiseConfig.isMiscDisguisesForLivingEnabled()) { if (disguise.getWatcher() instanceof LivingWatcher) { @@ -215,6 +216,7 @@ public class PacketHandlerSpawn implements IPacketHandler { boolean normalPlayerDisguise = observer == disguisedEntity || dist > (50 * 50) || (observer.getLocation().add(observer.getLocation().getDirection().normalize()) .distanceSquared(disguisedEntity.getLocation()) - dist) < 0.3; + sendArmor = normalPlayerDisguise; skin.setSleepPackets(!normalPlayerDisguise);