1.2.0: Remove unnecessary events, use yml as a config

This commit is contained in:
2025-10-15 21:12:07 +08:00
parent 6b463cf5b3
commit eabb5a69c1
30 changed files with 326 additions and 659 deletions
+40
View File
@@ -0,0 +1,40 @@
package moe.sob;
import org.bukkit.Bukkit;
import org.bukkit.Server;
import java.net.InetSocketAddress;
import java.net.Socket;
public class ServerUtils {
public static int port = 25565;
public static String address_fallback = "localhost";
public static String webhook_notify = Main.getNotifyWebhook();
public static String webhook_messages = Main.getPublicMessageWebhook();
public static String address = Utils.getServerHostPublicIP();
public static boolean serverIsUp(String serverAddress, Integer serverPort) {
try {
Server server = Bukkit.getServer();
Socket s = new Socket();
s.connect(new InetSocketAddress(serverAddress, Integer.parseInt(serverPort.toString())), 15);
s.close();
System.out.println("Server is online. Test notifying by sending a message to your webhook... (Pinged " + serverAddress + ":" + server.getPort() + ")");
return true;
} catch (Exception e) {
System.out.println("Server is inactive. Pinging fallback address...");
try {
Server server = Bukkit.getServer();
Socket s = new Socket();
s.connect(new InetSocketAddress(address_fallback, Integer.parseInt(serverPort.toString())), 15);
s.close();
System.out.println("Server is online. Sending message to webhook_notify... (Pinged " + Utils.getServerHostPublicIP() + ":" + server.getPort() + ")");
return true;
} catch (Exception err) {
System.out.println("Fallback address is inactive. No longer pinging...");
}
return false;
}
}
}