Skip to content

Commit

Permalink
Catch ModdedConfig.getFilePath errors
Browse files Browse the repository at this point in the history
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
  • Loading branch information
SquidDev committed Jan 17, 2025
1 parent 4710ee5 commit d697c47
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
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)
Expand Down Expand Up @@ -175,7 +176,13 @@ public static void sync(ModConfigEvent.Reloading event) {
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) {
Expand Down

0 comments on commit d697c47

Please sign in to comment.