From 541f095075a4eb600decd62e0d660a73c6c51cb4 Mon Sep 17 00:00:00 2001 From: Minecon724 Date: Mon, 3 Feb 2025 10:42:12 +0100 Subject: [PATCH] fix(motd): handle FileAlreadyExistsException in directory creation Added a catch block for FileAlreadyExistsException to prevent unnecessary exceptions when the "motd sets" directory already exists. This ensures smoother execution and improves error handling during initialization. Signed-off-by: Minecon724 --- src/main/java/eu/m724/tweaks/module/motd/MotdModule.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/eu/m724/tweaks/module/motd/MotdModule.java b/src/main/java/eu/m724/tweaks/module/motd/MotdModule.java index 4962f02..63f1b6c 100644 --- a/src/main/java/eu/m724/tweaks/module/motd/MotdModule.java +++ b/src/main/java/eu/m724/tweaks/module/motd/MotdModule.java @@ -7,7 +7,8 @@ package eu.m724.tweaks.module.motd; import com.comphenix.protocol.PacketType; -import com.comphenix.protocol.events.*; +import com.comphenix.protocol.events.InternalStructure; +import com.comphenix.protocol.events.PacketContainer; import com.comphenix.protocol.reflect.StructureModifier; import com.google.gson.JsonElement; import com.google.gson.JsonParseException; @@ -22,6 +23,7 @@ import net.minecraft.network.chat.Component; import net.minecraft.network.protocol.status.ServerStatus; import java.io.IOException; +import java.nio.file.FileAlreadyExistsException; import java.nio.file.Files; import java.nio.file.Path; import java.util.Arrays; @@ -36,6 +38,8 @@ public class MotdModule extends TweaksModule { // create "motd sets" directory try { Files.createDirectories(motdSetPath); + } catch (FileAlreadyExistsException ignored) { + } catch (IOException e) { throw new RuntimeException(e); }