Error in Bukkit.getOnlinePlayers()

Discussion in 'Spigot Plugin Development' started by --TOMAS--, May 24, 2016.

Thread Status:
Not open for further replies.
  1. What am I doing wrong?
    Error in: int j = (arrayOfPlayer = Bukkit.getOnlinePlayers()).length;
    Code (Text):
     private static List<Player> getPlayers(Location center, double range)
        List<Player> players = new ArrayList();
        String name = center.getWorld().getName();
        double squared = range * range;
        Player[] arrayOfPlayer;
        int j = (arrayOfPlayer = Bukkit.getOnlinePlayers()).length;
        for (int i = 0; i < j; i++)
          Player p = arrayOfPlayer[i];
          if ((p.getWorld().getName().equals(name)) && (p.getLocation().distanceSquared(center) <= squared)) {
        return players;
  2. Don't use decompiled code.
    • Agree Agree x 2
  3. I am learning.
    • Funny Funny x 1
  4. You learn by googleing it, to look through all online characters use
    for(Object var : Bukkit.getOnlinePlayers()){
    //code here.
    • Agree Agree x 1
  5. Well since you're trying to learn...let's get you to walk through your code and explain it's functionality. Let's make sure you understand what's going there before moving forward.
Thread Status:
Not open for further replies.