Fixed trying to use properties before they were added

This commit is contained in:
libraryaddict 2014-07-26 11:10:48 +12:00
parent f81e7bba6b
commit 0eba652926
3 changed files with 7 additions and 4 deletions

@ -151,7 +151,7 @@ public class PlayerDisguise extends TargetedDisguise {
if (skinToUse.length() > 16) { if (skinToUse.length() > 16) {
this.skinToUse = skinToUse.substring(0, 16); this.skinToUse = skinToUse.substring(0, 16);
} }
if (LibVersion.is1_7()) { if (LibVersion.is1_7_6()) {
currentLookup = new LibsProfileLookup() { currentLookup = new LibsProfileLookup() {
@Override @Override

@ -20,6 +20,7 @@ import me.libraryaddict.disguise.disguisetypes.TargetedDisguise;
import me.libraryaddict.disguise.disguisetypes.watchers.AgeableWatcher; import me.libraryaddict.disguise.disguisetypes.watchers.AgeableWatcher;
import me.libraryaddict.disguise.disguisetypes.watchers.ZombieWatcher; import me.libraryaddict.disguise.disguisetypes.watchers.ZombieWatcher;
import me.libraryaddict.disguise.disguisetypes.TargetedDisguise.TargetType; import me.libraryaddict.disguise.disguisetypes.TargetedDisguise.TargetType;
import me.libraryaddict.disguise.utilities.ReflectionManager.LibVersion;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
@ -344,7 +345,7 @@ public class DisguiseUtilities {
getAddedByPlugins().remove(disguise.getName().toLowerCase()); getAddedByPlugins().remove(disguise.getName().toLowerCase());
} }
if (DisguiseAPI.isDisguiseInUse(disguise) if (DisguiseAPI.isDisguiseInUse(disguise)
&& (!gameProfile.getName().equals(disguise.getName()) || !gameProfile.getProperties().isEmpty())) { && (!gameProfile.getName().equals(disguise.getName()) || (LibVersion.is1_7_6() && !gameProfile.getProperties().isEmpty()))) {
// TODO Resend for UUID? Might need to in the future. // TODO Resend for UUID? Might need to in the future.
DisguiseUtilities.refreshTrackers(disguise); DisguiseUtilities.refreshTrackers(disguise);
} }
@ -371,7 +372,7 @@ public class DisguiseUtilities {
Player player = Bukkit.getPlayerExact(playerName); Player player = Bukkit.getPlayerExact(playerName);
if (player != null) { if (player != null) {
WrappedGameProfile gameProfile = ReflectionManager.getGameProfile(player); WrappedGameProfile gameProfile = ReflectionManager.getGameProfile(player);
if (!gameProfile.getProperties().isEmpty()) { if (!LibVersion.is1_7_6() || !gameProfile.getProperties().isEmpty()) {
gameProfiles.put(playerName, gameProfile); gameProfiles.put(playerName, gameProfile);
return gameProfile; return gameProfile;
} }

@ -364,7 +364,9 @@ public class ReflectionManager {
public static WrappedGameProfile getGameProfileWithThisSkin(UUID uuid, String playerName, WrappedGameProfile profileWithSkin) { public static WrappedGameProfile getGameProfileWithThisSkin(UUID uuid, String playerName, WrappedGameProfile profileWithSkin) {
try { try {
WrappedGameProfile gameProfile = new WrappedGameProfile(uuid != null ? uuid : UUID.randomUUID(), playerName); WrappedGameProfile gameProfile = new WrappedGameProfile(uuid != null ? uuid : UUID.randomUUID(), playerName);
if (LibVersion.is1_7_6()) {
gameProfile.getProperties().putAll(profileWithSkin.getProperties()); gameProfile.getProperties().putAll(profileWithSkin.getProperties());
}
return gameProfile; return gameProfile;
} catch (Exception ex) { } catch (Exception ex) {
ex.printStackTrace(); ex.printStackTrace();