Poison on Skeletons/zombies

Discussion in 'Plugin Development' started by bronzzze, Mar 31, 2015.

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

    bronzzze

    I have this code:
    For zombies and skeletons is poision like a regeneration so I added regeneration But it still not working.
    Other mobs are working
    Code:
                    if(e.getEntityType().equals(EntityType.ZOMBIE) || (e.getEntityType().equals(EntityType.SKELETON))){
                        p.sendMessage("zombie");
                        el.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION,5*20, 2,true));
                   
                    }else{
                        p.sendMessage("not zombie");
                        el.addPotionEffect(new PotionEffect(PotionEffectType.POISON,5*20, 2,true));
                   
    
                       
                    }
     
  2. You're checking if the entity is a LivingEntity right ? Post whole method if you can
     
  3. Offline

    bronzzze

    Code:
     @EventHandler
         public void onEntityDamage(EntityDamageByEntityEvent e){
             if(!(e.getDamager()instanceof Player))return;
             if(!(e.getEntity()instanceof LivingEntity))return;
             Player p = (Player)e.getDamager();
            
    
             if (p.getItemInHand() == null
                     || (!(p.getItemInHand().getType() == Material.DIAMOND_SWORD
                             || p.getItemInHand().getType() == Material.IRON_SWORD
                             || p.getItemInHand().getType() == Material.GOLD_SWORD
                             || p.getItemInHand().getType() == Material.WOOD_SWORD)))
                 return;
            
             if (!p.getItemInHand().getItemMeta().hasLore()
                    && !p.getItemInHand().hasItemMeta())
                return;
            if (p.getItemInHand().getItemMeta().getLore()
                    .contains(ChatColor.GRAY + "Poison IV")) {
                LivingEntity el = (LivingEntity)e.getEntity();
                int randomint = (int) (Math.random() * 100);
                if (randomint < 99) {
                   
                    if(e.getEntityType().equals(EntityType.ZOMBIE) || (e.getEntityType().equals(EntityType.SKELETON))){
                        p.sendMessage("zombie");
                        el.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION,5*20, 2,false));
                   
                    }else{
                        p.sendMessage("not zombie");
                        el.addPotionEffect(new PotionEffect(PotionEffectType.POISON,5*20, 2,false));
                   
    
                       
                    }
                    
    Whole class

    So there is no way to poison them? If no i can use reapiting task I guess.

    Edit:
    Anyone know how much is poison doing dmg?

    <Edit by mrCookieSlime: Merged posts. Please don't double post. There is an Edit Button right next to the Date.>
     
    Last edited by a moderator: Mar 31, 2015
Thread Status:
Not open for further replies.

Share This Page