Advertisement
Guest User

Untitled

a guest
Dec 25th, 2016
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. package fr.plaigon.ts3link.common.packets;
  2.  
  3. import java.util.HashMap;
  4. import java.util.List;
  5. import java.util.Map;
  6. import java.util.logging.Level;
  7.  
  8. import com.github.theholywaffle.teamspeak3.TS3Api;
  9. import com.github.theholywaffle.teamspeak3.TS3Config;
  10. import com.github.theholywaffle.teamspeak3.TS3Query;
  11. import com.github.theholywaffle.teamspeak3.api.wrapper.Channel;
  12. import com.github.theholywaffle.teamspeak3.api.wrapper.Client;
  13.  
  14. public class test {
  15.  
  16. public static void main(String[] args)
  17. {
  18. final TS3Config config = new TS3Config();
  19. config.setHost("ts3 server ip");
  20. config.setDebugLevel(Level.ALL);
  21.  
  22. final TS3Query query = new TS3Query(config);
  23. query.connect();
  24.  
  25. final TS3Api api = query.getApi();
  26. api.login("username", "password");
  27. api.selectVirtualServerById(1);
  28. api.setNickname("PutPutBot");
  29. api.sendChannelMessage("PutPutBot is online!");
  30.  
  31. // Get all channels and map their channel IDs to them
  32. System.out.println(api.getChannels());
  33. List<Channel> channels = api.getChannels();
  34. Map<Integer, Channel> channelMap = new HashMap<>(channels.size());
  35. for (Channel channel : channels) {
  36. channelMap.put(channel.getId(), channel);
  37. }
  38.  
  39. // List all clients in the console
  40. for (Client c : api.getClients()) {
  41. // Get the client's channel
  42. Channel channel = channelMap.get(c.getChannelId());
  43.  
  44. // Write the client and channel name into the console
  45. System.out.println(c.getNickname() + " in channel " + channel.getName());
  46. }
  47.  
  48. // We're done, disconnect
  49. query.exit();
  50. }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement