Player death event

Discussion in 'Plugin Development' started by gamelord327, Aug 29, 2013.

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

    gamelord327

    Hi, i need my plugin to get the name of the killer of a payer and store that in a players.yml then put a number next to there name.
     
  2. Offline

    Rmarmorstein

    Code:java
    1.  
    2. @Override
    3. public void onEnable() {
    4. loadConfig();
    5. getServer().getPluginManager().registerEvents(this, this);
    6. }
    7.  
    8. private void loadConfig() {
    9. //This will just make the default config make my name have 100 kills.
    10. this.getConfig().addDefault("Rmarmorstein", 100);
    11. }
    12.  
    13. @Override
    14. public void onDisable() {}
    15.  
    16. @EventHandler (priority = EventPriority.MONITOR)
    17. public void onPlayerDeath(PlayerDeathEvent e) {
    18. Player killed = e.getEntity();
    19. //This will get the name of the person that died
    20. if(killed.getKiller() != null) {
    21. String killer = killed.getKiller().toString();
    22. int currentKill = getConfig().getInt(killer);
    23. getConfig().set("killer", currentKill + 1);
    24. }
    25. }
    26.  
     
  3. Offline

    newboyhun

    Rmarmorstein
    Line 23 : getConfig().set("killer", currentKill + 1); to getConfig().set(killer, currentKill + 1);

    Btw, why didn't you just gave him a link to the plugin tutorial, you wrote him the plugin....
     
Thread Status:
Not open for further replies.

Share This Page