TheHolyWaffle / TeamSpeak-3-Java-API

A Java wrapper of TeamSpeak's 3 server query API.
MIT License
307 stars 107 forks source link

Get ServerGroups of DatabaseClients? #211

Closed AmbroAnalog closed 7 years ago

AmbroAnalog commented 7 years ago

I need a function to get the Server Groups of All Clients in the Database.

I try to get all Clients with: ArrayList<DatabaseClient> clients = new ArrayList<>(); clients.addAll(api.getDatabaseClients());

Is it possible to get the Server Groups of an DatabasClient?

PS: I know it must be possible with Querys because YaTQA has a similar feature :)

rogermb commented 7 years ago

Strangely, while this information is saved in the database, the usual clientdblist or clientdbinfo do not send back the IDs of the server groups each database client is a member of.

You could use TS3Api#getServerGroups() to get a list of all server groups and then call TS3Api#getServerGroupClients(ServerGroup) for each group. Most likely you should only do this for regular client server groups, though, and not for template server groups or server query server groups. You can check which server group is which by calling ServerGroup#getType().

That way you could build a list of all server groups each client is a member of.

There's just one problem: Currently, there is a bug where calling getServerGroupClients on a server group with 0 members will crash our API. That's because for those groups, the TS3 server will simply not send back any data despite returning with error id=0 msg=ok. See #193 for more information.

So as a workaround until the next update, if you wanted to use that method, you'd either have to ensure that there are no empty server groups or you have to have some kind of dummy client which you would add to each available server group.

AmbroAnalog commented 7 years ago

All right. Thanks for the quick help!

You're doing a great job :*

rogermb commented 7 years ago

Thanks :smile: