Solved Detecting if everyone has the same GM other than 1 person

Discussion in 'Plugin Development' started by _Error, Jul 4, 2015.

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

    _Error

    So I want a way to check if everyone on my server is in SPECTATOR mode other than 1, Then perform actions with that person.
     
    Last edited: Jul 5, 2015
  2. @_Error Uhhh, it's right in your signature "Please do not beg me to code for you"
    We will not spoon feed you code. What have you tried so far?
     
  3. Offline

    _Error

    Nobody's perfect, I don't know how to do everything. I put this lign in my signature cause around 2 people ask me per day for me to work with them/ make them a plugin.

    To be honest I did not get any idea of how to do it. That's why i'm asking.
    Plus did I say I wanted people to Spoon feed me?
    Please do not make up words that were not spoken.

    Plus, I do help others when I have ideas on how to do it, Read my entire signature. If you understood it wrong, It's your fault. I said 'I help people', I can give them ideas on how to do stuff, and I even sometimes gives lines of code. Note that helping does not mean make an entire plugin for them or work for them.
    This forum is to get help, and not to hate on people that are asking questions.
     
  4. Offline

    Zombie_Striker

    @_Error
    --------------
    How can you get even on average 2 people per day? What do you say/where do you go?
    --------------
    Finally, what you are asking for is how to loop through all players online and then check if the player#getGameMode() is that of a spectator.

    This is elementary. Even if this is just a hobby, you learn java. In order to work on making plugins, you should be able to understand how to use a for loop.
     
    Synapz likes this.
  5. Offline

    Synapz

    @_Error

    Code:
    // loop through every player in the game, FOR each player do the following:
    
    // check if their gamemode is '==' to Gamemode Spectator
    // if it is spectator and the player's name is not {NAME OF 1 PERSON YOU WANT TO IGNORE} perform actions...
    // otherwise, do nothing
    
    
    You can hardcode their name, if player.getName().equals(name), or you can place this code in a onCommand and take the args on the command (arg[0] would be the name) and use that as the name to ignore.

    edit: ninja'd!!! second time this happened today >.< Hopefully my post helps aswell!
     
    _Error and Zombie_Striker like this.
  6. Offline

    Zombie_Striker

    Also,
    No, this forums is for people who know java and for questions that you do not learn in the first couple chapters of ANY Java tutorial.
     
    Synapz likes this.
  7. Offline

    SuperSniper

    @_Error

    Fine, ill spoonfeed you this once.

    Code:
    
    for(Player players : Bukkit.getOnlinePlayers() {
       if(players.getGameMode == GameMode.GAMEMODE && player.getGameMode == GameMode.GAMEMODE) {
          // do stuff
    
    
    EDIT: player = player that you want to check if their gamemode is the same as others.

    players = all other players.
     
    Last edited: Jul 4, 2015
    _Error and feff890 like this.
  8. Offline

    _Error

    For your information I read the entire java tutorial from oracle, And I absolutely know how to make a for loop, But I'm pretty new to Bukkit, I used to code a little in the 1.6.4, But stuff changed and I kinda forgot, Then from 5months ago I read the Orcale tutorials and 1 month later I started coding Bukkit
    Thanks, But I know how to do it with a IGN I just wanted a way to test if everyone has gm3 on the server other than 1 person, Not specified then perform actions with him. If this was not the case then with IGN it would be very easy to code.
    I want does not mean I want you to spoonfeed me, I will use I want a way for future misunderstandings, It was 5am when the post has been shared.

    As I said, I'm not specifying a player, I want to see if lets say 7 people have gm0 and 1 other has gm1, But that other person is unknown.
     
    Last edited: Jul 5, 2015
  9. Offline

    stefvanschie

    So it doesn't matter who the other person is?
    Code:
    int oddPlayers = 0;
    for (Player p : Bukkit.getOnlinePlayers()) {
      if (p.getGameMode() == GameMode.SPECTATOR) {
        //right person
      } else {
        oddPlayers++;
        if (oddPlayers >= 2) {
          //not everyone (except one player) is in gamemode spectator
          break;
        }
      }
    }
    if (oddPlayers <= 1) {
    //do your stuff
    }
    
     
  10. Offline

    Zombie_Striker

    @stefvanschie
    Please remove this, He said
    Please remove your post.
     
  11. Offline

    _Error

    Solved
     
  12. Locked upon request.
     
Thread Status:
Not open for further replies.

Share This Page