fixed it not being able to get the webhook
This commit is contained in:
generated
+12
-4
@@ -4,8 +4,7 @@
|
|||||||
<option name="autoReloadType" value="SELECTIVE" />
|
<option name="autoReloadType" value="SELECTIVE" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="ce97b9f5-6785-4670-b350-12f90ab9ea27" name="Changes" comment="fix stuff and add more functionality (definitely) (hi again)">
|
<list default="true" id="ce97b9f5-6785-4670-b350-12f90ab9ea27" name="Changes" comment="wrong version number">
|
||||||
<change beforePath="$PROJECT_DIR$/.gitignore" beforeDir="false" afterPath="$PROJECT_DIR$/.gitignore" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||||
</list>
|
</list>
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
@@ -119,12 +118,21 @@
|
|||||||
<option name="project" value="LOCAL" />
|
<option name="project" value="LOCAL" />
|
||||||
<updated>1695656657760</updated>
|
<updated>1695656657760</updated>
|
||||||
</task>
|
</task>
|
||||||
<option name="localTasksCounter" value="3" />
|
<task id="LOCAL-00003" summary="wrong version number">
|
||||||
|
<option name="closed" value="true" />
|
||||||
|
<created>1695657371321</created>
|
||||||
|
<option name="number" value="00003" />
|
||||||
|
<option name="presentableId" value="LOCAL-00003" />
|
||||||
|
<option name="project" value="LOCAL" />
|
||||||
|
<updated>1695657371321</updated>
|
||||||
|
</task>
|
||||||
|
<option name="localTasksCounter" value="4" />
|
||||||
<servers />
|
<servers />
|
||||||
</component>
|
</component>
|
||||||
<component name="VcsManagerConfiguration">
|
<component name="VcsManagerConfiguration">
|
||||||
<MESSAGE value="hmmm" />
|
<MESSAGE value="hmmm" />
|
||||||
<MESSAGE value="fix stuff and add more functionality (definitely) (hi again)" />
|
<MESSAGE value="fix stuff and add more functionality (definitely) (hi again)" />
|
||||||
<option name="LAST_COMMIT_MESSAGE" value="fix stuff and add more functionality (definitely) (hi again)" />
|
<MESSAGE value="wrong version number" />
|
||||||
|
<option name="LAST_COMMIT_MESSAGE" value="wrong version number" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
@@ -55,7 +55,7 @@ public class Main extends JavaPlugin {
|
|||||||
//FileWriter pubMessageWebhookConfigWriter = new FileWriter(pubMessageWebhookConfig);
|
//FileWriter pubMessageWebhookConfigWriter = new FileWriter(pubMessageWebhookConfig);
|
||||||
//notifyWebhookConfigWriter.write("{\"url_notify\": \"default-ns\"}");
|
//notifyWebhookConfigWriter.write("{\"url_notify\": \"default-ns\"}");
|
||||||
FileWriter linkConfigWriter = new FileWriter(webhookConfig);
|
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();
|
linkConfigWriter.close();
|
||||||
//notifyWebhookConfigWriter.close();
|
//notifyWebhookConfigWriter.close();
|
||||||
} else {
|
} else {
|
||||||
@@ -93,6 +93,10 @@ public class Main extends JavaPlugin {
|
|||||||
|
|
||||||
public static boolean validateWebhook_Pub() {
|
public static boolean validateWebhook_Pub() {
|
||||||
try {
|
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());
|
URL url = new URL(getPublicMessageWebhook());
|
||||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||||
connection.setRequestMethod("GET");
|
connection.setRequestMethod("GET");
|
||||||
@@ -100,11 +104,12 @@ public class Main extends JavaPlugin {
|
|||||||
if (responseCode == HttpURLConnection.HTTP_OK) {
|
if (responseCode == HttpURLConnection.HTTP_OK) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} 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;
|
return false;
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} 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;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -117,11 +122,12 @@ public class Main extends JavaPlugin {
|
|||||||
if (responseCode == HttpURLConnection.HTTP_OK) {
|
if (responseCode == HttpURLConnection.HTTP_OK) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} 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;
|
return false;
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} 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;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -133,18 +139,12 @@ public class Main extends JavaPlugin {
|
|||||||
String lineMsg = MsgParse.getAsJsonObject().get("url_publicmsg").getAsString();
|
String lineMsg = MsgParse.getAsJsonObject().get("url_publicmsg").getAsString();
|
||||||
|
|
||||||
brfmsg.close();
|
brfmsg.close();
|
||||||
if (lineMsg.equals("default-ns")) {
|
if (lineMsg.startsWith("https://") || lineMsg.startsWith("http://")) {
|
||||||
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://")) {
|
|
||||||
webhooksAreValidUrls = true;
|
webhooksAreValidUrls = true;
|
||||||
return lineMsg;
|
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) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ public class ServerUtils {
|
|||||||
Socket s = new Socket();
|
Socket s = new Socket();
|
||||||
s.connect(new InetSocketAddress(serverAddress, Integer.parseInt(serverPort.toString())), 15);
|
s.connect(new InetSocketAddress(serverAddress, Integer.parseInt(serverPort.toString())), 15);
|
||||||
s.close();
|
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;
|
return true;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
System.out.println("Server is inactive. Pinging fallback address...");
|
System.out.println("Server is inactive. Pinging fallback address...");
|
||||||
|
|||||||
Reference in New Issue
Block a user