From 5ab0f7e53d61d45ed01ec53a01dd63c03bdf62d3 Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Mon, 29 Sep 2014 17:05:04 +1300 Subject: [PATCH] Use unique uuid's for each player disguise. Prevents skinless ppl --- .../disguisetypes/PlayerDisguise.java | 33 ++++++++++--------- .../disguise/utilities/DisguiseUtilities.java | 6 ++-- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/src/me/libraryaddict/disguise/disguisetypes/PlayerDisguise.java b/src/me/libraryaddict/disguise/disguisetypes/PlayerDisguise.java index e5472d68..0746a3bb 100644 --- a/src/me/libraryaddict/disguise/disguisetypes/PlayerDisguise.java +++ b/src/me/libraryaddict/disguise/disguisetypes/PlayerDisguise.java @@ -1,7 +1,5 @@ package me.libraryaddict.disguise.disguisetypes; -import java.util.UUID; - import org.apache.commons.lang.Validate; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; @@ -33,12 +31,16 @@ public class PlayerDisguise extends TargetedDisguise { this.setReplaceSounds(replaceSounds); } - @Deprecated public PlayerDisguise(String name, String skinToUse) { this(name); setSkin(skinToUse); } + public PlayerDisguise(WrappedGameProfile gameProfile) { + this(gameProfile.getName()); + this.gameProfile = gameProfile; + } + public PlayerDisguise addPlayer(Player player) { return (PlayerDisguise) super.addPlayer(player); } @@ -67,23 +69,26 @@ public class PlayerDisguise extends TargetedDisguise { return disguise; } - @Deprecated + public void setGameProfile(WrappedGameProfile gameProfile) { + this.gameProfile = ReflectionManager.getGameProfileWithThisSkin(null, gameProfile.getName(), gameProfile); + } + public WrappedGameProfile getGameProfile() { - if (getSkin() != null) { - if (gameProfile != null) { - return gameProfile; + if (gameProfile == null) { + if (getSkin() != null) { + gameProfile = ReflectionManager.getGameProfile(null, getName()); + } else { + gameProfile = ReflectionManager.getGameProfileWithThisSkin(null, getName(), + DisguiseUtilities.getProfileFromMojang(this)); } - return ReflectionManager.getGameProfile(null, getName()); - } else { - return DisguiseUtilities.getProfileFromMojang(this); } + return gameProfile; } public String getName() { return playerName; } - @Deprecated public String getSkin() { return skinToUse; } @@ -147,7 +152,6 @@ public class PlayerDisguise extends TargetedDisguise { return (PlayerDisguise) super.setReplaceSounds(areSoundsReplaced); } - @Deprecated public PlayerDisguise setSkin(String skinToUse) { if (LibVersion.is1_7_6()) { this.skinToUse = skinToUse; @@ -167,6 +171,7 @@ public class PlayerDisguise extends TargetedDisguise { if (!gameProfile.getProperties().isEmpty() && DisguiseUtilities.isDisguiseInUse(PlayerDisguise.this)) { DisguiseUtilities.refreshTrackers(PlayerDisguise.this); } + currentLookup = null; } } }; @@ -186,7 +191,6 @@ public class PlayerDisguise extends TargetedDisguise { * GameProfile * @return */ - @Deprecated public PlayerDisguise setSkin(WrappedGameProfile gameProfile) { if (gameProfile == null) { this.gameProfile = null; @@ -196,8 +200,7 @@ public class PlayerDisguise extends TargetedDisguise { Validate.notEmpty(gameProfile.getName(), "Name must be set"); this.skinToUse = gameProfile.getName(); - this.gameProfile = ReflectionManager.getGameProfileWithThisSkin( - gameProfile.getId() != null ? UUID.fromString(gameProfile.getId()) : null, getName(), gameProfile); + this.gameProfile = ReflectionManager.getGameProfileWithThisSkin(null, getName(), gameProfile); return this; } diff --git a/src/me/libraryaddict/disguise/utilities/DisguiseUtilities.java b/src/me/libraryaddict/disguise/utilities/DisguiseUtilities.java index cd5c0c5c..ad20664f 100644 --- a/src/me/libraryaddict/disguise/utilities/DisguiseUtilities.java +++ b/src/me/libraryaddict/disguise/utilities/DisguiseUtilities.java @@ -483,7 +483,7 @@ public class DisguiseUtilities { && (!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. + disguise.setGameProfile(gameProfile); DisguiseUtilities.refreshTrackers(disguise); } } @@ -589,9 +589,7 @@ public class DisguiseUtilities { * This is called on a thread as it is thread blocking */ public static WrappedGameProfile lookupGameProfile(String playerName) { - WrappedGameProfile gameprofile = ReflectionManager.grabProfileAddUUID(playerName); - return ReflectionManager.getGameProfileWithThisSkin(null, gameprofile.getName(), - ReflectionManager.getSkullBlob(gameprofile)); + return ReflectionManager.grabProfileAddUUID(playerName); } /**