Who has the most lives (Minigame)?

Discussion in 'Plugin Development' started by Blockhead7360, Jun 22, 2015.

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

    Blockhead7360

    Hello!

    I am making a minigame for my server, and I was wondering how to check for who has the most lives in a hashmap. But I also just want the players in the arena.

    There are 4 players per arena, but all lives from ALL arenas are stored in the same hashmap. So I wanted to check to see out of the 4 players, who has the highest number (from the hashmap). Can anyone help me with that?

    If you need any code, just ask.
     
  2. Offline

    JBoss925

    Use the HashMap#get(UUUID player) <or whatever you're storing the players as> method to get the lives of a certain player from the hashmap. Then compare them.
     
  3. Offline

    Zombie_Striker

    @Blockhead7360
    • Store their names or UUID, not the entire player (use String or uuid, not Player for storing)
    • create a string field that stores the players name, one that stores their points as an int, and then justLoop through all players and compare each player to the fields, and if their score is better you would replace the values.
     
  4. Offline

    Blockhead7360

    Last edited by a moderator: Jun 12, 2016
  5. Offline

    JBoss925

    Ok, well in your big hashmap, store each player's UUID and the amount of lives they have. Then with your single arena hashmap do hashmap#keyset() to get all of the UUIDs of the players in the arena. Then you're going to want to loop through the large hashmap with all the lives hashmap#keyset() and see if any of the UUIDs match up with the players in the arena. When it finds a match, in a new arena-specific hashmap, store the UUID and amount of lines. Then, create a UUID variable called, "highestLives" and set it to the first player's UUID. Then loop through all the key values and check to see if each players lives from arenaSpecificHashMapWithLives#get(UUID player) is larger than arenaSpecificHashMapWithLives#get(highestLives). If so, set highestLives to the new player. Then continue to loop through until done.
     
  6. Offline

    Blockhead7360

Thread Status:
Not open for further replies.

Share This Page