Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package de.reapex;
- import com.github.theholywaffle.teamspeak3.TS3Api;
- import com.github.theholywaffle.teamspeak3.api.wrapper.Channel;
- import com.github.theholywaffle.teamspeak3.api.wrapper.Client;
- import java.util.Timer;
- import java.util.TimerTask;
- public class AfkMover {
- private static Timer timer;
- private static String exactAfkChannelName = "[cspacer]» AWAY FROM KEYBOARD «";
- private static int waitTimeSec = 1;
- private static int idleTimeUntilMoveSec = 60;
- private static boolean onlyMoveWhenMuted = true;
- public static void start(TS3Api api){
- Channel afkChannel = api.getChannelByNameExact(exactAfkChannelName, false);
- if(afkChannel == null) {
- Output.writeLine("RXBOT » Channel nicht gefunden!");
- return;
- }
- timer = new Timer();
- timer.schedule(new TimerTask() {
- @Override
- public void run() {
- for(Client client : api.getClients()){
- try {
- if(client.isServerQueryClient()) continue;
- if(client.getIdleTime() > idleTimeUntilMoveSec*1000 && client.getChannelId() != afkChannel.getId()) {
- if((onlyMoveWhenMuted || client.isOutputMuted() || client.isInputMuted()) || !onlyMoveWhenMuted) {
- api.moveClient(client.getId(),afkChannel.getId());
- Output.writeLine("[AfkMover] " + client.getNickname() + " was moved to " + exactAfkChannelName + "!");
- }
- }
- }
- catch (Exception e) {}
- }
- }
- },0,waitTimeSec*5000);
- }
- public static void stop(TS3Api api){
- if(timer != null) {
- timer.cancel();
- timer = null;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement