From 2a20013de5b8f44f2237140870d117bb9392a1b3 Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Thu, 22 Dec 2016 14:11:03 +1300 Subject: [PATCH] Fixed the disguises fetching player skins before its even used --- .../disguisetypes/PlayerDisguise.java | 46 +++++++++++-------- 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/src/me/libraryaddict/disguise/disguisetypes/PlayerDisguise.java b/src/me/libraryaddict/disguise/disguisetypes/PlayerDisguise.java index 31283196..d8a3db4b 100644 --- a/src/me/libraryaddict/disguise/disguisetypes/PlayerDisguise.java +++ b/src/me/libraryaddict/disguise/disguisetypes/PlayerDisguise.java @@ -237,6 +237,33 @@ public class PlayerDisguise extends TargetedDisguise { return (PlayerDisguise) super.setReplaceSounds(areSoundsReplaced); } + @Override + public boolean startDisguise() { + if (isDisguiseInUse() || skinToUse == null) + return super.startDisguise(); + + currentLookup = new LibsProfileLookup() { + @Override + public void onLookup(WrappedGameProfile gameProfile) { + if (currentLookup != this || gameProfile == null) + return; + + setSkin(gameProfile); + + currentLookup = null; + } + }; + + WrappedGameProfile gameProfile = DisguiseUtilities.getProfileFromMojang(this.skinToUse, currentLookup, + LibsDisguises.getInstance().getConfig().getBoolean("ContactMojangServers", true)); + + if (gameProfile != null) { + setSkin(gameProfile); + } + + return super.startDisguise(); + } + public PlayerDisguise setSkin(String newSkin) { if (newSkin != null && newSkin.length() > 50) { try { @@ -258,25 +285,6 @@ public class PlayerDisguise extends TargetedDisguise { if (newSkin.length() > 16) { skinToUse = newSkin.substring(0, 16); } - - currentLookup = new LibsProfileLookup() { - @Override - public void onLookup(WrappedGameProfile gameProfile) { - if (currentLookup != this || gameProfile == null) - return; - - setSkin(gameProfile); - - currentLookup = null; - } - }; - - WrappedGameProfile gameProfile = DisguiseUtilities.getProfileFromMojang(this.skinToUse, currentLookup, - LibsDisguises.getInstance().getConfig().getBoolean("ContactMojangServers", true)); - - if (gameProfile != null) { - setSkin(gameProfile); - } } return this;