mirror of
https://github.com/Elecast2/EntityTrackerFixer.git
synced 2024-11-29 05:15:16 +01:00
cache tracker field
This commit is contained in:
parent
4208443d26
commit
b0440f6b40
@ -21,6 +21,16 @@ import net.minemora.entitytrackerfixer.util.Util;
|
|||||||
public class UntrackerTask extends BukkitRunnable {
|
public class UntrackerTask extends BukkitRunnable {
|
||||||
|
|
||||||
private static boolean running = false;
|
private static boolean running = false;
|
||||||
|
|
||||||
|
private static Field trackerField;
|
||||||
|
|
||||||
|
static {
|
||||||
|
try {
|
||||||
|
trackerField = ReflectionUtils.getClassPrivateField(EntityTracker.class, "tracker");
|
||||||
|
} catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
@Override
|
@Override
|
||||||
@ -48,9 +58,8 @@ public class UntrackerTask extends BukkitRunnable {
|
|||||||
ChunkProviderServer cps = ws.getChunkProvider();
|
ChunkProviderServer cps = ws.getChunkProvider();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Field field = ReflectionUtils.getClassPrivateField(EntityTracker.class, "tracker");
|
|
||||||
for(EntityTracker et : cps.playerChunkMap.trackedEntities.values()) {
|
for(EntityTracker et : cps.playerChunkMap.trackedEntities.values()) {
|
||||||
net.minecraft.server.v1_14_R1.Entity nmsEnt = (net.minecraft.server.v1_14_R1.Entity) field.get(et);
|
net.minecraft.server.v1_14_R1.Entity nmsEnt = (net.minecraft.server.v1_14_R1.Entity) trackerField.get(et);
|
||||||
if(nmsEnt instanceof EntityPlayer) {
|
if(nmsEnt instanceof EntityPlayer) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -82,7 +91,7 @@ public class UntrackerTask extends BukkitRunnable {
|
|||||||
UntrackedEntitiesCache.getInstance().add(nmsEnt);
|
UntrackedEntitiesCache.getInstance().add(nmsEnt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) {
|
} catch (IllegalArgumentException | IllegalAccessException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user