Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2020
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.87 KB | None | 0 0
  1. package de.reapex;
  2.  
  3. import com.github.theholywaffle.teamspeak3.TS3Api;
  4. import com.github.theholywaffle.teamspeak3.api.wrapper.Channel;
  5. import com.github.theholywaffle.teamspeak3.api.wrapper.Client;
  6.  
  7. import java.util.Timer;
  8. import java.util.TimerTask;
  9.  
  10. public class AfkMover {
  11. private static Timer timer;
  12.  
  13. private static String exactAfkChannelName = "[cspacer]» AWAY FROM KEYBOARD «";
  14. private static int waitTimeSec = 1;
  15. private static int idleTimeUntilMoveSec = 60;
  16. private static boolean onlyMoveWhenMuted = true;
  17.  
  18. public static void start(TS3Api api){
  19. Channel afkChannel = api.getChannelByNameExact(exactAfkChannelName, false);
  20. if(afkChannel == null) {
  21. Output.writeLine("RXBOT » Channel nicht gefunden!");
  22. return;
  23. }
  24.  
  25. timer = new Timer();
  26. timer.schedule(new TimerTask() {
  27. @Override
  28. public void run() {
  29. for(Client client : api.getClients()){
  30. try {
  31. if(client.isServerQueryClient()) continue;
  32. if(client.getIdleTime() > idleTimeUntilMoveSec*1000 && client.getChannelId() != afkChannel.getId()) {
  33. if((onlyMoveWhenMuted || client.isOutputMuted() || client.isInputMuted()) || !onlyMoveWhenMuted) {
  34. api.moveClient(client.getId(),afkChannel.getId());
  35. Output.writeLine("[AfkMover] " + client.getNickname() + " was moved to " + exactAfkChannelName + "!");
  36. }
  37. }
  38. }
  39. catch (Exception e) {}
  40. }
  41. }
  42. },0,waitTimeSec*5000);
  43. }
  44.  
  45. public static void stop(TS3Api api){
  46. if(timer != null) {
  47. timer.cancel();
  48. timer = null;
  49. }
  50. }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement