2012-06-15 02:43:13 +02:00
|
|
|
package com.gmail.nossr50.skills.archery;
|
|
|
|
|
2019-01-15 07:11:58 +01:00
|
|
|
import com.gmail.nossr50.mcMMO;
|
2012-06-15 02:43:13 +02:00
|
|
|
import org.bukkit.entity.LivingEntity;
|
2013-03-20 08:11:16 +01:00
|
|
|
import org.bukkit.scheduler.BukkitRunnable;
|
2012-06-15 02:43:13 +02:00
|
|
|
|
2019-01-15 07:11:58 +01:00
|
|
|
import java.util.UUID;
|
2012-06-15 02:43:13 +02:00
|
|
|
|
2013-03-20 08:11:16 +01:00
|
|
|
public class TrackedEntity extends BukkitRunnable {
|
2012-06-15 02:43:13 +02:00
|
|
|
private LivingEntity livingEntity;
|
2013-02-26 16:07:00 +01:00
|
|
|
private UUID id;
|
2012-06-15 02:43:13 +02:00
|
|
|
private int arrowCount;
|
|
|
|
|
2013-01-08 23:44:05 +01:00
|
|
|
protected TrackedEntity(LivingEntity livingEntity) {
|
2012-06-15 02:43:13 +02:00
|
|
|
this.livingEntity = livingEntity;
|
2013-02-26 16:07:00 +01:00
|
|
|
this.id = livingEntity.getUniqueId();
|
2013-03-20 08:11:16 +01:00
|
|
|
|
|
|
|
this.runTaskTimer(mcMMO.p, 12000, 12000);
|
2012-06-15 02:43:13 +02:00
|
|
|
}
|
|
|
|
|
2013-03-01 06:52:01 +01:00
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
if (!livingEntity.isValid()) {
|
|
|
|
Archery.removeFromTracker(this);
|
2013-03-20 08:11:16 +01:00
|
|
|
this.cancel();
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-08 23:44:05 +01:00
|
|
|
protected LivingEntity getLivingEntity() {
|
2012-07-03 03:40:12 +02:00
|
|
|
return livingEntity;
|
|
|
|
}
|
|
|
|
|
2013-02-26 16:07:00 +01:00
|
|
|
protected UUID getID() {
|
|
|
|
return id;
|
|
|
|
}
|
|
|
|
|
2013-01-08 23:44:05 +01:00
|
|
|
protected int getArrowCount() {
|
2012-06-15 02:43:13 +02:00
|
|
|
return arrowCount;
|
|
|
|
}
|
|
|
|
|
2013-01-08 23:44:05 +01:00
|
|
|
protected void incrementArrowCount() {
|
2012-06-15 02:43:13 +02:00
|
|
|
arrowCount++;
|
|
|
|
}
|
|
|
|
}
|