Use unique uuid's for each player disguise. Prevents skinless ppl
This commit is contained in:
		| @@ -1,7 +1,5 @@ | |||||||
| package me.libraryaddict.disguise.disguisetypes; | package me.libraryaddict.disguise.disguisetypes; | ||||||
|  |  | ||||||
| import java.util.UUID; |  | ||||||
|  |  | ||||||
| import org.apache.commons.lang.Validate; | import org.apache.commons.lang.Validate; | ||||||
| import org.bukkit.entity.Entity; | import org.bukkit.entity.Entity; | ||||||
| import org.bukkit.entity.Player; | import org.bukkit.entity.Player; | ||||||
| @@ -33,12 +31,16 @@ public class PlayerDisguise extends TargetedDisguise { | |||||||
|         this.setReplaceSounds(replaceSounds); |         this.setReplaceSounds(replaceSounds); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Deprecated |  | ||||||
|     public PlayerDisguise(String name, String skinToUse) { |     public PlayerDisguise(String name, String skinToUse) { | ||||||
|         this(name); |         this(name); | ||||||
|         setSkin(skinToUse); |         setSkin(skinToUse); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     public PlayerDisguise(WrappedGameProfile gameProfile) { | ||||||
|  |         this(gameProfile.getName()); | ||||||
|  |         this.gameProfile = gameProfile; | ||||||
|  |     } | ||||||
|  |  | ||||||
|     public PlayerDisguise addPlayer(Player player) { |     public PlayerDisguise addPlayer(Player player) { | ||||||
|         return (PlayerDisguise) super.addPlayer(player); |         return (PlayerDisguise) super.addPlayer(player); | ||||||
|     } |     } | ||||||
| @@ -67,23 +69,26 @@ public class PlayerDisguise extends TargetedDisguise { | |||||||
|         return disguise; |         return disguise; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Deprecated |     public void setGameProfile(WrappedGameProfile gameProfile) { | ||||||
|  |         this.gameProfile = ReflectionManager.getGameProfileWithThisSkin(null, gameProfile.getName(), gameProfile); | ||||||
|  |     } | ||||||
|  |  | ||||||
|     public WrappedGameProfile getGameProfile() { |     public WrappedGameProfile getGameProfile() { | ||||||
|         if (getSkin() != null) { |         if (gameProfile == null) { | ||||||
|             if (gameProfile != null) { |             if (getSkin() != null) { | ||||||
|                 return gameProfile; |                 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() { |     public String getName() { | ||||||
|         return playerName; |         return playerName; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Deprecated |  | ||||||
|     public String getSkin() { |     public String getSkin() { | ||||||
|         return skinToUse; |         return skinToUse; | ||||||
|     } |     } | ||||||
| @@ -147,7 +152,6 @@ public class PlayerDisguise extends TargetedDisguise { | |||||||
|         return (PlayerDisguise) super.setReplaceSounds(areSoundsReplaced); |         return (PlayerDisguise) super.setReplaceSounds(areSoundsReplaced); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Deprecated |  | ||||||
|     public PlayerDisguise setSkin(String skinToUse) { |     public PlayerDisguise setSkin(String skinToUse) { | ||||||
|         if (LibVersion.is1_7_6()) { |         if (LibVersion.is1_7_6()) { | ||||||
|             this.skinToUse = skinToUse; |             this.skinToUse = skinToUse; | ||||||
| @@ -167,6 +171,7 @@ public class PlayerDisguise extends TargetedDisguise { | |||||||
|                             if (!gameProfile.getProperties().isEmpty() && DisguiseUtilities.isDisguiseInUse(PlayerDisguise.this)) { |                             if (!gameProfile.getProperties().isEmpty() && DisguiseUtilities.isDisguiseInUse(PlayerDisguise.this)) { | ||||||
|                                 DisguiseUtilities.refreshTrackers(PlayerDisguise.this); |                                 DisguiseUtilities.refreshTrackers(PlayerDisguise.this); | ||||||
|                             } |                             } | ||||||
|  |                             currentLookup = null; | ||||||
|                         } |                         } | ||||||
|                     } |                     } | ||||||
|                 }; |                 }; | ||||||
| @@ -186,7 +191,6 @@ public class PlayerDisguise extends TargetedDisguise { | |||||||
|      *            GameProfile |      *            GameProfile | ||||||
|      * @return |      * @return | ||||||
|      */ |      */ | ||||||
|     @Deprecated |  | ||||||
|     public PlayerDisguise setSkin(WrappedGameProfile gameProfile) { |     public PlayerDisguise setSkin(WrappedGameProfile gameProfile) { | ||||||
|         if (gameProfile == null) { |         if (gameProfile == null) { | ||||||
|             this.gameProfile = null; |             this.gameProfile = null; | ||||||
| @@ -196,8 +200,7 @@ public class PlayerDisguise extends TargetedDisguise { | |||||||
|  |  | ||||||
|         Validate.notEmpty(gameProfile.getName(), "Name must be set"); |         Validate.notEmpty(gameProfile.getName(), "Name must be set"); | ||||||
|         this.skinToUse = gameProfile.getName(); |         this.skinToUse = gameProfile.getName(); | ||||||
|         this.gameProfile = ReflectionManager.getGameProfileWithThisSkin( |         this.gameProfile = ReflectionManager.getGameProfileWithThisSkin(null, getName(), gameProfile); | ||||||
|                 gameProfile.getId() != null ? UUID.fromString(gameProfile.getId()) : null, getName(), gameProfile); |  | ||||||
|         return this; |         return this; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -483,7 +483,7 @@ public class DisguiseUtilities { | |||||||
|                         && (!gameProfile.getName().equals( |                         && (!gameProfile.getName().equals( | ||||||
|                                 disguise.getSkin() != null && LibVersion.is1_7_6() ? disguise.getSkin() : disguise.getName()) || (LibVersion |                                 disguise.getSkin() != null && LibVersion.is1_7_6() ? disguise.getSkin() : disguise.getName()) || (LibVersion | ||||||
|                                 .is1_7_6() && !gameProfile.getProperties().isEmpty()))) { |                                 .is1_7_6() && !gameProfile.getProperties().isEmpty()))) { | ||||||
|                     // TODO Resend for UUID? Might need to in the future. |                     disguise.setGameProfile(gameProfile); | ||||||
|                     DisguiseUtilities.refreshTrackers(disguise); |                     DisguiseUtilities.refreshTrackers(disguise); | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
| @@ -589,9 +589,7 @@ public class DisguiseUtilities { | |||||||
|      * This is called on a thread as it is thread blocking |      * This is called on a thread as it is thread blocking | ||||||
|      */ |      */ | ||||||
|     public static WrappedGameProfile lookupGameProfile(String playerName) { |     public static WrappedGameProfile lookupGameProfile(String playerName) { | ||||||
|         WrappedGameProfile gameprofile = ReflectionManager.grabProfileAddUUID(playerName); |         return ReflectionManager.grabProfileAddUUID(playerName); | ||||||
|         return ReflectionManager.getGameProfileWithThisSkin(null, gameprofile.getName(), |  | ||||||
|                 ReflectionManager.getSkullBlob(gameprofile)); |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user