Hey guys! I feel like this is a super simple question, but I want it so when a player joins, it checks if the player count is at a certain number that is set in the config.yml, but I have no idea how to do that without ServerListPingEvent. Here's what I have so far: Code (Text): @EventHandler public void onJoin(PlayerJoinEvent e) { if (/*somehow get player count of the bukkit server */ == (plugin.getConfig().getInt("Players-Needed"))) { Bukkit.getConsoleSender().sendMessage("§7[§b§lSERVERMANAGER§7] §bThe Minimum Player Count has been reached."); doSomething(); } } Any help would be appreciated, again, sorry if this is such a simple question to answer . Thanks, - Cervinakuy
Try this Edit: Code (Text): int playercount = Bukkit.getServer().getOnlinePlayers().length; if(playercount == 1){ //do stuff }
??????? Not even one thing in this method makes sense. First you define a Player with a collection of players and then you compare it with an integer. @StalexDev 's method is the right thing to do
yep i know this is correct Code (Text): int playercount = Bukkit.getServer().getOnlinePlayers().length; if(playercount == 1){ //do stuff }
The .getOnlinePlayers() method changed, so depending on your version you have to use .size() or .length
I knew it had to be that simple! I must have accidently skimmed over it in the dropdown for Bukkit., anyways, thank you guys for the help! Very true. Thanks, - Cervinakuy