Brauche Hilfe bei Java/der Ts3 API von theholywaffle

Bitte aktiviere JavaScript!
Ich habe erst vor kurzem mir Java angefangen und habe diesen Fehler:
Code:
Exception in thread "Timer-1" Exception in thread "Timer-0" java.lang.NullPointerException
    at com.github.theholywaffle.teamspeak3.TS3Query.doCommandAsync(TS3Query.java:226)
    at com.github.theholywaffle.teamspeak3.TS3ApiAsync.executeAndTransform(TS3ApiAsync.java:5394)
    at com.github.theholywaffle.teamspeak3.TS3ApiAsync.getClients(TS3ApiAsync.java:2314)
    at com.github.theholywaffle.teamspeak3.TS3Api.getClients(TS3Api.java:1921)
    at de.velortex.ts3querybot.events.afkmover$1.run(afkmover.java:23)
    at java.util.TimerThread.mainLoop(Unknown Source)
    at java.util.TimerThread.run(Unknown Source)
java.lang.NullPointerException
    at com.github.theholywaffle.teamspeak3.TS3Query.doCommandAsync(TS3Query.java:226)
    at com.github.theholywaffle.teamspeak3.TS3ApiAsync.executeAndTransform(TS3ApiAsync.java:5394)
    at com.github.theholywaffle.teamspeak3.TS3ApiAsync.getClients(TS3ApiAsync.java:2314)
    at com.github.theholywaffle.teamspeak3.TS3Api.getClients(TS3Api.java:1921)
    at de.velortex.ts3querybot.events.supportchannel$1.run(supportchannel.java:32)
    at java.util.TimerThread.mainLoop(Unknown Source)
    at java.util.TimerThread.run(Unknown Source)
Meine Main Class aus der alles geladen wird:
Java:
package de.velortex.ts3querybot.main;

import com.github.theholywaffle.teamspeak3.TS3Api;
import com.github.theholywaffle.teamspeak3.TS3Config;
import com.github.theholywaffle.teamspeak3.TS3Query;
import com.github.theholywaffle.teamspeak3.TS3Query.FloodRate;

import de.velortex.ts3querybot.events.afkmover;
import de.velortex.ts3querybot.events.botmessage;
import de.velortex.ts3querybot.events.supportchannel;
import de.velortex.ts3querybot.events.supportnotify;

public class load {

    public static final TS3Config config = new TS3Config();
    public static final TS3Query query =new TS3Query(config);
    public static final TS3Api api = query.getApi();
 
    public static void main(String[] args) {
        config.setHost("37.114.51.209");
        config.setFloodRate(FloodRate.UNLIMITED);
        query.connect();
        api.login("serveradmin", "passwor");
        api.selectVirtualServerByPort(9987);
        api.setNickname("RavedMC-System");
        afkmover.start();
        supportchannel.start();
        botmessage.loadevents();
        supportnotify.loadevents();
        System.out.println("  _______         ____     ____                                  ____            _   ");
        System.out.println(" |__   __|       |___ \\   / __ \\                                |  _ \\          | |  ");
        System.out.println("    | |     ___    __) | | |  | |  _   _    ___   _ __   _   _  | |_) |   ___   | |_ ");
        System.out.println("    | |    / __|  |__ <  | |  | | | | | |  / _ \\ | '__| | | | | |  _ <   / _ \\  | __|");
        System.out.println("    | |    \\__ \\  ___) | | |__| | | |_| | |  __/ | |    | |_| | | |_) | | (_) | | |_ ");
        System.out.println("    |_|    |___/ |____/   \\___\\_\\  \\__,_|  \\___| |_|     \\__, | |____/   \\___/   \\__");
        System.out.println("                                                          __/ |                      ");
        System.out.println("                                                         |___/                       ");
    }
}
Meine AFK mover Class:
Java:
package de.velortex.ts3querybot.events;

import java.util.Timer;
import java.util.TimerTask;

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.Client;

import de.velortex.ts3querybot.main.load;

public class afkmover {
 
