Why doesn't this work?

Discussion in 'Plugin Development' started by Bobfan, Nov 27, 2012.

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

    Bobfan

    Well it works fine, but it displays an error when the damage isn't a projectile.
    Code:
    //event handler/etc.
    Entity pR = (Entity) event.getEntity();
     
    //code
     
    if(pR.getLastDamageCause().equals(DamageCause.PROJECTILE) &&
     
    //code
    When attacked by a projectile, it should set them on fire. Why is this an error?
     
  2. Offline

    raGan.

    It is nice when you provide error and all relevant code.
     
  3. Offline

    Bobfan

    When you attack, and the damage cause isn't by an arrow, than it shows the error above.
    Code:
    @EventHandler
        public void onAttack(EntityDamageByEntityEvent event) {//Attack Event
            FileConfiguration c = pp.getConfig();
           
            Entity pR = (Entity) event.getEntity();
            Player pA = (Player) event.getDamager();
           
            ItemStack iH = pA.getItemInHand();...
     
    if(pR.getLastDamageCause().equals(DamageCause.PROJECTILE) &&
                (pA instanceof Player) &&
                (c.getStringList("Races.Elf").contains(pA.getName()))) {//Elf Shoot Arrow
                random = new Random().nextInt(4) + 1;
               
                if(random == 2) {
                    pR.setFireTicks(8);
                   
                }//random
            }//elf shot arrow
        }//event handler end
    Some more code. If 1-4 chance after being shot by an arrow, than set the entity being attacked on fire.
     
  4. Offline

    raGan.

    what is line 102 ?
     
  5. Offline

    Bobfan

    pR.getLastDamageCause()
     
Thread Status:
Not open for further replies.

Share This Page