get the killer that kill the player

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

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

    StickyMan

    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)
     
  2. Offline

    Tirelessly

    Go on then.
     
  3. Offline

    Woobie

    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

    and i need help with it
     
  5. Offline

    KingMagnus

    He literally gave you exactly what you asked for what more do you need help with?
     
  6. Offline

    StickyMan

    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

    Your class needs to implement Listener

    "public class xxxxx implements Listener {

    }"
     
  8. Offline

    StickyMan

    nice idea
    but i need more ideas

    thanks in advence
    itay
     
  9. Offline

    Tirelessly

    You should start by learning java?
     
    MordorKing78 likes this.
  10. Offline

    lol768

    Events also need registering, btw.
     
  11. Offline

    brord

    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//
     
    StickyMan likes this.
  12. Offline

    StickyMan

    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

    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

    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.
     
    tommycake50 and StickyMan like this.
  15. Offline

    brord

    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

    Lol
     
  17. Offline

    brord

    Yea, agreed
     
  18. Offline

    Tirelessly

    I'll tag you in the post he makes tomorrow.
     
  19. Offline

    brord

    xD Good, ill give him a word doc with heaps of pages explaining the simple thing he needs
     
  20. Offline

    Tirelessly

    It's called the bukkit wiki.
     
  21. Offline

    brord

    SHhhhh
     
  22. Offline

    iZanax

    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
     
Thread Status:
Not open for further replies.

Share This Page