From af9dfb8d6e706ea17f19696dbf5b552e1fe14bf0 Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Wed, 27 Aug 2014 04:25:02 +1200 Subject: [PATCH] The name to fetch is either the skin or name. Not both. Move the runnables down to make it accessible and prevent the invalid names using it --- .../disguise/utilities/DisguiseUtilities.java | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/me/libraryaddict/disguise/utilities/DisguiseUtilities.java b/src/me/libraryaddict/disguise/utilities/DisguiseUtilities.java index 7271083a..996ecbe7 100644 --- a/src/me/libraryaddict/disguise/utilities/DisguiseUtilities.java +++ b/src/me/libraryaddict/disguise/utilities/DisguiseUtilities.java @@ -337,17 +337,19 @@ public class DisguiseUtilities { } public static WrappedGameProfile getProfileFromMojang(final PlayerDisguise disguise) { - final boolean remove = getAddedByPlugins().contains(disguise.getName().toLowerCase()); - return getProfileFromMojang(disguise.getName(), new LibsProfileLookup() { + final String nameToFetch = disguise.getSkin() != null ? disguise.getSkin() : disguise.getName(); + final boolean remove = getAddedByPlugins().contains(nameToFetch.toLowerCase()); + return getProfileFromMojang(nameToFetch, new LibsProfileLookup() { @Override public void onLookup(WrappedGameProfile gameProfile) { if (remove) { - getAddedByPlugins().remove(disguise.getName().toLowerCase()); + getAddedByPlugins().remove(nameToFetch.toLowerCase()); } if (DisguiseAPI.isDisguiseInUse(disguise) - && (!gameProfile.getName().equals(disguise.getName()) || (LibVersion.is1_7_6() && !gameProfile - .getProperties().isEmpty()))) { + && (!gameProfile.getName().equals( + disguise.getSkin() != null && LibVersion.is1_7_6() ? disguise.getSkin() : disguise.getName()) || (LibVersion + .is1_7_6() && !gameProfile.getProperties().isEmpty()))) { // TODO Resend for UUID? Might need to in the future. DisguiseUtilities.refreshTrackers(disguise); } @@ -411,12 +413,14 @@ public class DisguiseUtilities { } } }); - if (runnable != null) { - if (!runnables.containsKey(playerName)) { - runnables.put(playerName, new ArrayList()); - } - runnables.get(playerName).add(runnable); + } else { + return ReflectionManager.getGameProfile(null, origName); + } + if (runnable != null) { + if (!runnables.containsKey(playerName)) { + runnables.put(playerName, new ArrayList()); } + runnables.get(playerName).add(runnable); } return ReflectionManager.getGameProfile(null, origName); }