From fe32358fd0edbd30916ff03d4e9096d5332269ef Mon Sep 17 00:00:00 2001 From: Gegy Date: Fri, 3 Nov 2023 15:51:41 +0100 Subject: [PATCH] Don't send chat message if it is empty --- .../java/org/jedi/JustEnoughDiscordIntegrationMod.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/jedi/JustEnoughDiscordIntegrationMod.java b/src/main/java/org/jedi/JustEnoughDiscordIntegrationMod.java index a2e07f6..bfbccb2 100644 --- a/src/main/java/org/jedi/JustEnoughDiscordIntegrationMod.java +++ b/src/main/java/org/jedi/JustEnoughDiscordIntegrationMod.java @@ -64,7 +64,7 @@ public class JustEnoughDiscordIntegrationMod { private static ForgeConfigSpec.ConfigValue serverStartedEntry; private static ForgeConfigSpec.ConfigValue serverShuttingDownEntry; private static ForgeConfigSpec.ConfigValue replyingToEntry; - private static ForgeConfigSpec.ConfigValue sendDeathMessages; + private static ForgeConfigSpec.BooleanValue sendDeathMessages; private static ForgeConfigSpec.ConfigValue botTokenEntry; private static ForgeConfigSpec.ConfigValue> webhookEntries; @@ -225,10 +225,12 @@ public void onServerChatEvent(ServerChatEvent event) { try { final String username = event.getUsername(); final String message = event.getMessage().getString(); - final String uuid = event.getPlayer().getStringUUID(); - final String cacheBust = CACHE_BUSTS.getOrDefault(event.getPlayer().getUUID(), username); + if (!message.isBlank()) { + final String uuid = event.getPlayer().getStringUUID(); + final String cacheBust = CACHE_BUSTS.getOrDefault(event.getPlayer().getUUID(), username); - sendMessage(message, username, new URL(String.format(VISAGE_URL, uuid, cacheBust))); + sendMessage(message, username, new URL(String.format(VISAGE_URL, uuid, cacheBust))); + } } catch (MalformedURLException e) { e.printStackTrace(); }