Named mob death message

Discussion in 'Plugin Development' started by CrystallFTW, Nov 15, 2015.

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

    CrystallFTW

    Hi, I'm working on a plugin where I spawn some custom named mobs. Whenever a player kills these mobs, they get some death messages:
    http://i.imgur.com/XgU4N2T.png
    How can I get rid of these messages whenever I kill a names mob like this?
    This is what I use to spawn them:
    Code:
               
                Wolf wolf = (Wolf)p.getWorld().spawnCreature(loc, CreatureType.WOLF);
                wolf.setTamed(true);
                wolf.setOwner(p);
                wolf.setCustomName("§5§lNAMED MOB");
    
    Thanks!
     
  2. Offline

    timtower Administrator Administrator Moderator

    Gonmarte likes this.
  3. Offline

    CrystallFTW

    @timtower like
    Code:
        @EventHandler
        public void wolfdies(EntityDeathEvent e){
            Entity en = e.getEntity();
          
            if(en instanceof Wolf){
                Wolf wolf = (Wolf)en;
                if(wolf.getCustomName().equalsIgnoreCase("§5§lNAMED MOB")){
                          // cancel the message
         }
      }
    }
    
    
    
    ? But there is no method to remove the message, or maybe i'm blind.
     
  4. Offline

    timtower Administrator Administrator Moderator

    @CrystallFTW Then I am curious where the message is coming from.
     
  5. Offline

    Scimiguy

    Out of curiosity, what happens if you use the PlayerDeathEvent instead?
     
  6. Offline

    CrystallFTW

  7. Offline

    dlange

    If there is no way to set the death message, try listening to EntityDamageEvent and seeing if the health is <= 0, and if it is, cancel the event, and do entity.remove().
    Doing this makes the entity go away, as if it was dead. People use this in plugins to skip the death screen - i believe this is because the EntityDamageEvent is called before the EntityDeathEvent, meaning u can intercept when they are about to die.
     
  8. Offline

    Scimiguy

    @dlange
    There is no setMessage method for anything but the PlayerDeathEvent
     
  9. Offline

    dlange

    @Scimiguy Yes, so if u look at what i wrote, i gave another way to detect death, without the message.
     
Thread Status:
Not open for further replies.

Share This Page