From 992e416edfdedf2f1692650a2c2b6710c180eb0b Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Sat, 21 Jun 2014 07:58:37 +1200 Subject: [PATCH] Send self disguise in the same tracker refresh entry.. --- .../disguise/disguisetypes/PlayerDisguise.java | 4 ---- .../disguise/utilities/DisguiseUtilities.java | 15 ++++++++------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/me/libraryaddict/disguise/disguisetypes/PlayerDisguise.java b/src/me/libraryaddict/disguise/disguisetypes/PlayerDisguise.java index c6231160..e0aab30b 100644 --- a/src/me/libraryaddict/disguise/disguisetypes/PlayerDisguise.java +++ b/src/me/libraryaddict/disguise/disguisetypes/PlayerDisguise.java @@ -3,7 +3,6 @@ package me.libraryaddict.disguise.disguisetypes; import java.util.UUID; import org.apache.commons.lang.Validate; -import org.bukkit.entity.Player; import com.comphenix.protocol.wrappers.WrappedGameProfile; @@ -102,9 +101,6 @@ public class PlayerDisguise extends TargetedDisguise { setSkin(gameProfile); if (DisguiseUtilities.isDisguiseInUse(PlayerDisguise.this)) { DisguiseUtilities.refreshTrackers(PlayerDisguise.this); - if (getEntity() instanceof Player && isSelfDisguiseVisible()) { - DisguiseUtilities.sendSelfDisguise((Player) getEntity(), PlayerDisguise.this); - } } } } diff --git a/src/me/libraryaddict/disguise/utilities/DisguiseUtilities.java b/src/me/libraryaddict/disguise/utilities/DisguiseUtilities.java index 7fe19da6..f758dabd 100644 --- a/src/me/libraryaddict/disguise/utilities/DisguiseUtilities.java +++ b/src/me/libraryaddict/disguise/utilities/DisguiseUtilities.java @@ -345,9 +345,6 @@ public class DisguiseUtilities { } if (DisguiseAPI.isDisguiseInUse(disguise)) { DisguiseUtilities.refreshTrackers(disguise); - if (disguise.getEntity() instanceof Player && disguise.isSelfDisguiseVisible()) { - DisguiseUtilities.sendSelfDisguise((Player) disguise.getEntity(), disguise); - } } } }); @@ -518,6 +515,9 @@ public class DisguiseUtilities { */ public static void refreshTrackers(TargetedDisguise disguise) { try { + if (disguise.isDisguiseInUse() && disguise.getEntity() instanceof Player) { + DisguiseUtilities.sendSelfDisguise((Player) disguise.getEntity(), disguise); + } Object entityTrackerEntry = ReflectionManager.getEntityTrackerEntry(disguise.getEntity()); if (entityTrackerEntry != null) { HashSet trackedPlayers = (HashSet) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers").get( @@ -532,7 +532,7 @@ public class DisguiseUtilities { // if (entity instanceof Player && !((Player) ReflectionManager.getBukkitEntity(player)).canSee((Player) // entity)) // continue; - if (player == disguise.getEntity() || disguise.canSee(player.getName())) { + if (disguise.canSee(player.getName())) { clear.invoke(entityTrackerEntry, p); updatePlayer.invoke(entityTrackerEntry, p); } @@ -609,9 +609,10 @@ public class DisguiseUtilities { /** * Sends the self disguise to the player */ - public static void sendSelfDisguise(final Player player, final Disguise disguise) { + public static void sendSelfDisguise(final Player player, final TargetedDisguise disguise) { try { - if (!player.isValid() || !player.isOnline() || !disguise.isSelfDisguiseVisible()) { + if (!disguise.isDisguiseInUse() || !player.isValid() || !player.isOnline() || !disguise.isSelfDisguiseVisible() + || !disguise.canSee(player)) { return; } Object entityTrackerEntry = ReflectionManager.getEntityTrackerEntry(player); @@ -748,7 +749,7 @@ public class DisguiseUtilities { return; } selfDisguised.add(player.getUniqueId()); - sendSelfDisguise(player, disguise); + sendSelfDisguise(player, (TargetedDisguise) disguise); if (disguise.isHidingArmorFromSelf() || disguise.isHidingHeldItemFromSelf()) { if (PacketsManager.isInventoryListenerEnabled()) { player.updateInventory();