Advertisement
Guest User

Untitled

a guest
May 27th, 2015
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.60 KB | None | 0 0
  1.  
  2. @EventHandler
  3. public void onInterac(PlayerInteractEvent e){
  4. if(e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK){
  5. final Player p = e.getPlayer();
  6. if(p.getItemInHand().getType() == Material.COOKIE){
  7. if(main.Start == true){
  8. final Item Cookie = p.getWorld().dropItem(p.getEyeLocation(), new ItemStack(Material.COOKIE));
  9. Cookie.setVelocity(p.getEyeLocation().getDirection().multiply(1.5));
  10. new BukkitRunnable(){
  11. @SuppressWarnings("deprecation")
  12. public void run(){
  13. if (!Cookie.getNearbyEntities(2D, 2D, 2D).isEmpty()) {
  14. for (LivingEntity l : Cookie.getWorld().getEntitiesByClass(LivingEntity.class)) {
  15. if(l instanceof Player){
  16. if(l != p){
  17. Player l1 = (Player) l;
  18. if(!Cookie.isOnGround()){
  19. if (l.getLocation().distance(Cookie.getLocation()) <= 2D) {
  20. l.damage(5000);
  21.  
  22.  
  23. Bukkit.getScheduler().scheduleSyncDelayedTask(main.getInstance(), new Runnable() {
  24.  
  25. @Override
  26. public void run() {
  27.  
  28. ItemStack is = new ItemStack(Material.COOKIE);
  29. ItemMeta is_m = is.getItemMeta();
  30. is_m.setDisplayName(main.pr + "Cookie Shooter");
  31. is.setItemMeta(is_m);
  32.  
  33. p.getInventory().setItem(1, is);
  34.  
  35.  
  36. }
  37. }, 100L);
  38.  
  39. }
  40.  
  41. }
  42. }
  43. }
  44.  
  45.  
  46. }
  47. }
  48. if(Cookie.isOnGround()){
  49. Cookie.remove();
  50. p.getInventory().remove(p.getItemInHand());
  51. this.cancel();
  52.  
  53.  
  54. Bukkit.getScheduler().scheduleSyncDelayedTask(main.getInstance(), new Runnable() {
  55.  
  56. @Override
  57. public void run() {
  58.  
  59. ItemStack is = new ItemStack(Material.COOKIE);
  60. ItemMeta is_m = is.getItemMeta();
  61. is_m.setDisplayName(main.pr + "Cookie Shooter");
  62. is.setItemMeta(is_m);
  63.  
  64. p.getInventory().setItem(1, is);
  65.  
  66.  
  67. }
  68. }, 100L);
  69.  
  70. }
  71.  
  72. }
  73.  
  74. }.runTaskTimer(main.getInstance(), 2L, 2L);
  75.  
  76. }else{
  77. e.setCancelled(true);
  78. }
  79.  
  80. }
  81. }
  82. }
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement