Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class ArrowRemoval {
- public ArrowRemoval(){
- enable();
- }
- public static PriorityQueue<ArrowLandData> q = new PriorityQueue<ArrowLandData>();
- public void enable(){
- plugin.getInstance().getServer().getScheduler().scheduleSyncRepeatingTask(plugin.getInstance(), new Runnable(){
- @Override
- public void run() {
- ArrowLandData ald;
- while ((ald = q.peek()) != null && ald.isReady()) {
- q.poll().removeArrow();
- }
- }
- }, 100L, 100L);
- }
- }
- public class ArrowLandData {
- private Arrow arrow;
- private long landTime;
- public ArrowLandData(Arrow a) {
- arrow = a;
- landTime = System.currentTimeMillis();
- }
- public boolean isReady() {
- if (!arrow.isValid()) return true;
- return System.currentTimeMillis() > landTime + (1000 * 10);
- }
- public void removeArrow() {
- arrow.remove();
- arrow = null; // drop ref
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement