Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Errors / Bugs? #323

Open
YourGameSpace opened this issue Apr 1, 2019 · 6 comments
Open

Errors / Bugs? #323

YourGameSpace opened this issue Apr 1, 2019 · 6 comments

Comments

@YourGameSpace
Copy link

Hello,

Unfortunately I have several mistakes and unfortunately can not explain them to me. As you can see on the screenshot (see below), I get (not always, but often) this error when a client leaves the server .. My corresponding code, as well as the methods used are attached via Pastebin.

In addition .. When I send a private message, also appears again and again a bug in the console that the client ID is wrong (see also screenshot), but the client receives the message. But why the mistake? The client ID is correct in every case?

Then another thing .. If I send several (private) messages in a row, then they have a delay .. Means: (I noticed so ..) When I send messages in a row, so claim two messages a whole second. Sum of time: 3 seconds .. And that's too much or just not good ..

Hope it can be helped me with these things .. Send also like to request more parts of my code

LG TUBEOF

https://i.imgur.com/zccTg1M.png (Console)
https://i.imgur.com/P4wNXm2.png (Code)
https://i.imgur.com/bhdJFtx.png (Code)

@rogermb
Copy link
Collaborator

rogermb commented Apr 1, 2019

getClientInfo only works if the client is online. By the time you're getting a ClientLeaveEvent, the client has already left the server. Therefore, that command will always fail.

More explanation of this phenomenon in other issues or the FAQ 😄

@YourGameSpace
Copy link
Author

I leave the ClientInfo with the important information in the beginning when the client on the server cache join (cache) so that I can then retrieve them -> ClientInfo clientInfo = data.getCacheClientInfo (clientId);

@rogermb
Copy link
Collaborator

rogermb commented Apr 1, 2019

Oh, my bad, I just kinda glanced over your code 😅

If you're getting a NullPointerException at this specific line:

ClientInfo clientInfo = data.getCacheClientInfo(clientId);

then the only logical conclusion is that data - for whatever reason - is null. That's the only expression on this line that could cause an NPE.

@Tumbledore
Copy link

Hey @TUBEOF , I think your second Method could be more readable:

private List<Integer> serverGroupIDs = Arrays.asList(2,4);

private boolean yourMethod(int clientID, int serverGroupID){
   return api.getServerGroupsByClientId(clientID).stream().anyMatch(serverGroup -> serverGroupIDs.contains(serverGroupID));
}

as for the NPE I think @rogermb has right: your data Object is somehow null.

@YourGameSpace
Copy link
Author

YourGameSpace commented Apr 2, 2019

To query from an offline client, if he is in a group, I use the code you sent in a different thread .. This looks like this: https://i.imgur.com/A37491w.png
The code is exactly the same in itself?

BTW I fixed the bug with the client info. However, the problem with the delay when sending messages still remains. How can I fix this? D: -.- @rogermb

@rogermb
Copy link
Collaborator

rogermb commented Apr 2, 2019

Well, your isDatabaseClientInTeam method causes way too many commands to be sent for no good reason. Remember that any call to a method in TS3Api or TS3ApiAsync causes at least one command to be sent. So instead of repeatedly calling api.getServerGroupsByClientId(databaseId), consider doing something like:

// Defined once as a field somewhere else
private final Set<Integer> TEAM_GROUP_IDS = Set.of(6, 11, 24, 45, 46, 47, 49);

// Then, in your method:
return Main.getTS3API().getServerGroupsByClientId(databaseId)
                       .stream()
                       .anyMatch(sg -> TEAM_GROUP_IDS.contains(sg.getId()));

Also, if your query runs on the same machine as your TS3 server or if you're able to add the IP of your query to the TS3 server's whitelist, you can use the FloodRate.UNLIMITED flood rate setting. That will make the query send commands at a much quicker rate (as it doesn't have to watch out not to get flood-banned), so you should see less of a delay. But even then - try not to go too wild with the number of commands you send to the TS3 server.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants