Solved Two times PlayerDeathEvent

Discussion in 'Plugin Development' started by Julz_Dev, Sep 28, 2013.

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

    Julz_Dev

    Hello community,

    I need help with the PlayerDeathListener.

    It executes two times if a player dies.

    Example : Player 1 kills Player 2 and he gets 2 kills for this kill.

    Does anyone know why?

    Code:
    @EventHandler
        public void onPlayerDeath(PlayerDeathEvent e){
             
                e.setDroppedExp(0);
                for(int i = 0;i<e.getDrops().size();i++){
                    e.getDrops().set(i, null);
                }
             
                e.setDeathMessage("");
         
                Player killer = e.getEntity().getKiller();
                Player killed = e.getEntity();
     
                if(killer != null){     
                    e.getEntity().getWorld().playSound(e.getEntity().getLocation(), Sound.AMBIENCE_THUNDER, 2, 2);
             
                    killer.sendMessage(ChatColor.GOLD + "+1 Kill");
         
                    Main.r.sendMessage(ChatColor.DARK_GREEN + "" + killed.getName() + " was killed by " + killer.getName() + "!");
                    PlayerData.addKill(killer);
                    Bukkit.broadcastMessage("test1");
                 
                }else{
                    e.getEntity().getWorld().playSound(e.getEntity().getLocation(), Sound.GHAST_SCREAM, 2, 2);
                    Bukkit.broadcastMessage("test2");
                }
            }
         
        }
     
  2. Offline

    amhokies

    Julz_Dev
    I know there was an issue like this the other day where the guy had two instances of his plugin running on the server at once, so you might want to check that that's not the case with you.
     
  3. Offline

    Julz_Dev

    amhokies
    Two instances?
    No, I think there is only one instance.
    I have the plugin only one time on the ftp-server.

    #solved alone

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 4, 2016
Thread Status:
Not open for further replies.

Share This Page