I'm trying to call a class that starts a websocket in another file when the Minecraft plugin runs, but I'm getting an error. What's the problem? please help me.. (use maven)
package test.minecraft;
import org.bukkit.plugin.java.JavaPlugin;
public final class test_Minecraft extends JavaPlugin {
@Override
public void onEnable() {
// Plugin startup logic
this.saveDefaultConfig();
chat backchat = new chat();
backchat.st();
}
@Override
public void onDisable() {
// Plugin shutdown logic
}
}
package test.minecraft;
import org.java_websocket.client.WebSocketClient;
import org.java_websocket.handshake.ServerHandshake;
import java.net.URI;
import java.net.URISyntaxException;
public class chat {
private static WebSocketClient client;
public static void st(String chatId) {
connectWebSocket();
private static void connectWebSocket(S) {
try {
URI uri = new URI("wss://example.com");
client = new WebSocketClient(uri) {
@Override
public void onOpen(ServerHandshake serverHandshake) {
System.out.println("Connected to websocket");
}
@Override
public void onMessage(String s) {
JSONObject jsonObject = new JSONObject(s);
System.out.println(s);
}
@Override
public void onClose(int i, String s, boolean b) {
System.out.println("Connection closed");
}
@Override
public void onError(Exception e) {
e.printStackTrace();
}
};
client.connect();
} catch (URISyntaxException e) {
e.printStackTrace();
}
}
}
I'm trying to call a class that starts a websocket in another file when the Minecraft plugin runs.