org.bukkit.Server.getPlayer says it may return null for offline players. Is there a way to get info on offline players without manually looking in the world file and the player.dat files? Specifically I'm trying to determine if a player exists with a certain name who may be offline. I could check if the name.dat file exists, but I'm hoping there is an easier way.
Why do you need an easier way? Code: boolean playerExists(String name) { try { FileInputStream test = new FileInputStream("world/players/"+name+".dat); } catch (FileNotFoundException e) { //no player.dat file so return false return false; } //if code got this far then file must exist: return true return true; } should work I think (though not actually tested)
How about this then as a slight improvement? Code: boolean playerExists(String name) { if(referenceToServer.getPlayer(name) != null) return true; try { FileInputStream test = new FileInputStream("world/players/"+name+".dat); } catch (FileNotFoundException e) { return false; } return true; }
Yes that's the best way I can think of, but what I was getting at is that he wanted to know if there is something like getOfflinePlayers() or something and that is WHY he wanted to know a better way than filesystem Offtopic: Edward from your posts I can see that it's a real shame you live in England, otherwise I'd like to employ you
I will be using this approach to check for offline players. But the functionality to access offline players may be useful for a variety of reasons beyond just checking for existence so I was curious if the functionality existed. Apparently it does not. Thanks for the replies.