diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index bd384d6..7d29752 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,8 +4,7 @@
-
-
+
@@ -119,12 +118,21 @@
1695656657760
-
+
+
+ 1695657371321
+
+
+
+ 1695657371321
+
+
-
+
+
\ No newline at end of file
diff --git a/src/main/java/cf/sobrooms/Main.java b/src/main/java/cf/sobrooms/Main.java
index 7df29c2..a3113c9 100644
--- a/src/main/java/cf/sobrooms/Main.java
+++ b/src/main/java/cf/sobrooms/Main.java
@@ -55,7 +55,7 @@ public class Main extends JavaPlugin {
//FileWriter pubMessageWebhookConfigWriter = new FileWriter(pubMessageWebhookConfig);
//notifyWebhookConfigWriter.write("{\"url_notify\": \"default-ns\"}");
FileWriter linkConfigWriter = new FileWriter(webhookConfig);
- linkConfigWriter.write("{\n \"url_publicmsg\": \"default-ns\", \n \"url_notify\": \"default-ns\"\n}");
+ linkConfigWriter.write("{\"url_publicmsg\": \"default-ns\",\"url_notify\": \"default-ns\"}");
linkConfigWriter.close();
//notifyWebhookConfigWriter.close();
} else {
@@ -93,6 +93,10 @@ public class Main extends JavaPlugin {
public static boolean validateWebhook_Pub() {
try {
+ if (getPublicMessageWebhook().equals("default-ns") || !getPublicMessageWebhook().contains("https://")) {
+ System.out.println("There was no webhook set for the public messages function. The send-message command cannot be used until you do.");
+ return true;
+ }
URL url = new URL(getPublicMessageWebhook());
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET");
@@ -100,11 +104,12 @@ public class Main extends JavaPlugin {
if (responseCode == HttpURLConnection.HTTP_OK) {
return true;
} else {
- System.out.println("Invalid webhook URL provided. Please provide the correct webhook and check for any typos.");
+ System.out.println("Invalid webhook URL provided for your public messages. Please provide the correct webhook and check for any typos.");
return false;
}
} catch (Exception e) {
- System.out.println("Invalid webhook URL provided. Please provide the correct webhook and check for any typos. (Caught exception)");
+ System.out.println("Invalid webhook URL provide for your public messages. Please provide the correct webhook and check for any typos. (Caught exception)");
+ System.out.println("Exception: %s".formatted(e));
return false;
}
}
@@ -117,11 +122,12 @@ public class Main extends JavaPlugin {
if (responseCode == HttpURLConnection.HTTP_OK) {
return true;
} else {
- System.out.println("Invalid webhook URL provided. Please provide the correct webhook and check for any typos.");
+ System.out.println("Invalid webhook URL provided for the event logs. Please provide the correct webhook and check for any typos.");
return false;
}
} catch (Exception e) {
- System.out.println("Invalid webhook URL provided. Please provide the correct webhook and check for any typos. (Caught exception)");
+ System.out.println("Invalid webhook URL provided for the event logs. Please provide the correct webhook and check for any typos. (Caught exception)");
+ System.out.println("Exception: %s".formatted(e));
return false;
}
}
@@ -133,18 +139,12 @@ public class Main extends JavaPlugin {
String lineMsg = MsgParse.getAsJsonObject().get("url_publicmsg").getAsString();
brfmsg.close();
- if (lineMsg.equals("default-ns")) {
- System.out.printf("Please set the public message webhook URL in %s and restart the server", webhookConfig.getAbsolutePath());
- webhooksAreValidUrls = false;
- return lineMsg;
- } else if (lineMsg.startsWith("https://") || lineMsg.startsWith("http://")) {
+ if (lineMsg.startsWith("https://") || lineMsg.startsWith("http://")) {
webhooksAreValidUrls = true;
return lineMsg;
- } else {
- System.out.printf("Please set the public message webhook URL in %s and restart the server", webhookConfig.getAbsolutePath());
- webhooksAreValidUrls = false;
- return lineMsg;
}
+
+ return "default-ns";
} catch (IOException e) {
throw new RuntimeException(e);
}
diff --git a/src/main/java/cf/sobrooms/ServerUtils.java b/src/main/java/cf/sobrooms/ServerUtils.java
index 81c7bcf..a0f0fbf 100644
--- a/src/main/java/cf/sobrooms/ServerUtils.java
+++ b/src/main/java/cf/sobrooms/ServerUtils.java
@@ -19,7 +19,7 @@ public class ServerUtils {
Socket s = new Socket();
s.connect(new InetSocketAddress(serverAddress, Integer.parseInt(serverPort.toString())), 15);
s.close();
- System.out.println("Server is online. Sending message to webhook_notify... (Pinged " + serverAddress + ":" + server.getPort() + ")");
+ 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...");