(HELP) How can i add regenaration to the killer of a player?

Discussion in 'Plugin Development' started by AngelopoulosfilmsYT, Oct 27, 2014.

Thread Status:
Not open for further replies.
  1. How can i add regenaration to the killer of a player?
     
  2. Offline

    Watto

  3. Can you give me a better explanation?

    Code:
    @EventHandler(priority = EventPriority.NORMAL)
    public void onEntityDeath(EntityDeathEvent event)
    {
        if(event.getEntity() instanceof Player)
           
        {
    I made this. Now?

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

    Watto

    AngelopoulosfilmsYT

    Code:java
    1. public void onPlayerDeath(PlayerDeathEvent event){
    2. if(event.getKiller() instanceof Player){
    3. Player killer = (Player) event.getKiller();
    4. killer.addPotionEffect(//Potion stuff here, again look at the link i supplied.)
    5. }
    6. }


    Nevermind there's no .getKiller for PlayerDeathEvent..
    Sorry, i wrote from hand :S Use that method in your post.

    Wow my brain is broken tonight. Call .getKiller on the killed player. not on the event.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 14, 2016
  5. Can you show me how? I am quite nooby :p
     
  6. Offline

    CraftCreeper6

  7. Offline

    fireblast709

    Watto getKiller() will always return a Player (the return type is Player after all). Check if it's not null instead.
     
  8. Offline

    Watto

    @fireblast70

    Yeah thanks for that.
    I wrote the code like that assuming that PlayerDeatheEvent had the .getKiller method, thank you though ^^

    AngelopoulosfilmsYT

    I pretty much spelled it out for except for the actual potion part which i already explained you can read in the link i gave earlier, then you may aswell just post here.
     
  9. Thank you guys so much for the help :D
     
Thread Status:
Not open for further replies.

Share This Page