Set an Effect

Discussion in 'Spigot Plugin Development' started by maxouland1, May 23, 2015.

  1. Hello,
    I want to give effect to a speed zombies spawn naturally.
    I know give effects to spawn mobs that I do but I do not know how to natural spawn .

    Thank you

    Sorry for my bad English, I am French ^^
     
  2. Listen on EntitySpawnEvent and add the effect to the entity.
     
  3. Do you have an example ?
     
  4. Code (Text):

    @org.bukkit.event.EventHandler
        public void onSpawn(org.bukkit.event.entity.EntitySpawnEvent event) {        
            if (event.getEntityType() == org.bukkit.entity.EntityType.CHICKEN) {
                org.bukkit.entity.Chicken chicken = (org.bukkit.entity.Chicken) event.getEntity();
                chicken.addPotionEffect(new org.bukkit.potion.PotionEffect(org.bukkit.potion.PotionEffectType.REGENERATION, 60*20, 0));
            }
        }
     
  5. Ok I'll test
     
    • Friendly Friendly x 1
  6. It work ! Thank you :D