Finish up the refresh tracker. Its retarded and I don't want to look at it.

This commit is contained in:
libraryaddict 2014-06-21 08:01:42 +12:00
parent 992e416edf
commit 7453053131

View File

@ -455,23 +455,28 @@ public class DisguiseUtilities {
public static void refreshTracker(TargetedDisguise disguise, String player) {
if (disguise.getEntity() != null && disguise.getEntity().isValid()) {
try {
if (disguise.isDisguiseInUse() && disguise.getEntity() instanceof Player
&& ((Player) disguise.getEntity()).getName().equalsIgnoreCase(player)) {
DisguiseUtilities.sendSelfDisguise((Player) disguise.getEntity(), disguise);
} else {
Object entityTrackerEntry = ReflectionManager.getEntityTrackerEntry(disguise.getEntity());
if (entityTrackerEntry != null) {
HashSet trackedPlayers = (HashSet) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers").get(
entityTrackerEntry);
HashSet trackedPlayers = (HashSet) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers")
.get(entityTrackerEntry);
Method clear = ReflectionManager.getNmsMethod("EntityTrackerEntry", "clear",
ReflectionManager.getNmsClass("EntityPlayer"));
Method updatePlayer = ReflectionManager.getNmsMethod("EntityTrackerEntry", "updatePlayer",
ReflectionManager.getNmsClass("EntityPlayer"));
HashSet cloned = (HashSet) trackedPlayers.clone();
for (Object p : cloned) {
if (player.equals(((Player) ReflectionManager.getBukkitEntity(p)).getName())) {
if (player.equalsIgnoreCase(((Player) ReflectionManager.getBukkitEntity(p)).getName())) {
clear.invoke(entityTrackerEntry, p);
updatePlayer.invoke(entityTrackerEntry, p);
break;
}
}
}
}
} catch (Exception ex) {
ex.printStackTrace();
}
@ -514,6 +519,7 @@ public class DisguiseUtilities {
* Resends the entity to all the watching players, which is where the magic begins
*/
public static void refreshTrackers(TargetedDisguise disguise) {
if (disguise.getEntity().isValid()) {
try {
if (disguise.isDisguiseInUse() && disguise.getEntity() instanceof Player) {
DisguiseUtilities.sendSelfDisguise((Player) disguise.getEntity(), disguise);
@ -542,6 +548,7 @@ public class DisguiseUtilities {
ex.printStackTrace();
}
}
}
public static boolean removeDisguise(TargetedDisguise disguise) {
UUID entityId = disguise.getEntity().getUniqueId();