[SOLVED] [1.7.10] How to get player kill and death count?

Discussion in 'Spigot Plugin Development' started by Jad, Feb 20, 2015.

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

    Jad

    I need 2 ints for scoreboard plugin, one that gets how many players you've killed, and how many times you have died. Probably a stupid question, but thats all I need.
     
  2. Jad

    Jad

    No, I got all the scoreboard stuff. But I just need these 2 ints.
     
  3. Serializator

    Supporter

    Do you want to use those variables in an Objective or do you want to use them for something else?
     
  4. Code (Text):

    HashMap<UUID, Integer> deathsMap = new HashMap<UUID, Integer>();
    @EventHandler
    onPlayerDeath(PlayerDeathEvent event){
        if(killsMap.containsKey(event.getPlayer().getUniqueId())){
            killsMap.put(event.getPlayer().getUniqueId(), killsMap.get(event.getPlayer().getUniqueId())+1);
        }
        else{
            killsMap.put(event.getPlayer().getUniqueId(), 1);
        }
    }
     
    Just an example
     
  5. Or you could just ask bukkit/spigots statistics manager for the player kills and number of deaths stats.
     
  6. Jad

    Jad

    Where's this statistics manager?
     
  7. I have an old plugin that counts how many kills each player has and logs to a database, In which i can send you some code to implement into your scoreboard?
     
    • Friendly Friendly x 1
    • Creative Creative x 1
  8. player.getStastic (Statistic.PLAYER_KILLS);
    And
    player.getStatistic (Statistic.DEATHS);
     
    #9 MrBlobman, Feb 20, 2015
    Last edited: Apr 4, 2017
    • Like Like x 7
    • Winner Winner x 2
  9. Jad

    Jad

    OMFG, THANK YOU!!
    I SPENT LIKE HOURS USING THE CONFIG TO STORE AND I JUST GAVE UP.

    PRAISE THE LOORRRDD!!

    HOW CAN I REPAY YOU! :DDDD
     
Thread Status:
Not open for further replies.