get the killer that kill the player

Discussion in 'Plugin Development' started by StickyMan, Dec 8, 2012.

  1. Offline

    StickyMan

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Code:
      @EventHandler
      public void onDeath(PlayerDeathEvent e)
      {
          if(e.getEntity() instanceof Player)
          {
              Player p = e.getEntity();
              p.sendMessage("the test work");
              if(e.getEntity().getKiller() instanceof Player)
              {
                  Player killer = e.getEntity().getKiller();
              killer.sendMessage("the test work");
              }
          }
      }
    no errors but it dosen't do nothing to the killer or the death player (send message)

    This post has been edited 1 time. It was last edited by StickyMan Dec 8, 2012.
  2. Offline

    Tirelessly

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Go on then.
  3. Offline

    Woobie

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    @StickyMan
    Code:
    @EventHandler
        public void onDeath(PlayerDeathEvent e)
        {
            if(e.getEntity() instanceof Player) // <-- the killed player
            {
                Player p = e.getEntity();
                if(e.getEntity().getKiller() instanceof Player) // <-- The killer player
                {
                    Player killer = e.getEntity().getKiller();
    And if you want to add a potion effect to the killer, do
    Code:
    killer.addPotionEffect(new PotionEffect(PotionEffectType.POOP, 1, 200));
  4. Offline

    StickyMan

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    and i need help with it
  5. Offline

    KingMagnus

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    He literally gave you exactly what you asked for what more do you need help with?
  6. Offline

    StickyMan

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Code:
      @EventHandler
      public void onDeath(PlayerDeathEvent e)
      {
          if(e.getEntity() instanceof Player) // <-- the killed player
          {
              Player p = e.getEntity();
              p.sendMessage("the test work");
              if(e.getEntity().getKiller() instanceof Player) // <-- The killer player
              {
                  Player killer = e.getEntity().getKiller();
              killer.sendMessage("the test work");
              }
          }
      }
    no errors but still do nothing
  7. Offline

    brord

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Your class needs to implement Listener

    "public class xxxxx implements Listener {

    }"
  8. Offline

    StickyMan

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    nice idea
    but i need more ideas

    thanks in advence
    itay
  9. Offline

    Tirelessly

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    You should start by learning java?
  10. Offline

    lol768 BukkitDev Staff

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Events also need registering, btw.
  11. Offline

    brord

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Main class:
    Code:java
    1.  
    2. public class getkillerplugin extends JavaPlugin{
    3. public void onEnable()
    4. {
    5. PluginManager pm = getServer().getPluginManager();
    6. pm.registerEvents(new listener(this), this);
    7. }
    8. }
    9.  
    10.  

    Listener:
    Code:java
    1.  
    2. public class listener implements Listener {
    3. public getkillerplugin plugin;
    4.  
    5. public listener(getkillerplugin plugin) {
    6. this.plugin = plugin;
    7. }
    8.  
    9.  
    10. @EventHandler
    11. public void onDeath(PlayerDeathEvent e)
    12. {
    13. if(e.getEntity() instanceof Player)
    14. {
    15. Player p = e.getEntity();
    16. p.sendMessage("the test work");
    17. if(e.getEntity().getKiller() instanceof Player)
    18. {
    19. Player killer = e.getEntity().getKiller();
    20. killer.sendMessage("the test work");
    21. }
    22. }
    23. }
    24. }
    25.  


    Should do it. //still editing//

    This post has been edited 3 times. It was last edited by brord Dec 8, 2012.
    StickyMan likes this.
  12. Offline

    StickyMan

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    let's start with that the if you don't have something helping to say don't say it

    can you help me please i am new in develop bukkit plugins
  13. Offline

    Tirelessly

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    What? You think you can do this without learning java? At least read the bukkit wiki. You know why I don't want to help you? Because if I spoon feed you code you're going to come back every day and ask for more, and if you actually learn what you're doing you will figure things out on your own. That's why I urge @brord to delete his code..
    number1_Master and iZanax like this.
  14. Offline

    lol768 BukkitDev Staff

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Take a look at the provided code: http://forums.bukkit.org/threads/get-the-killer-that-kill-the-player.114996/#post-1445132

    I can understand why you may not wish to help, but berating the OP doesn't really help the matter. Some people learn by example. I do admit it might be worth learning some simple Java prior to this, however.

    This post has been edited 1 time. It was last edited by lol768 Dec 8, 2012.
    tommycake50 and StickyMan like this.
  15. Offline

    brord

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    IF he has basic java knowledge, and takes a look at the most simple code i gave him, he should be fine.
    I learned it by example, so i dont think others shouldnt be allowedto
  16. Offline

    Tirelessly

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Lol
  17. Offline

    brord

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Yea, agreed
  18. Offline

    Tirelessly

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    I'll tag you in the post he makes tomorrow.
  19. Offline

    brord

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    xD Good, ill give him a word doc with heaps of pages explaining the simple thing he needs
  20. Offline

    Tirelessly

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    It's called the bukkit wiki.
  21. Offline

    brord

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
  22. Offline

    iZanax

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    OffTopic:
    This kind of threads happen to appear more often,
    If u got stuck at some point, then it not a problem to ask around here.
    But if u don't even tried or read anything that might help, that is just bad.
    Just use Google and Java Documentation, it helps 9 out of 10 times...
    If u still get stuck, then come here, and ask so precisely as possible,
    To get the fastest and the best answer

    http://docs.oracle.com/javase/7/docs/api/ #Java Documentations
    http://docs.oracle.com/javase/tutorial/ #Java Tutorials
    http://jd.bukkit.org/doxygen/ #Bukkit Documentations
    http://wiki.bukkit.org/Plugin_Tutorial #Bukkit Tutorials

    This post has been edited 1 time. It was last edited by iZanax Dec 8, 2012.

Share This Page