diff --git a/src/main/java/org/itqop/chatit/ChatIT.java b/src/main/java/org/itqop/chatit/ChatIT.java index 0475764..d4035b1 100644 --- a/src/main/java/org/itqop/chatit/ChatIT.java +++ b/src/main/java/org/itqop/chatit/ChatIT.java @@ -1,6 +1,5 @@ package org.itqop.chatit; -import com.mojang.logging.LogUtils; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.ModLoadingContext; import net.minecraftforge.event.server.ServerStartingEvent; @@ -12,6 +11,7 @@ import org.itqop.chatit.handlers.ChatEventHandler; import org.itqop.chatit.utils.Config; import org.itqop.chatit.utils.PlayerConfigManager; import org.slf4j.Logger; +import com.mojang.logging.LogUtils; @Mod(ChatIT.MODID) public class ChatIT { diff --git a/src/main/java/org/itqop/chatit/handlers/ChatEventHandler.java b/src/main/java/org/itqop/chatit/handlers/ChatEventHandler.java index a0db127..c5783ba 100644 --- a/src/main/java/org/itqop/chatit/handlers/ChatEventHandler.java +++ b/src/main/java/org/itqop/chatit/handlers/ChatEventHandler.java @@ -11,15 +11,20 @@ import net.minecraft.ChatFormatting; import org.itqop.chatit.utils.Config; import org.itqop.chatit.utils.PlayerConfigManager; import org.itqop.chatit.utils.ProfanityChecker; +import org.slf4j.Logger; +import com.mojang.logging.LogUtils; import java.util.concurrent.CompletableFuture; @Mod.EventBusSubscriber public class ChatEventHandler { + private static final Logger LOGGER = LogUtils.getLogger(); + @SubscribeEvent public static void onServerChat(ServerChatEvent event) { ServerPlayer sender = event.getPlayer(); + MinecraftServer server = sender.getServer(); String originalMessage = event.getMessage().getString(); @@ -57,7 +62,7 @@ public class ChatEventHandler { }); } }).exceptionally(ex -> { - ex.printStackTrace(); + LOGGER.error(ex.toString()); if (server != null) { server.execute(() -> { MutableComponent errorComponent = createErrorMessage(sender, message); diff --git a/src/main/java/org/itqop/chatit/utils/PlayerConfigManager.java b/src/main/java/org/itqop/chatit/utils/PlayerConfigManager.java index 506aefa..c8f3917 100644 --- a/src/main/java/org/itqop/chatit/utils/PlayerConfigManager.java +++ b/src/main/java/org/itqop/chatit/utils/PlayerConfigManager.java @@ -12,11 +12,15 @@ import java.util.HashMap; import java.util.Map; import java.util.UUID; +import org.slf4j.Logger; +import com.mojang.logging.LogUtils; + public class PlayerConfigManager { private static final Gson GSON = new Gson(); private static final File CONFIG_FILE = new File("config/chatit_player_settings.json"); private static final Type CONFIG_TYPE = new TypeToken>() {}.getType(); + private static final Logger LOGGER = LogUtils.getLogger(); private static Map playerSettings = new HashMap<>(); @@ -25,7 +29,7 @@ public class PlayerConfigManager { try (FileReader reader = new FileReader(CONFIG_FILE)) { playerSettings = GSON.fromJson(reader, CONFIG_TYPE); } catch (Exception e) { - e.printStackTrace(); + LOGGER.error(e.toString()); } } } @@ -34,7 +38,7 @@ public class PlayerConfigManager { try (FileWriter writer = new FileWriter(CONFIG_FILE)) { GSON.toJson(playerSettings, writer); } catch (Exception e) { - e.printStackTrace(); + LOGGER.error(e.toString()); } } diff --git a/src/main/java/org/itqop/chatit/utils/ProfanityChecker.java b/src/main/java/org/itqop/chatit/utils/ProfanityChecker.java index bf1a8de..f11f4b4 100644 --- a/src/main/java/org/itqop/chatit/utils/ProfanityChecker.java +++ b/src/main/java/org/itqop/chatit/utils/ProfanityChecker.java @@ -8,12 +8,16 @@ import java.nio.charset.StandardCharsets; import java.util.concurrent.CompletableFuture; import java.util.regex.Pattern; +import org.slf4j.Logger; +import com.mojang.logging.LogUtils; + import com.google.gson.Gson; public class ProfanityChecker { private static final Gson GSON = new Gson(); private static final HttpClient CLIENT = HttpClient.newHttpClient(); + private static final Logger LOGGER = LogUtils.getLogger(); private static Pattern profanityPattern = null; @@ -49,7 +53,7 @@ public class ProfanityChecker { return Double.parseDouble(responseBody); } catch (Exception e) { - e.printStackTrace(); + LOGGER.error(e.toString()); if (Config.useRegex) { if (containsProfanity(message)) { return 1.0;