mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-06-27 19:24:44 +02:00
Use BukkitRunnable.
This commit is contained in:
@ -3,29 +3,27 @@ package com.gmail.nossr50.skills.archery;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
|
||||
public class TrackedEntity implements Runnable {
|
||||
public class TrackedEntity extends BukkitRunnable {
|
||||
private LivingEntity livingEntity;
|
||||
private UUID id;
|
||||
private int arrowCount;
|
||||
private int taskId;
|
||||
private BukkitScheduler scheduler;
|
||||
|
||||
protected TrackedEntity(LivingEntity livingEntity) {
|
||||
this.livingEntity = livingEntity;
|
||||
this.id = livingEntity.getUniqueId();
|
||||
this.scheduler = mcMMO.p.getServer().getScheduler();
|
||||
this.taskId = scheduler.runTaskTimer(mcMMO.p, this, 12000, 12000).getTaskId();
|
||||
|
||||
this.runTaskTimer(mcMMO.p, 12000, 12000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (!livingEntity.isValid()) {
|
||||
Archery.removeFromTracker(this);
|
||||
scheduler.cancelTask(taskId);
|
||||
this.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user