mirror of
https://github.com/TotalFreedomMC/TF-LibsDisguises.git
synced 2025-02-11 19:50:30 +00:00
Only allow refreshing entity is the entity is valid
This commit is contained in:
parent
4e09a64abb
commit
c2e7aae201
1 changed files with 49 additions and 43 deletions
|
@ -383,6 +383,7 @@ public class DisguiseUtilities {
|
|||
* the entity to all the watching players, which is where the magic begins
|
||||
*/
|
||||
public static void refreshTracker(TargetedDisguise disguise, String player) {
|
||||
if (disguise.getEntity() != null && disguise.getEntity().isValid()) {
|
||||
try {
|
||||
Object world = ReflectionManager.getWorld(disguise.getEntity().getWorld());
|
||||
Object tracker = world.getClass().getField("tracker").get(world);
|
||||
|
@ -392,7 +393,8 @@ public class DisguiseUtilities {
|
|||
if (entityTrackerEntry != null) {
|
||||
HashSet trackedPlayers = (HashSet) entityTrackerEntry.getClass().getField("trackedPlayers")
|
||||
.get(entityTrackerEntry);
|
||||
Method clear = entityTrackerEntry.getClass().getMethod("clear", ReflectionManager.getNmsClass("EntityPlayer"));
|
||||
Method clear = entityTrackerEntry.getClass()
|
||||
.getMethod("clear", ReflectionManager.getNmsClass("EntityPlayer"));
|
||||
Method updatePlayer = entityTrackerEntry.getClass().getMethod("updatePlayer",
|
||||
ReflectionManager.getNmsClass("EntityPlayer"));
|
||||
HashSet cloned = (HashSet) trackedPlayers.clone();
|
||||
|
@ -408,12 +410,14 @@ public class DisguiseUtilities {
|
|||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param A
|
||||
* convidence method for me to refresh trackers in other plugins
|
||||
*/
|
||||
public static void refreshTrackers(Entity entity) {
|
||||
if (entity.isValid()) {
|
||||
try {
|
||||
Object world = ReflectionManager.getWorld(entity.getWorld());
|
||||
Object tracker = world.getClass().getField("tracker").get(world);
|
||||
|
@ -423,7 +427,8 @@ public class DisguiseUtilities {
|
|||
if (entityTrackerEntry != null) {
|
||||
HashSet trackedPlayers = (HashSet) entityTrackerEntry.getClass().getField("trackedPlayers")
|
||||
.get(entityTrackerEntry);
|
||||
Method clear = entityTrackerEntry.getClass().getMethod("clear", ReflectionManager.getNmsClass("EntityPlayer"));
|
||||
Method clear = entityTrackerEntry.getClass()
|
||||
.getMethod("clear", ReflectionManager.getNmsClass("EntityPlayer"));
|
||||
Method updatePlayer = entityTrackerEntry.getClass().getMethod("updatePlayer",
|
||||
ReflectionManager.getNmsClass("EntityPlayer"));
|
||||
HashSet cloned = (HashSet) trackedPlayers.clone();
|
||||
|
@ -442,6 +447,7 @@ public class DisguiseUtilities {
|
|||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Resends
|
||||
|
|
Loading…
Reference in a new issue