Question how do i damage mobs/players within a certain radius

Discussion in 'Bukkit Help' started by OKGplayz, Aug 15, 2021.

Thread Status:
Not open for further replies.
  1. Offline

    OKGplayz

    so i am currently trying to create a stick that damages everything around the player that uses it what would i use to do this im kinda new so idrk alot
     
  2. Online

    KarimAKL

    @OKGplayz How do you want to create this? Are you developing a plugin? Are you using Skript? Do you want to install a plugin that enables you to do this some other way? Please elaborate.
     
  3. Offline

    ZweiGeschleim

    Try this...

    Code:
        @EventHandler
        public void onClick(PlayerInteractEvent e) {
            if(e.getItem().getType()==Material.STICK) {
                Player p = e.getPlayer();
                for(Entity en : p.getNearbyEntities(/*the range*/ 10, 10, 10)) {
                    if(en instanceof LivingEntity) {
                        ((LivingEntity)en).damage(2/*your damage amount*/);
                    }
                }
            }
        }
     
Thread Status:
Not open for further replies.

Share This Page