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:
parent
4710ee5bcc
commit
d697c47b80
@ -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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user