mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-12-26 18:47:57 +01:00
Forgot to cancel the task
This commit is contained in:
parent
df08bc4da0
commit
739cd83155
@ -12,9 +12,7 @@ public class TrackedEntity {
|
|||||||
|
|
||||||
public TrackedEntity(LivingEntity livingEntity) {
|
public TrackedEntity(LivingEntity livingEntity) {
|
||||||
this.livingEntity = livingEntity;
|
this.livingEntity = livingEntity;
|
||||||
|
new CheckTrackedEntityExistence(this);
|
||||||
//Check if the entity is still active every 10 minutes
|
|
||||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(mcMMO.p, new CheckTrackedEntityExistence(this), 12000, 12000);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//LivingEntity.isDead() isn't a reliable way to know if an entity is still active
|
//LivingEntity.isDead() isn't a reliable way to know if an entity is still active
|
||||||
@ -45,15 +43,20 @@ public class TrackedEntity {
|
|||||||
|
|
||||||
private class CheckTrackedEntityExistence implements Runnable {
|
private class CheckTrackedEntityExistence implements Runnable {
|
||||||
private TrackedEntity trackedEntity;
|
private TrackedEntity trackedEntity;
|
||||||
|
private int taskId;
|
||||||
|
|
||||||
public CheckTrackedEntityExistence(TrackedEntity trackedEntity) {
|
public CheckTrackedEntityExistence(TrackedEntity trackedEntity) {
|
||||||
this.trackedEntity = trackedEntity;
|
this.trackedEntity = trackedEntity;
|
||||||
|
|
||||||
|
//Check if the entity is still active every 10 minutes
|
||||||
|
taskId = Bukkit.getScheduler().scheduleSyncRepeatingTask(mcMMO.p, this, 20, 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (!trackedEntity.isActive()) {
|
if (!trackedEntity.isActive()) {
|
||||||
Archery.removeFromTracker(trackedEntity);
|
Archery.removeFromTracker(trackedEntity);
|
||||||
|
Bukkit.getScheduler().cancelTask(taskId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user