Fix outdated code which would make huge problems because of previous fix

This commit is contained in:
libraryaddict 2014-06-01 06:53:01 +12:00
parent 841dab296d
commit 5bfd6c5541
2 changed files with 13 additions and 12 deletions

View File

@ -1,5 +1,7 @@
package me.libraryaddict.disguise.disguisetypes; package me.libraryaddict.disguise.disguisetypes;
import org.bukkit.entity.Player;
import me.libraryaddict.disguise.utilities.DisguiseUtilities; import me.libraryaddict.disguise.utilities.DisguiseUtilities;
import me.libraryaddict.disguise.utilities.LibsProfileLookup; import me.libraryaddict.disguise.utilities.LibsProfileLookup;
import me.libraryaddict.disguise.utilities.ReflectionManager; import me.libraryaddict.disguise.utilities.ReflectionManager;
@ -58,7 +60,7 @@ public class PlayerDisguise extends TargetedDisguise {
} }
return ReflectionManager.getGameProfile(null, getName()); return ReflectionManager.getGameProfile(null, getName());
} else { } else {
return DisguiseUtilities.getProfileFromMojang(getName()); return DisguiseUtilities.getProfileFromMojang(this);
} }
} }
@ -100,6 +102,9 @@ public class PlayerDisguise extends TargetedDisguise {
setGameProfile(gameProfile); setGameProfile(gameProfile);
if (DisguiseUtilities.isDisguiseInUse(PlayerDisguise.this)) { if (DisguiseUtilities.isDisguiseInUse(PlayerDisguise.this)) {
DisguiseUtilities.refreshTrackers(PlayerDisguise.this); DisguiseUtilities.refreshTrackers(PlayerDisguise.this);
if (getEntity() instanceof Player && isSelfDisguiseVisible()) {
DisguiseUtilities.sendSelfDisguise((Player) getEntity(), PlayerDisguise.this);
}
} }
} }
} }

View File

@ -294,23 +294,19 @@ public class DisguiseUtilities {
return players; return players;
} }
public static Object getProfileFromMojang(final String playerName) { public static Object getProfileFromMojang(final PlayerDisguise disguise) {
return getProfileFromMojang(playerName, new LibsProfileLookup() { return getProfileFromMojang(disguise.getName(), new LibsProfileLookup() {
@Override @Override
public void onLookup(Object gameProfile) { public void onLookup(Object gameProfile) {
getAddedByPlugins().remove(playerName); getAddedByPlugins().remove(disguise.getName());
for (HashSet<TargetedDisguise> disguises : DisguiseUtilities.getDisguises().values()) { if (DisguiseAPI.isDisguiseInUse(disguise)) {
for (TargetedDisguise disguise : disguises) {
if (disguise.getType() == DisguiseType.PLAYER && ((PlayerDisguise) disguise).getName().equals(playerName)) {
DisguiseUtilities.refreshTrackers((TargetedDisguise) disguise); DisguiseUtilities.refreshTrackers((TargetedDisguise) disguise);
if (disguise.getEntity() instanceof Player && disguise.isSelfDisguiseVisible()) { if (disguise.getEntity() instanceof Player && disguise.isSelfDisguiseVisible()) {
DisguiseUtilities.sendSelfDisguise((Player) disguise.getEntity(), disguise); DisguiseUtilities.sendSelfDisguise((Player) disguise.getEntity(), disguise);
} }
} }
} }
}
}
}); });
} }