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 <git@m724.eu>
This commit is contained in:
Minecon724 2025-02-03 10:42:12 +01:00
parent 1fafc90e04
commit 541f095075
Signed by: Minecon724
GPG key ID: 3CCC4D267742C8E8

View file

@ -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);
}