Solved Last Man Standing Check Function?

Discussion in 'Plugin Development' started by Wintergrasped, Oct 28, 2014.

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

    Wintergrasped

    My friend and I made mini-game plugin the we have mainly got working all the functions and check and timers and teams ETC work just fine but I cant seam to get a function to check if theres just one person left on the server that alive (mini-g. Any ways i needed it so that I have probally tried 400+ ways to possiblly do it like adding the people who dead to a List And comparing the length of that array to the length of Bukkit.GetOnlinePlayers but nothing.....
     
  2. Offline

    Gamecube762

    Well it depends on how you set up your minigame. I would just have a list of alive players and after every death, check if the list only contains 1 player, if so, they are the last.
     
  3. Wintergrasped use a HashSet<UUID> which stores all UUID's of the Players who are playing the game. then check for playerdeathevent (something like this should exist, not quied sure how it is called, sorry) and use set.remove(Player.getUUID()). after this call set.getSize() and if size == 1 you can end the minigame, get the last standing player with Bukkit.getPlayer(set.toArray()[0]) and send him/her a message or do whatever you want to do with the last surviving player

    Hope i could help you :)
     
    Wintergrasped likes this.
  4. Offline

    Wintergrasped

    SOLVED -
    Thanks this worked exactly.
     
  5. Offline

    Gamecube762

    Shmobi Bukkit TOS and Rules:
     
  6. Gamecube762 wuupsy, don't knew a rule like this exists. Also i guess in the most cases the threadcreator will be very happy about the solution but doesn't even think about to like the answer which solved the problem, because at this moment he doesn't spend any attention to this function. I think their whole attention at this timepoint is about fixing thier problem with the given solution. As you can read
    The answer i gave was exactly what he was searching for and it is a very good solution as you should recognize. So i think, that the answer is a like worth, isn't it?
     
    Wintergrasped likes this.
Thread Status:
Not open for further replies.

Share This Page