From 4105b953bf11f9f9f3c1d7622a6a32403a19123e Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Sat, 15 Feb 2020 20:55:29 +1300 Subject: [PATCH] Send remove player info even if disguise is removed --- .../utilities/packets/LibsPackets.java | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/main/java/me/libraryaddict/disguise/utilities/packets/LibsPackets.java b/src/main/java/me/libraryaddict/disguise/utilities/packets/LibsPackets.java index 8795d153..ffd0fce2 100644 --- a/src/main/java/me/libraryaddict/disguise/utilities/packets/LibsPackets.java +++ b/src/main/java/me/libraryaddict/disguise/utilities/packets/LibsPackets.java @@ -93,17 +93,22 @@ public class LibsPackets { final boolean isRemoveCancel = isSpawnPacket && entry.getKey() >= removeMetaAt && removeMetaAt >= 0; Bukkit.getScheduler().scheduleSyncDelayedTask(LibsDisguises.getInstance(), () -> { - if (!disguise.isDisguiseInUse()) { - if (isRemoveCancel) { - PacketsManager.getPacketsHandler().removeCancel(disguise, observer); - } - - return; - } if (isRemoveCancel) { PacketsManager.getPacketsHandler().removeCancel(disguise, observer); + } + if (!disguise.isDisguiseInUse()) { + ArrayList packets = entry.getValue(); + + if (packets.stream().noneMatch(p -> p.getType() == PacketType.Play.Server.PLAYER_INFO)) { + return; + } + + packets.removeIf(p -> p.getType() != PacketType.Play.Server.PLAYER_INFO); + } + + if (isRemoveCancel) { if (isSendArmor()) { for (EquipmentSlot slot : EquipmentSlot.values()) { PacketContainer packet = createPacket(slot);