Solved How do you get a specific mob that has been slain by a player?

Discussion in 'Plugin Development' started by DoubleDwars, Apr 23, 2014.

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

    DoubleDwars

    I want to send a message to a player who has slain a witch. But how do you do that? I already have this in my code:

    Code:java
    1. @EventHandler
    2. public void onMobKill(EntityDeathEvent event){
    3. Player p = (Player) event.getEntity().getKiller();
    4. if(event.getEntity().equals(witch)){
    5. p.sendMessage("You have slain a witch!");
    6. }


    What is a witch called in the Bukkit API?
     
  2. Offline

    ko47374737

    DoubleDwars
    Try this
    Code:java
    1. @EventHandler
    2. public void onMobKill(EntityDeathEvent event){
    3. Player p = (Player) event.getEntity().getKiller();
    4. if(event.getEntity() istanceof Witch){
    5. p.sendMessage("You have slain a witch!");
    6. }
     
  3. Offline

    DoubleDwars

    It worked! Thank you!
     
Thread Status:
Not open for further replies.

Share This Page