From 5f03b75eb7710ea53065c2689b13159f9b844ea9 Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Wed, 16 Apr 2014 16:26:19 +1200 Subject: [PATCH] Refresh all disguises using that playername. Not just the caller --- .../disguise/utilities/DisguiseUtilities.java | 20 +++++++++++++------ .../disguise/utilities/PacketsManager.java | 2 +- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/me/libraryaddict/disguise/utilities/DisguiseUtilities.java b/src/me/libraryaddict/disguise/utilities/DisguiseUtilities.java index 7de55268..4d3d1a36 100644 --- a/src/me/libraryaddict/disguise/utilities/DisguiseUtilities.java +++ b/src/me/libraryaddict/disguise/utilities/DisguiseUtilities.java @@ -14,6 +14,7 @@ import me.libraryaddict.disguise.DisguiseAPI; import me.libraryaddict.disguise.LibsDisguises; import me.libraryaddict.disguise.disguisetypes.Disguise; import me.libraryaddict.disguise.disguisetypes.DisguiseType; +import me.libraryaddict.disguise.disguisetypes.PlayerDisguise; import me.libraryaddict.disguise.disguisetypes.TargetedDisguise; import me.libraryaddict.disguise.disguisetypes.watchers.AgeableWatcher; import me.libraryaddict.disguise.disguisetypes.watchers.ZombieWatcher; @@ -269,11 +270,11 @@ public class DisguiseUtilities { return players; } - public static Object getProfile(final Disguise disguise, final String playerName) { + public static Object getProfile(final String playerName) { Player player = Bukkit.getPlayerExact(playerName); if (player != null) { return ReflectionManager.getGameProfile(player); - } else if (disguise != null) { + } else { if (gameProfiles.containsKey(playerName)) { if (gameProfiles.get(playerName) != null) { return gameProfiles.get(playerName); @@ -293,10 +294,17 @@ public class DisguiseUtilities { if (gameProfiles.containsKey(playerName) && gameProfiles.get(playerName) == null) { gameProfiles.put(playerName, gameProfile); } - if (DisguiseUtilities.isDisguiseInUse(disguise)) { - DisguiseUtilities.refreshTrackers((TargetedDisguise) disguise); - if (disguise.getEntity() instanceof Player && disguise.isSelfDisguiseVisible()) { - DisguiseUtilities.sendSelfDisguise((Player) disguise.getEntity(), disguise); + for (HashSet disguises : DisguiseUtilities.getDisguises().values()) { + for (TargetedDisguise disguise : disguises) { + if (disguise.getType() == DisguiseType.PLAYER + && ((PlayerDisguise) disguise).getName().equals(playerName)) { + DisguiseUtilities.refreshTrackers((TargetedDisguise) disguise); + if (disguise.getEntity() instanceof Player + && disguise.isSelfDisguiseVisible()) { + DisguiseUtilities.sendSelfDisguise((Player) disguise.getEntity(), + disguise); + } + } } } } diff --git a/src/me/libraryaddict/disguise/utilities/PacketsManager.java b/src/me/libraryaddict/disguise/utilities/PacketsManager.java index aec5734e..2cd9a659 100644 --- a/src/me/libraryaddict/disguise/utilities/PacketsManager.java +++ b/src/me/libraryaddict/disguise/utilities/PacketsManager.java @@ -201,7 +201,7 @@ public class PacketsManager { } } else { Object gameProfile = null; - gameProfile = DisguiseUtilities.getProfile(disguise, ((PlayerDisguise) disguise).getName()); + gameProfile = DisguiseUtilities.getProfile(((PlayerDisguise) disguise).getName()); spawnPackets[0].getModifier().write(1, gameProfile); } StructureModifier intMods = spawnPackets[0].getIntegers();