Advertisement
riking

ArrowLandData

Aug 9th, 2013
413
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class ArrowRemoval {
  2. public ArrowRemoval(){
  3. enable();
  4. }
  5.  
  6. public static PriorityQueue<ArrowLandData> q = new PriorityQueue<ArrowLandData>();
  7.  
  8. public void enable(){
  9. plugin.getInstance().getServer().getScheduler().scheduleSyncRepeatingTask(plugin.getInstance(), new Runnable(){
  10.  
  11. @Override
  12. public void run() {
  13. ArrowLandData ald;
  14. while ((ald = q.peek()) != null && ald.isReady()) {
  15. q.poll().removeArrow();
  16. }
  17.  
  18. }
  19. }, 100L, 100L);
  20. }
  21.  
  22. }
  23.  
  24. public class ArrowLandData {
  25. private Arrow arrow;
  26. private long landTime;
  27. public ArrowLandData(Arrow a) {
  28. arrow = a;
  29. landTime = System.currentTimeMillis();
  30. }
  31. public boolean isReady() {
  32. if (!arrow.isValid()) return true;
  33. return System.currentTimeMillis() > landTime + (1000 * 10);
  34. }
  35. public void removeArrow() {
  36. arrow.remove();
  37. arrow = null; // drop ref
  38. }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement