Solved Getting all online players not working correctly.

Discussion in 'Plugin Development' started by Shadorunce, Jul 26, 2019.

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

    Shadorunce

    Hello everyone, I'm having a problem that I haven't been able to work out yet. I'm needing to get all currently online players so that I can make changes to their inventories. I'll be straight forward that fairly new to programming, Java dev and MC Plugin dev, but I can at least read some of it and understand and help alter our plugins to a certain point, but I don't know any alternatives and haven't been able to find anything else yet.

    I'm using a loop of "for(Player p : Bukkit.getServer().getOnlinePlayers()){method(p);}"

    The problem i'm having though is in our test server of just 2 people (both online at the same time), it would only show one of the currently online players depending on who connected to the server last.

    I've also tried "Bukkit.getOnlinePlayers()" but it was still the same result.

    I had the same issue, but was able to resolve that with "p = Bukkit.getPlayer(args[0]);", but was told elsewhere that this method was deprecated.

    Thank you for any assistance.
     

    Attached Files:

  2. Online

    timtower Administrator Administrator Moderator

    @Shadorunce deprecated for the uuid change.
    And move the return to outside the loop
     
  3. Offline

    Shadorunce

    Thank you so much. Can't believe it's something so simple. I'm used to dealing with ifs and didn't think about "for" process.
     
Thread Status:
Not open for further replies.

Share This Page