Solved Death Message

Discussion in 'Plugin Help/Development/Requests' started by bubblefat_, Jan 23, 2015.

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


    So I made a death message, and I want it to show what Item the player was killed with. When someone kills me with a unnamed item it says null. How do I make it show the name?

        public void onPlayerJoin(PlayerDeathEvent event) {
            Player player = event.getEntity().getPlayer();
            Player killer = event.getEntity().getKiller();
            event.setDeathMessage(player.getName() + " was killed by " + killer.getName() + " with " + killer.getItemInHand().getItemMeta().getDisplayName());
    Deleted Message.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: Jun 13, 2016
  2. Offline


    • Killer may be null (do checks to prevent a NPE)
    • Player may not always have an item in their hand (which would be null)
    • The display name is only used if the item was renamed. Else it would return null
  3. Offline


    How do I make it display the item name?
  4. Offline


    Last edited: Jan 24, 2015
Thread Status:
Not open for further replies.

Share This Page