Development Assistance Updating 1.7 to 1.8

Discussion in 'Plugin Help/Development/Requests' started by pjr8, Jun 21, 2015.

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

    pjr8

    Code:
      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)) {
            players.add(p);
          }
        }
        return players;
      }
    The problem with this is since I am in 1.8 the "Bukkit.getOnlinePlayers()).length;" won't work, it says "
    Type mismatch: cannot convert from Collection<capture#6-of ? extends Player> to Player[]" I have no idea.
     
  2. Online

    timtower Administrator Administrator Moderator

    Moved to Bukkit alternatives
    @pjr8 Change the array in a list.
     
  3. Offline

    pjr8

  4. Online

    timtower Administrator Administrator Moderator

    @pjr8 List<Player> playerList = getServer().getOnlinePlayers() ?
     
  5. Offline

    pjr8

    It won't work, maybe because the List is suppose to be an integer
     
  6. Offline

    xTrollxDudex

    Get the size of the list
     
Thread Status:
Not open for further replies.

Share This Page