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