5zig / The-5zig-API

The official client API of The 5zig Mod.
Apache License 2.0
11 stars 2 forks source link

ModAPI#getServerPlayers() returns an error #13

Closed roccodev closed 7 years ago

roccodev commented 7 years ago

ModAPI#getServerPlayers() returns an error saying "This method can only be called in a world!"

5zig commented 7 years ago

When are you calling the method? You should only call it when you know that the player is already connected to the server and inside a world.

roccodev commented 7 years ago

Oh, I was running it in a ServerConnectEvent listener, maybe I should delay it.

5zig commented 7 years ago

Yeah, during the connect event the client doesn't have any information about the player list. You could try to use the TickEvent and call the getServerPlayers() function as soon as ModAPI#isInWorld() returns true.