1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2025-02-22 14:00:09 +00:00

Catch ModdedConfig.getFilePath errors

This occurs when syncing the server config to the client. Ideally we'd
not hit this code path in the first place, but unfortunately there's no
way to tell where the config file comes from.

Fixes #2065
This commit is contained in:
Jonathan Coates 2025-01-17 17:14:06 +00:00
parent 4710ee5bcc
commit d697c47b80
No known key found for this signature in database
GPG Key ID: B9E431FF07C98D06

View File

@ -57,6 +57,7 @@ import net.neoforged.neoforge.registries.NewRegistryEvent;
import net.neoforged.neoforge.registries.RegistryBuilder;
import javax.annotation.Nullable;
import java.nio.file.Path;
@Mod(ComputerCraftAPI.MOD_ID)
@EventBusSubscriber(modid = ComputerCraftAPI.MOD_ID, bus = EventBusSubscriber.Bus.MOD)
@ -175,7 +176,13 @@ public final class ComputerCraft {
private static void syncConfig(ModConfig config) {
if (!config.getModId().equals(ComputerCraftAPI.MOD_ID)) return;
var path = config.getFullPath();
Path path;
try {
path = config.getFullPath();
} catch (IllegalStateException ignored) {
path = null; // getFullPath throws if loading a non-valid file.
}
if (config.getType() == ModConfig.Type.SERVER && ((ForgeConfigFile) ConfigSpec.serverSpec).spec().isLoaded()) {
ConfigSpec.syncServer(path);
} else if (config.getType() == ModConfig.Type.CLIENT) {