Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package fr.plaigon.ts3link.common.packets;
- import java.util.HashMap;
- import java.util.List;
- import java.util.Map;
- import java.util.logging.Level;
- import com.github.theholywaffle.teamspeak3.TS3Api;
- import com.github.theholywaffle.teamspeak3.TS3Config;
- import com.github.theholywaffle.teamspeak3.TS3Query;
- import com.github.theholywaffle.teamspeak3.api.wrapper.Channel;
- import com.github.theholywaffle.teamspeak3.api.wrapper.Client;
- public class test {
- public static void main(String[] args)
- {
- final TS3Config config = new TS3Config();
- config.setHost("ts3 server ip");
- config.setDebugLevel(Level.ALL);
- final TS3Query query = new TS3Query(config);
- query.connect();
- final TS3Api api = query.getApi();
- api.login("username", "password");
- api.selectVirtualServerById(1);
- api.setNickname("PutPutBot");
- api.sendChannelMessage("PutPutBot is online!");
- // Get all channels and map their channel IDs to them
- System.out.println(api.getChannels());
- List<Channel> channels = api.getChannels();
- Map<Integer, Channel> channelMap = new HashMap<>(channels.size());
- for (Channel channel : channels) {
- channelMap.put(channel.getId(), channel);
- }
- // List all clients in the console
- for (Client c : api.getClients()) {
- // Get the client's channel
- Channel channel = channelMap.get(c.getChannelId());
- // Write the client and channel name into the console
- System.out.println(c.getNickname() + " in channel " + channel.getName());
- }
- // We're done, disconnect
- query.exit();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement