Little eventhandler/void/playerdeath help!

Discussion in 'Plugin Development' started by Hectorg98, Dec 1, 2014.

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

    Hectorg98

    So what I wanted to do is for when the player dies it sends him a message saying you have died to ''killer''

    Then the killer will send himself a msg (hi) <-- Thats just for testing perpouses, ill add in some commands later. I tried logging in with an alt on my server and killed my alt and it doesnt show anything HELP!
    heres my code:

    Code:
        public void onDeath(PlayerDeathEvent e){
                Player player = e.getEntity();
            if(player.getKiller() != null){
                Player killer = player.getKiller();
     
                player.sendMessage(ChatColor.DARK_RED + killer.getName() + " " + "killed you! Better luck next time!");
                killer.sendMessage(ChatColor.GREEN + "You have killed " + player.getName());
                killer.chat("/msg" + killer.getName() + "hi"); } }
    I also have @eventhandler on top of that :)

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

    drpk

  3. Offline

    Creeoer

    Hectorg98
    Did you register it in the onEnable? And I'm not sure if killer always returns player but if it doesn't than make sure that the killer is an instanceof Player.
     
  4. Offline

    CullanP

    Are you implementing listener in your class?
     
  5. Offline

    Hectorg98

    drpk what do u mean "register events"?

    CullanP Yep on top i wrote extends Java plugin implements listener

    Creeoer im not quite sure I understand you, can you maybe edit my code and re send it here thanks :)

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

    Rocoty

    Hectorg98 How about you show us all your code. No point in us trying to guess the rest of it, surely?
     
    AdamQpzm likes this.
  7. Offline

    Hectorg98

    Rocoty will do when I get home, currently at school, thanks :D
     
  8. Offline

    drpk

Thread Status:
Not open for further replies.

Share This Page