Solved for (Player player : ) Issue

Discussion in 'Spigot Plugin Development' started by JavoxDub, Aug 9, 2018.

Thread Status:
Not open for further replies.
  1. Hello. I have a problem with the line that saids " for (Player player : )". I don't know if its my fault but i'm really stressed.

    Here is a piece of my code:

    Code (Java):
      public void callPlayer(AsyncPlayerChatEvent e)
        for (Player player : )
  2. You most likely want to iterate over all players of the server that are online.

    Let's take a look at the enhanced for loops syntax. This is described by hundreds of source, but when looking at stackoverflow, this one will perfectly fit:

    You should learn some fundamental java skills, you will need them. As soon as you have understood the for loop, you will need to proceed.
  3. Syntax error. Do you want this:
    Code (Java):
    for (Player player : Bukkit.getOnlinePlayers()) {
    that is a for-each loop, you have to specify a collection wich implements the Iterable interface.
    • Optimistic Optimistic x 1
  4. There needs to be an Iterable object behind the colon, yet you have nothing. All collections and arrays are iterable. I assume you want all players on the server, which would go like this.
    Code (Text):
    for (Player player: getOnlinePlayers()) { ... }
  5. It was that, now it works. Thanks!

    I would check it. Thanks also!
Thread Status:
Not open for further replies.