TeamSpeak 3 Java API
A Java wrapper of the TeamSpeak 3 Server Query API
- Contains almost all server query functionality! (see TeamSpeak 3 Server Query Manual)
- Built-in keep alive method
- Threaded event-based system
- Both synchronous and asynchronous implementations available
- Can be set up to reconnect and automatically resume execution after a connection problem
- Utilizes SLF4J for logging abstraction and integrates with your logging configuration
Option 1 (Standalone Jar):
Download the latest release and add this jar to the buildpath of your project.
Option 2 (Maven):
Add the following to your pom.xml:
<dependency> <groupId>com.github.theholywaffle</groupId> <artifactId>teamspeak3-api</artifactId> <version>...</version> </dependency>
This API utilizes SLF4J for logging purposes and doesn't come shipped with a default logging implementation, if you use Maven instead of the standalone jar. You will manually have to add one via Maven to get any logging going, if you don't have one already.
The easiest way to do so is to just add SimpleLogger to your project, which also supports configuration via config file (needs to be shipped as a resource with your jar), if you want to log
DEBUGmessages for instance (e.g. raw client-server communication).
See this configuration example for SimpleLogger. Add the following to your pom.xml to get started:
<dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-simple</artifactId> <version>1.7.25</version> </dependency>
You can however choose whichever logging framework suits your needs best. Just add your logging framework and the corresponding binding to your pom.xml.
All functionality is contained in the TS3Api object.
- Create a TS3Config object and customize it.
- Create a TS3Query object with your TS3Config as argument.
TS3Query#connect()to connect to the server.
TS3Query#getApi()to get an TS3Api object.
- Do whatever you want with this api :)
final TS3Config config = new TS3Config(); config.setHost("220.127.116.11"); final TS3Query query = new TS3Query(config); query.connect(); final TS3Api api = query.getApi(); api.login("serveradmin", "serveradminpassword"); api.selectVirtualServerById(1); api.setNickname("PutPutBot"); api.sendChannelMessage("PutPutBot is online!"); ...
FloodRate.UNLIMITED if you are sure that your query account is whitelisted (query_ip_whitelist.txt in Teamspeak server folder). If not, use
FloodRate.DEFAULT. The server will temporarily ban your account if you send too many commands in a short period of time. For more info on this, check the TeamSpeak 3 Server Query Manual, page 6.
|Option||Description||Method signature||Default value||Required|
|Host/IP||IP/Host of TeamSpeak 3 server.||
|QueryPort||Query port of TeamSpeak 3 server.||
|FloodRate||Prevents possible spam to the server.||
|Communications logging||Log client-server communication.||
|Command timeout||Time until a command waiting for a response fails||
Questions or bugs?
Please let us know here. We'll try to help you as soon as we can.
If you just have a simple question or want to talk to us about something else, please join the repository chat on Gitter.