From 4e09a64abb460b76a44395f8da11e703380462dc Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Sat, 19 Apr 2014 23:11:56 +1200 Subject: [PATCH] Just make it a runnable. More convident for my plugins --- .../disguise/utilities/DisguiseUtilities.java | 37 ++++++++++--------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/src/me/libraryaddict/disguise/utilities/DisguiseUtilities.java b/src/me/libraryaddict/disguise/utilities/DisguiseUtilities.java index c71b34e7..6c68d565 100644 --- a/src/me/libraryaddict/disguise/utilities/DisguiseUtilities.java +++ b/src/me/libraryaddict/disguise/utilities/DisguiseUtilities.java @@ -263,15 +263,28 @@ public class DisguiseUtilities { return players; } - public static Object getProfileFromMojang(String playerName) { - return getProfileFromMojang(playerName, true); + public static Object getProfileFromMojang(final String playerName) { + return getProfileFromMojang(playerName, new Runnable() { + public void run() { + 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); + } + } + } + } + } + }); } /** * Thread safe to use. This returns a GameProfile. And if its GameProfile doesn't have a skin blob. Then it does a lookup - * using schedulers. + * using schedulers. The runnable is run once the GameProfile has been successfully dealt with */ - public static Object getProfileFromMojang(final String playerName, final boolean updateDisguises) { + public static Object getProfileFromMojang(final String playerName, final Runnable runnable) { if (gameProfiles.containsKey(playerName)) { if (gameProfiles.get(playerName) != null) { return gameProfiles.get(playerName); @@ -295,20 +308,8 @@ public class DisguiseUtilities { public void run() { if (gameProfiles.containsKey(playerName) && gameProfiles.get(playerName) == null) { gameProfiles.put(playerName, gameProfile); - if (updateDisguises) { - 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); - } - } - } - } + if (runnable != null) { + runnable.run(); } } }