Guest User

Untitled

a guest
Jan 21st, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. package com.hotmail.spoonikle.bigcatch;
  2.  
  3. import java.util.Timer;
  4. import java.util.TimerTask;
  5. import net.minecraft.server.EntityItem;
  6. import org.bukkit.craftbukkit.entity.CraftEntity;
  7. import org.bukkit.event.player.PlayerListener;
  8. import org.bukkit.event.player.PlayerPickupItemEvent;
  9.  
  10. public class CatchFish extends PlayerListener {
  11.  
  12. private boolean caughtFish = false;
  13.  
  14. public void setCaughtFish(boolean caughtFish) {
  15. this.caughtFish = caughtFish;
  16. }
  17.  
  18. /*
  19. * The following method was written with help from Edward Hand.
  20. */
  21.  
  22. public void onPlayerPickupItem(PlayerPickupItemEvent event) {
  23. CraftEntity fish = (CraftEntity) event.getItem();
  24. int fishId = ((EntityItem) fish.getHandle()).a.id;
  25. if (fishId == 349) {
  26. caughtFish = true;
  27. new CatchReset(2); // resets Catch fish value.
  28. }
  29. }
  30.  
  31. public boolean isCaughtFish() {
  32. return caughtFish;
  33. }
  34.  
  35. public class CatchReset {
  36. Timer timer;
  37.  
  38. public CatchReset(int seconds) {
  39. timer = new Timer();
  40. timer.schedule(new RemindTask(), seconds * 1000);
  41. }
  42.  
  43. // Declaration of the timer and its method.
  44. class RemindTask extends TimerTask {
  45. public void run() {
  46. setCaughtFish(false);
  47. timer.cancel();
  48. }
  49. }
  50. }
  51. }
Add Comment
Please, Sign In to add comment