Closed Axtkaempfer closed 5 years ago
Hi Axtkaempfer 😄
First - timing. Your code currently does things in this order:
but it should be
But this isn't what's causing your bad performance issue.
This API offers two different flood rate settings, DEFAULT
and UNLIMITED
. By default, this API will only send one command every 350 milliseconds, because the TS3 server only allows queries to send 10 commands every 3 seconds. Queries that send commands too quickly will be banned.
Now, the way around this limit is to add IP of the server query client to the TS3 server's query_ip_whitelist.txt
file, but as you're already connecting to localhost
, you don't even need to do that, you're already whitelisted by default.
In other words, you just need to tell the TS3Query to use the UNLIMITED
flood rate setting by calling config.setFloodRate(FloodRate.UNLIMITED);
.
So to fix both of the issues I mentioned, you could start your code like this:
public static TS3Query query;
public static TS3Api api = query.getApi();
public static void connectTeamspeak() {
UltimateCards.print("§7Verbindung wird aufgebaut...");
TS3Config config = new TS3Config();
config.setHost("localhost");
config.setQueryPort(10011);
config.setFloodRate(FloodRate.UNLIMITED);
query = new TS3Query(config);
query.connect();
api = query.getApi();
[...]
Also, you should try to reduce the number of calls to TS3Api
methods if they aren't necessary. For example, api.getClients()
only returns a list of clients that are online, so basically, all of those calls to api.getClientByUId
and api.isClientOnline
in your isUserOnline
method are redundant.
Thank you works fine now!
Awesome, thanks for letting me know! Closed 😄
Hello, when I start the server, the API connects to the server as far as good, but if I interact with the API, for example, create a channel or a client move the server laggs for about 3-4 seconds and reacts after the action performed normally again. I have already tried to program the API Asyncron with the same success. An error itself does not occur directly but the above problem occurs.
package
com.github.norbo11.util;import java.util.HashMap; import java.util.Map;
import org.bukkit.Bukkit; import org.bukkit.entity.Player;
import com.github.norbo11.UltimateCards; import com.github.theholywaffle.teamspeak3.TS3Api; import com.github.theholywaffle.teamspeak3.TS3ApiAsync; import com.github.theholywaffle.teamspeak3.TS3Config; import com.github.theholywaffle.teamspeak3.TS3Query; import com.github.theholywaffle.teamspeak3.api.ChannelProperty; import com.github.theholywaffle.teamspeak3.api.CommandFuture; import com.github.theholywaffle.teamspeak3.api.wrapper.Channel; import com.github.theholywaffle.teamspeak3.api.wrapper.Client; import com.github.theholywaffle.teamspeak3.api.wrapper.ClientInfo;
import de.axt.MySQL.MySQLTS;
public class TeamspeakUtils {
} `