[Help] How do I check who on the server is in a certain GameMode!

Discussion in 'Plugin Development' started by Skatedog27, Feb 11, 2014.

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


    So... I am having a HUGE brainfart. This is driving me insane, so insane, that I am resorting to the bukkit forums for help (No offense :p) - Anyways, I am running a minigame that is based off of Gamemodes, and the only way to win, is to be the last person alive with the Adventure mode. I have tried every single possibility to fetch for all online players, and get the last player in that gamemode. Below, I am going to paste some example code (DOES NOT WORK) to give you a better idea of what I'm attempting to do:
    1. //Get the online players
    2. for (Player online : getServer().getOnlinePlayers()) {
    4. //Check to see how many online players are in adventure mode
    5. if (online.getGameMode(GameMode.ADVENTURE).length == 1) {
    7. //Set the players gamemode to survival (The minigame events only work if
    8. //you are in adventure, so by changing to survival it doesn't let the
    9. //events reach the player)
    10. online.setGameMode(GameMode.SURVIVAL);
    12. //Broadcast that the player won the game
    13. Bukkit.broadcastMessage("Player has won the game!")
    15. //Shut down server that then runs a script that connects back to bungee
    16. //and restarts the server with a clean map
    17. getServer().shutdown();
    19. }
    21. }
  2. Offline


    Do you get any errors in the console? Possibly not from what I can see, but I'm not omniscient, do you have any errors showing up?
  3. Offline


    No, that was a made up method. I wrote that to show an example of what I want it to do, because I do not know the method, therefore, I am getting no errors in console
  4. Offline


    if (online.getGameMode(GameMode.ADVENTURE).length == 1) {
    for(Player online : getServer().getOnlinePlayers()){
        List<Player> survivors = new ArrayList<Player>();
        if(online.getGameMode() == Gamemode.ADVENTURE){
        if(survivors.size() = 1){
          Player winner = survivors.get(0);
  5. Offline


    AWESOME thank you! And also: if (online.getGameMode(GameMode.ADVENTURE).length == 1) { - that was an example of what I wanted it to do, because I didn't know the method :p, but thank for your help!
Thread Status:
Not open for further replies.

Share This Page