Deathmessages

Discussion in 'Plugin Development' started by Felixbakkum, Feb 1, 2015.

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

    Felixbakkum

  2. Offline

    The Fancy Whale

    Just so you know .getKiller() sometimes returns null.
     
  3. Offline

    Felixbakkum

    Can you just do this easy plugin i need it today and the message should be like: &c{Player} &7 Was killed by &c{Killer}
     
  4. Offline

    Konato_K

  5. Offline

    TehHypnoz

    Try this:

    Code:
    @EventHandler
    public void onPlayerDeath(PlayerDeathEvent e) {
         if (e.getKiller() == null) return;
         e.setDeathMessage(e.getEntity().getName() + " was killed by " + e.getKiller().getName());
    }
    Edit: If you want colors, use ChatColor.[Insert color here]
     
  6. @Felixbakkum You need to learn Java, or at least the basics in order to understand what you are doing. Trying to code plugins in Java without knowing it is like writing an essay in German, when you don't even know how to speak it. I seriously suggest learning Java before coding with the Bukkit API.
     
  7. Offline

    nverdier

    Yup.

    @Felixbakkum Like I've told many people, here are a few good links:
    The Java™ Tutorials
    Interactive Java Tutorial
    thenewboston's Videos
     
  8. Offline

    Signatured

    Before you run your broadcast, I suggest you check to see if the killer is a player using if (k instanceof Played)
     
  9. Offline

    1Rogue

    Completely pointless, LivingEntity#getKiller() always returns a Player object.
     
    Konato_K likes this.
  10. Offline

    Signatured

    Ah, good to know.
     
Thread Status:
Not open for further replies.

Share This Page