    public static final TS3Config config = new TS3Config();
    public static final TS3Query query =new TS3Query(config);
    public static final TS3Api api = query.getApi();
 
    public static void start() {
        Timer timer = new Timer();
        timer.schedule(new TimerTask() {
         
            @Override
            public void run() {
                for(Client c : load.api.getClients()) {
                    if(c.getIdleTime() > 15*60*1000) {
                        if(c.getChannelId() !=59 && c.getChannelId() !=28) {
                            if(!(c.isInServerGroup(49))) {
                                api.moveClient(c.getId(), 59);
                                api.sendPrivateMessage(c.getId(), "Du wurdest in den AFK-Channel gemoved, da du länger als 15 minuten AFK warst");
                            }else {
                                api.moveClient(c.getId(), 28);
                                api.sendPrivateMessage(c.getId(), "Du wurdest in den AFK-Channel gemoved, da du länger als 15 minuten AFK warst");
                            }
                        }
                    }
                }
            }
        }, 1000, 5*1000);
    }
}
Meine supportchannel Class:

Java:
package de.velortex.ts3querybot.events;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Timer;
import java.util.TimerTask;

import com.github.theholywaffle.teamspeak3.TS3Api;
import com.github.theholywaffle.teamspeak3.TS3Config;
import com.github.theholywaffle.teamspeak3.TS3Query;
import com.github.theholywaffle.teamspeak3.api.ChannelProperty;
import com.github.theholywaffle.teamspeak3.api.wrapper.Client;

import de.velortex.ts3querybot.main.load;

public class supportchannel {
 
    public static final TS3Config config = new TS3Config();
    public static final TS3Query query =new TS3Query(config);
    public static final TS3Api api = query.getApi();
 
    public static ArrayList<Integer> onlinesups = new ArrayList<>();
 
    public static void start() {
        Timer timer = new Timer();
        timer.schedule(new TimerTask() {
         
            @Override
            public void run() {
                onlinesups.clear();
                for(Client c : api.getClients()) {
                    if(c.isInServerGroup(26)) {
                        onlinesups.add(c.getId());
                    }
                }
                Map<ChannelProperty, String> property = new HashMap<ChannelProperty, String>();
                if(onlinesups.size() == 0) {
                    if(!api.getChannelInfo(32).getName().contains("╔-● Support | Warteraum [CLOSED]")) {
                        property.put(ChannelProperty.CHANNEL_NAME, "╔-● Support | Warteraum [CLOSED]");
                        property.put(ChannelProperty.CHANNEL_MAXCLIENTS, "0");
                        property.put(ChannelProperty.CHANNEL_FLAG_MAXCLIENTS_UNLIMITED, "0");
                        load.api.editChannel(32, property);
                        property.clear();
                    }
                }else {
                    if(!api.getChannelInfo(32).getName().contains("╔-● Support | Warteraum ["+onlinesups.size()+"]")) {
                        property.put(ChannelProperty.CHANNEL_NAME, "╔-● Support | Warteraum ["+onlinesups.size()+"]");
                        property.put(ChannelProperty.CHANNEL_MAXCLIENTS, "1");
                        property.put(ChannelProperty.CHANNEL_FLAG_MAXCLIENTS_UNLIMITED, "1");
                        load.api.editChannel(32, property);
                        property.clear();
                    }
                }
            }
        }, 1000, 5*1000);
    }
}
PS: Ich hoffe irgendwer kann mir helfen danke im Vorraus
 
Zuletzt bearbeitet von einem Moderator:
A

Anzeige


Vielleicht hilft dir dieser Kurs hier weiter: (hier klicken)
Könnte es am fehlenden query.connect(); liegen? In der main Methode machst du das, in den anderen Klassen wo du jeweils neue query-Objekte hast aber nicht. Ich kenne mich aber nicht wirklich mit dieser API aus. Hab nur mal kurz aus Langeweile den Code auf GitHub angeschaut.
 
Passende Stellenanzeigen aus deiner Region:

Neue Themen

Oben