onDeath

Discussion in 'Plugin Development' started by Thallo, Jan 26, 2011.

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

    Thallo

    Hey

    how can i call an onDeath event? and is there a possibility to check wich block killed the player like lava wather or a other type of block?

    thx
    Thallo
     
  2. Offline

    MadMichi

    Hi, please have a look here.
    If you overwrite the onEntityCombust, onEntityDamage, etc. methods you should get all the informations.
    Greetz Mad
     
  3. Offline

    Thallo

    sorry for such a noob question but why is the hook not called??

    Code:
            PluginManager pm = getServer().getPluginManager();
            pm.registerEvent(Event.Type.ENTITY_DEATH,
                    (Listener) this.entityListener,
                    Event.Priority.Normal,
                    this);
    
    Code:
        public void onEntityDamage(EntityDamageEvent event)
        {
            Player player = (Player) event.getEntity();
    
            if(event.getCause().equals("LAVA"))
            {
                player.sendMessage("Lava");
            }
     
  4. Offline

    Fifteen

    I believe you're trying to call onEntityDamage with an ENTITY_DEATH registerer. Try this:

    Code:
            PluginManager pm = getServer().getPluginManager();
            pm.registerEvent(Event.Type.ENTITY_DAMAGED,
                    (Listener) this.entityListener,
                    Event.Priority.Normal,
                    this);
    
     
  5. Offline

    Thallo

    sorry but this is not working .. The player doesn't get a message if he gets dmg .. I put a player.sendMessage() under Player player = (Player) event.getEntity() and tried it but no message ..
     
  6. Offline

    Fifteen

    This should work, an enum is not a string:
    Code:
    if(event.getCause() == DamageCause.LAVA)
    {
         player.sendMessage("Lava");
    }
    EDIT: According to RedMine, the event hasn't been implemented yet.
     
Thread Status:
Not open for further replies.

Share This Page