Setting player death Msg doesnt work!

Discussion in 'Plugin Development' started by william9518, Jan 4, 2013.

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

    william9518

    Yes, added @EventHandler anotation, yes, registered events. all other events work. this doesnt:
    Code:
    @EventHandler(priority=EventPriority.HIGHEST)
      public void deathMsg(PlayerDeathEvent event) {
    Player killed = event.getEntity();
        Entity killer = event.getEntity().getKiller();
        if (killed.getLastDamageCause().equals(EntityDamageEvent.DamageCause.FALL))
          event.setDeathMessage(ChatColor.DARK_BLUE + killed.getName() + " didn't believe in gravity");
        else if (killed.getLastDamageCause().equals(EntityDamageEvent.DamageCause.DROWNING))
          event.setDeathMessage(ChatColor.DARK_BLUE + killed.getName() + " thought he could breath in water");
        else if (killed.getLastDamageCause().equals(EntityDamageEvent.DamageCause.LAVA))
          event.setDeathMessage(ChatColor.DARK_BLUE + killed.getName() + " mistaked the lava pool for a hot bath");
        else if ((killed.getLastDamageCause().equals(EntityDamageEvent.DamageCause.FIRE)) || (killed.getLastDamageCause().equals(EntityDamageEvent.DamageCause.FIRE_TICK)))
          event.setDeathMessage(ChatColor.DARK_BLUE + killed.getName() + " thought he had fire resistance");
        else if (killed.getLastDamageCause().equals(EntityDamageEvent.DamageCause.CONTACT)) {
          event.setDeathMessage(ChatColor.DARK_BLUE + killed.getName() + " got pricked to death");
        }
          if (killed.getLastDamageCause().equals(EntityDamageEvent.DamageCause.ENTITY_ATTACK))
            event.setDeathMessage(ChatColor.DARK_BLUE + killed.getName() + " has been cut to pieces by " + ((Player)killer).getName());
          else if (killed.getLastDamageCause().equals(EntityDamageEvent.DamageCause.PROJECTILE))
            event.setDeathMessage(ChatColor.DARK_BLUE + killed.getName() + " has been skewered by an arrow shot by " + ((Player)killer).getName());
          else if (killed.getLastDamageCause().equals(EntityDamageEvent.DamageCause.MAGIC))
            event.setDeathMessage(ChatColor.DARK_BLUE + killed.getName() + " has been killed by a potion thrown by " + ((Player)killer).getName());
      }
      }
    NO ERROR, NO STACKTRACE, NOTHING
     
  2. Offline

    MrMysterious

    Please post your error and use this for code formatting:

    Code:
    [SYNTAX=JAVA][/SYNTAX]
     
  3. Offline

    william9518

    No error. Nothing. No stack trace,
     
  4. Offline

    fireblast709

    debug your code
     
  5. Offline

    xize

    Try to use:
    Code:
    event.getDeathMessage();
    
    at the end of setDeathMessage in every if and else loop.
     
  6. Offline

    william9518

    doesnt even say anythng i used the logger to say the deathmessage it did not output it.
     
  7. Offline

    fireblast709

    william9518 getLastDamageCause() returns an EntityDamageEvent, not a DamageCause
     
  8. Offline

    william9518

    I said if (killed.getLastDamageCause().equals(EntityDamageEvent.DamageCause.ENTITY_ATTACK)){
     
  9. Offline

    fireblast709

    And I replied that a EntityDamageEvent could never equal a DamageCause ;D
     
  10. Offline

    william9518

    I got the basic one,
    new EntityDamageEvent(event.getPlayer(), DamageCause.ENTITY_ATTACK, int);
    I think the int is the damage but i want it regardless of damage how can i do that
     
  11. Offline

    Deathmarine Retired Staff

    hmmm.... event.getEntity().getLastDamageCause().getCause()
     
  12. Offline

    william9518

    Tank you. me stupid.
     
Thread Status:
Not open for further replies.

Share This Page