ErdbeerbaerLP / DiscordIntegration-Core

Common module for the Discord Integration mod
https://modrinth.com/plugin/dcintegration
4 stars 21 forks source link

[BUG] If the config file exists, but the messages file and parent dir doesn't exist, mod crashes on startup #107

Open Ricket opened 1 year ago

Ricket commented 1 year ago

What happened?

Mod failed to load with exception:

./latest.log:[14Nov2022 05:38:06.493] [modloading-worker-0/INFO] [STDERR/]: [de.erdbeerbaerlp.dcintegration.forge.DiscordIntegration:<init>:87]: Config loading failed
./latest.log:[14Nov2022 05:38:06.493] [modloading-worker-0/INFO] [STDERR/]: [de.erdbeerbaerlp.dcintegration.forge.DiscordIntegration:<init>:88]: java.io.IOException: No such file or directory
./latest.log:[14Nov2022 05:38:06.494] [modloading-worker-0/INFO] [STDERR/]: [de.erdbeerbaerlp.dcintegration.forge.DiscordIntegration:<init>:88]:       at java.io.UnixFileSystem.createFileExclusively(Native Method)
./latest.log:[14Nov2022 05:38:06.494] [modloading-worker-0/INFO] [STDERR/]: [de.erdbeerbaerlp.dcintegration.forge.DiscordIntegration:<init>:88]:       at java.io.File.createNewFile(File.java:1023)
./latest.log:[14Nov2022 05:38:06.494] [modloading-worker-0/INFO] [STDERR/]: [de.erdbeerbaerlp.dcintegration.forge.DiscordIntegration:<init>:88]:       at de.erdbeerbaerlp.dcintegration.common.Discord.loadConfigs(Discord.java:525)
./latest.log:[14Nov2022 05:38:06.494] [modloading-worker-0/INFO] [STDERR/]: [de.erdbeerbaerlp.dcintegration.forge.DiscordIntegration:<init>:88]:       at de.erdbeerbaerlp.dcintegration.forge.DiscordIntegration.<init>(DiscordIntegration.java:75)
./latest.log:[14Nov2022 05:38:06.494] [modloading-worker-0/INFO] [STDERR/]: [de.erdbeerbaerlp.dcintegration.forge.DiscordIntegration:<init>:88]:       at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
./latest.log:[14Nov2022 05:38:06.494] [modloading-worker-0/INFO] [STDERR/]: [de.erdbeerbaerlp.dcintegration.forge.DiscordIntegration:<init>:88]:       at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
./latest.log:[14Nov2022 05:38:06.494] [modloading-worker-0/INFO] [STDERR/]: [de.erdbeerbaerlp.dcintegration.forge.DiscordIntegration:<init>:88]:       at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
./latest.log:[14Nov2022 05:38:06.494] [modloading-worker-0/INFO] [STDERR/]: [de.erdbeerbaerlp.dcintegration.forge.DiscordIntegration:<init>:88]:       at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
./latest.log:[14Nov2022 05:38:06.494] [modloading-worker-0/INFO] [STDERR/]: [de.erdbeerbaerlp.dcintegration.forge.DiscordIntegration:<init>:88]:       at java.lang.Class.newInstance(Class.java:442)
./latest.log:[14Nov2022 05:38:06.495] [modloading-worker-0/INFO] [STDERR/]: [de.erdbeerbaerlp.dcintegration.forge.DiscordIntegration:<init>:88]:       at net.minecraftforge.fml.javafmlmod.FMLModContainer.constructMod(FMLModContainer.java:67)
./latest.log:[14Nov2022 05:38:06.495] [modloading-worker-0/INFO] [STDERR/]: [de.erdbeerbaerlp.dcintegration.forge.DiscordIntegration:<init>:88]:       at net.minecraftforge.fml.ModContainer.lambda$buildTransitionHandler$4(ModContainer.java:106)
./latest.log:[14Nov2022 05:38:06.495] [modloading-worker-0/INFO] [STDERR/]: [de.erdbeerbaerlp.dcintegration.forge.DiscordIntegration:<init>:88]:       at java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1640)
./latest.log:[14Nov2022 05:38:06.495] [modloading-worker-0/INFO] [STDERR/]: [de.erdbeerbaerlp.dcintegration.forge.DiscordIntegration:<init>:88]:       at java.util.concurrent.CompletableFuture$AsyncRun.exec(CompletableFuture.java:1632)
./latest.log:[14Nov2022 05:38:06.495] [modloading-worker-0/INFO] [STDERR/]: [de.erdbeerbaerlp.dcintegration.forge.DiscordIntegration:<init>:88]:       at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
./latest.log:[14Nov2022 05:38:06.495] [modloading-worker-0/INFO] [STDERR/]: [de.erdbeerbaerlp.dcintegration.forge.DiscordIntegration:<init>:88]:       at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
./latest.log:[14Nov2022 05:38:06.501] [modloading-worker-0/INFO] [STDERR/]: [de.erdbeerbaerlp.dcintegration.forge.DiscordIntegration:<init>:88]:       at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
./latest.log:[14Nov2022 05:38:06.501] [modloading-worker-0/INFO] [STDERR/]: [de.erdbeerbaerlp.dcintegration.forge.DiscordIntegration:<init>:88]:       at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:175)

What should happen?

I have a Dockerfile that overlays customizations on top of modpack after install script, and I don't care to change the messages toml, I just care about the main config file. So I would like to only copy the config file in, and the mod can create the default messages file. But this bug means I need to actually copy the messages file, too.

Steps to reproduce

Version

Minecraft 1.16.5 Mod/plugin: dcintegration-forge-2.4.7-1.16.jar

Platform Linux/Docker, Forge

Config file

REMOVE YOUR BOT TOKEN BEFORE UPLOADING!!!

Crash report if available (use https://hastebin.com)

Additional info

https://github.com/ErdbeerbaerLP/DiscordIntegration-Core/blob/1d2b9437168a145dca46d66a4e5d80743233f4e7/src/main/java/de/erdbeerbaerlp/dcintegration/common/Discord.java#L122

Since the parent folder doesn't exist, the file can't be created yet. Need to first call messagesFile.getParentFile().mkdirs();

https://stackoverflow.com/a/3090789/47493