Skip to content

Commit 89c46fc

Browse files
committed
fix: update Discord notification configuration keys for consistency and improve error handling
1 parent b9f196b commit 89c46fc

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/main/java/net/onelitefeather/antiredstoneclockremastered/service/impl/DiscordNotificationService.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
import org.jetbrains.annotations.NotNull;
2222
import org.jetbrains.annotations.Nullable;
2323

24+
import java.net.URI;
25+
import java.net.URISyntaxException;
2426
import java.net.URL;
2527
import java.util.HashMap;
2628
import java.util.List;
@@ -42,10 +44,10 @@ public DiscordNotificationService(@NotNull AntiRedstoneClockRemastered plugin,
4244

4345
private WebhookClient createWebHook() {
4446
if (this.plugin.getConfig().getString("notification.discord.webhook", "").isEmpty()) return null;
45-
if (!this.plugin.getConfig().getStringList("notification.discord.enabled").contains("discord")) return null;
47+
if (!this.plugin.getConfig().getStringList("notification.enabled").contains("discord")) return null;
4648
try {
47-
var url = new URL(this.plugin.getConfig().getString("notification.discord.webhook", ""));
48-
} catch (Exception e) {
49+
URI.create(this.plugin.getConfig().getString("notification.discord.webhook", ""));
50+
} catch (IllegalArgumentException e) {
4951
LOGGER.error("Failed to create webhook client. Please check your webhook URL in the config.yml");
5052
LOGGER.error("Disabling plugin...");
5153
Bukkit.getPluginManager().disablePlugin(this.plugin);

0 commit comments

Comments
 (0)