From 5bfd6c5541d1214dae9bda1c2ef0f0278b743ca1 Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Sun, 1 Jun 2014 06:53:01 +1200 Subject: [PATCH] Fix outdated code which would make huge problems because of previous fix --- .../disguise/disguisetypes/PlayerDisguise.java | 7 ++++++- .../disguise/utilities/DisguiseUtilities.java | 18 +++++++----------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/me/libraryaddict/disguise/disguisetypes/PlayerDisguise.java b/src/me/libraryaddict/disguise/disguisetypes/PlayerDisguise.java index 42d4d16a..f2f1d1c8 100644 --- a/src/me/libraryaddict/disguise/disguisetypes/PlayerDisguise.java +++ b/src/me/libraryaddict/disguise/disguisetypes/PlayerDisguise.java @@ -1,5 +1,7 @@ package me.libraryaddict.disguise.disguisetypes; +import org.bukkit.entity.Player; + import me.libraryaddict.disguise.utilities.DisguiseUtilities; import me.libraryaddict.disguise.utilities.LibsProfileLookup; import me.libraryaddict.disguise.utilities.ReflectionManager; @@ -58,7 +60,7 @@ public class PlayerDisguise extends TargetedDisguise { } return ReflectionManager.getGameProfile(null, getName()); } else { - return DisguiseUtilities.getProfileFromMojang(getName()); + return DisguiseUtilities.getProfileFromMojang(this); } } @@ -100,6 +102,9 @@ public class PlayerDisguise extends TargetedDisguise { setGameProfile(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 87b95847..dfff3b14 100644 --- a/src/me/libraryaddict/disguise/utilities/DisguiseUtilities.java +++ b/src/me/libraryaddict/disguise/utilities/DisguiseUtilities.java @@ -294,20 +294,16 @@ public class DisguiseUtilities { return players; } - public static Object getProfileFromMojang(final String playerName) { - return getProfileFromMojang(playerName, new LibsProfileLookup() { + public static Object getProfileFromMojang(final PlayerDisguise disguise) { + return getProfileFromMojang(disguise.getName(), new LibsProfileLookup() { @Override public void onLookup(Object gameProfile) { - getAddedByPlugins().remove(playerName); - 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); - } - } + getAddedByPlugins().remove(disguise.getName()); + if (DisguiseAPI.isDisguiseInUse(disguise)) { + DisguiseUtilities.refreshTrackers((TargetedDisguise) disguise); + if (disguise.getEntity() instanceof Player && disguise.isSelfDisguiseVisible()) { + DisguiseUtilities.sendSelfDisguise((Player) disguise.getEntity(), disguise); } } }