When using getOnlinePlayers in the 1.7 protocol hack, nothing happens. It seems like the code is skipped, but no idea why. Thank you!
Maybe you compile against minecraft 1.8 and the compiler uses the version of getOnlinePlayers() that returns an array. Wouldn't that cause a NoSuchMethodException?
Well it works for me, so all that can be assumed is user error. More code would be nice, because it's certainly a problem with the surrounding code, not the #getOnlinePlayers call itself.
For me I really don't like using deprecated code, so I fastly made my own getOnlinePlayers() Method. If you want, you can use it: Code (Text): public List<Player> getOnlinePlayers() { List<Player> players = new ArrayList<Player>(); for(World world : Bukkit.getWorlds()) { for(Player player : world.getPlayers()) { players.add(player); } } return players; } I hope I could help you! ~ Sorry for my english CBPlugins
That's a much, much slower method than using Bukkit#getOnlinePlayers (which OP really isn't having a problem with anyhow)
#getOnlinePlayers is not deprecated, the return value was just changed in the 1.8 update. It now returns a Collection by default, but you can still use #toArray() and OP, https://hub.spigotmc.org/jira/browse/SPIGOT-103
Yes you are right But I thought @TheTrollzJ 's code is not working on the #getOnlinePlayers Methode in the 1.7 protocol hack version of spigot. And with the code snippet I posted it should definitly work fine.
The problem isn't with #getOnlinePlayers, it's completely different. We just don't have context because more code hasn't been posted.
Well, they did give us code: Code (Java): for(Player p : Bukkit.getOnlinePlayers()){ // code } Maybe he thinks the compiler magically turns //code into whatever he wants!
Make sure you are importing from bukkit and not craftbukkit, this is because CB returns both an array of online players and a collection, which causes a conflict.