fix webhook validation and change readme
This commit is contained in:
@@ -32,7 +32,6 @@ public class Main extends JavaPlugin {
|
||||
public static void main(String... args) {
|
||||
System.out.printf("Initializing using server address: %s...%n", ServerUtils.address);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
String loggingDir = "./NoS";
|
||||
@@ -73,7 +72,8 @@ public class Main extends JavaPlugin {
|
||||
} catch (NullPointerException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
webhooksAreValidUrls = validateWebhook_Ntfy();
|
||||
webhooksAreValidUrls = validateWebhook_Pub();
|
||||
// register events
|
||||
if (getLoggingConfig().equals("true") && webhooksAreValidUrls)
|
||||
registerEvents();
|
||||
@@ -87,6 +87,19 @@ public class Main extends JavaPlugin {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static boolean validateWebhook_Pub() {
|
||||
if (getPublicMessageWebhook().startsWith("https://") || getPublicMessageWebhook().startsWith("http://"))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
public static boolean validateWebhook_Ntfy() {
|
||||
if (getNotifyWebhook().startsWith("https://") || getNotifyWebhook().startsWith("http://"))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
public static String getPublicMessageWebhook() {
|
||||
try {
|
||||
BufferedReader brfmsg = new BufferedReader(new FileReader(pubMessageWebhookConfig));
|
||||
@@ -101,6 +114,7 @@ public class Main extends JavaPlugin {
|
||||
webhooksAreValidUrls = false;
|
||||
return lineMsg;
|
||||
} else if (lineMsg.startsWith("https://") || lineMsg.startsWith("http://")) {
|
||||
webhooksAreValidUrls = true;
|
||||
return lineMsg;
|
||||
} else {
|
||||
System.out.printf("Please set the webhook URL in %s and restart the server", pubMessageWebhookConfig.getAbsolutePath());
|
||||
@@ -125,6 +139,7 @@ public class Main extends JavaPlugin {
|
||||
webhooksAreValidUrls = false;
|
||||
return lineNtfy;
|
||||
} else if (lineNtfy.startsWith("https://") || lineNtfy.startsWith("http://")) {
|
||||
webhooksAreValidUrls = true;
|
||||
return lineNtfy;
|
||||
} else {
|
||||
System.out.printf("Please set the webhook URL in %s and restart the server", notifyWebhookConfig.getAbsolutePath());
|
||||
|
||||
Reference in New Issue
Block a user