Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @EventHandler
- public void onInterac(PlayerInteractEvent e){
- if(e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK){
- final Player p = e.getPlayer();
- if(p.getItemInHand().getType() == Material.COOKIE){
- if(main.Start == true){
- final Item Cookie = p.getWorld().dropItem(p.getEyeLocation(), new ItemStack(Material.COOKIE));
- Cookie.setVelocity(p.getEyeLocation().getDirection().multiply(1.5));
- new BukkitRunnable(){
- @SuppressWarnings("deprecation")
- public void run(){
- if (!Cookie.getNearbyEntities(2D, 2D, 2D).isEmpty()) {
- for (LivingEntity l : Cookie.getWorld().getEntitiesByClass(LivingEntity.class)) {
- if(l instanceof Player){
- if(l != p){
- Player l1 = (Player) l;
- if(!Cookie.isOnGround()){
- if (l.getLocation().distance(Cookie.getLocation()) <= 2D) {
- l.damage(5000);
- Bukkit.getScheduler().scheduleSyncDelayedTask(main.getInstance(), new Runnable() {
- @Override
- public void run() {
- ItemStack is = new ItemStack(Material.COOKIE);
- ItemMeta is_m = is.getItemMeta();
- is_m.setDisplayName(main.pr + "Cookie Shooter");
- is.setItemMeta(is_m);
- p.getInventory().setItem(1, is);
- }
- }, 100L);
- }
- }
- }
- }
- }
- }
- if(Cookie.isOnGround()){
- Cookie.remove();
- p.getInventory().remove(p.getItemInHand());
- this.cancel();
- Bukkit.getScheduler().scheduleSyncDelayedTask(main.getInstance(), new Runnable() {
- @Override
- public void run() {
- ItemStack is = new ItemStack(Material.COOKIE);
- ItemMeta is_m = is.getItemMeta();
- is_m.setDisplayName(main.pr + "Cookie Shooter");
- is.setItemMeta(is_m);
- p.getInventory().setItem(1, is);
- }
- }, 100L);
- }
- }
- }.runTaskTimer(main.getInstance(), 2L, 2L);
- }else{
- e.setCancelled(true);
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement