Getting online players...

Discussion in 'Plugin Development' started by thecreator153, Nov 1, 2014.

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

    thecreator153

    Hi, I'm trying to get the number of online players. I'm using Spigot, and I try doing Bukkit.getOnlinePlayers() in IntelliJ but it says there is an ambiguous method call. When i looked closer it seemed that the are two methods in the Bukkit class, one returning a Player[], the other returning a Collection<? extends Player>. How do i specify that which method i want to call? I'd rather do the one that returns a collection since it seems more versatile, but it really doesn't matter. Note that this error isn't occurring for me in NetBeans, it just gives me a deprection warning.
     
  2. Offline

    teej107

    Newer Bukkit builds return a Collection. I think it's 1.7.9 and up? Idk for sure because I never save Bukkit.getOnlinePlayers() to a variable. I only loop through it which you can do with both Collections and Arrays.
     
    ChipDev and XXLuigiMario like this.
  3. 1. Don't say Spigot if you don't want your thread to be closed.
    2. Are you sure you aren't you aren't importing CraftBukkit instad of Bukkit, because weird things like this happen if you do.
     
  4. Offline

    TheCodingCat

    if you are getting a problem with Bukkit.getOnlinePlayers() then try
    Bukkit.getServer().getOnlinePlayers()
     
  5. Offline

    teej107

    Bukkit is the API which you should always use. CraftBukkit is only needed if you are using NMS.
    That makes no difference and both of them return the same thing.
     
  6. Aww, those were the days!
     
    XXLuigiMario likes this.
  7. Offline

    Monkey_Swag

    AdamQpzm rip TheDoctor, he would always complain about things like that
     
Thread Status:
Not open for further replies.

Share This Page