Tom-The-Geek / server-restarter

@NucleoidMC inspired server wrapper (fabric mod)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Should create empty config if it doesn't exist

ChildoftheBeast opened this issue · comments

[13:29:08] [main/ERROR]: Failed to load config!
java.nio.file.NoSuchFileException: .\config\server_restarter.json
        at sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:79) ~[?:1.8.0_211]
        at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:97) ~[?:1.8.0_211]
        at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:102) ~[?:1.8.0_211]
        at sun.nio.fs.WindowsFileSystemProvider.newByteChannel(WindowsFileSystemProvider.java:230) ~[?:1.8.0_211]
        at java.nio.file.Files.newByteChannel(Files.java:361) ~[?:1.8.0_211]
        at java.nio.file.Files.newByteChannel(Files.java:407) ~[?:1.8.0_211]
        at java.nio.file.spi.FileSystemProvider.newInputStream(FileSystemProvider.java:384) ~[?:1.8.0_211]
        at java.nio.file.Files.newInputStream(Files.java:152) ~[?:1.8.0_211]
        at me.geek.tom.serverrestarter.Config.loadConfig(Config.java:92) ~[server-restarter-1.2.0.jar:?]
        at me.geek.tom.serverrestarter.Config.get(Config.java:86) ~[server-restarter-1.2.0.jar:?]
        at me.geek.tom.serverrestarter.Config.complete(Config.java:55) ~[server-restarter-1.2.0.jar:?]
        at me.geek.tom.serverrestarter.ServerRestarter.onInitialize(ServerRestarter.java:55) ~[server-restarter-1.2.0.jar:?]
        at net.fabricmc.loader.entrypoint.minecraft.hooks.EntrypointUtils.invoke0(EntrypointUtils.java:50) [fabric-server-launch.jar:?]
        at net.fabricmc.loader.entrypoint.minecraft.hooks.EntrypointUtils.invoke(EntrypointUtils.java:36) [fabric-server-launch.jar:?]
        at net.fabricmc.loader.entrypoint.minecraft.hooks.EntrypointServer.start(EntrypointServer.java:32) [fabric-server-launch.jar:?]
        at net.minecraft.server.Main.main(Main.java:92) [intermediary-server.jar:?]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_211]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_211]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_211]
        at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_211]
        at net.fabricmc.loader.game.MinecraftGameProvider.launch(MinecraftGameProvider.java:226) [fabric-server-launch.jar:?]
        at net.fabricmc.loader.launch.knot.Knot.init(Knot.java:139) [fabric-server-launch.jar:?]
        at net.fabricmc.loader.launch.knot.KnotServer.main(KnotServer.java:27) [fabric-server-launch.jar:?]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_211]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_211]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_211]
        at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_211]
        at net.fabricmc.loader.launch.server.FabricServerLauncher.launch(FabricServerLauncher.java:62) [fabric-server-launch.jar:?]
        at net.fabricmc.loader.launch.server.FabricServerLauncher.setup(FabricServerLauncher.java:106) [fabric-server-launch.jar:?]
        at net.fabricmc.loader.launch.server.FabricServerLauncher.main(FabricServerLauncher.java:50) [fabric-server-launch.jar:?]
[13:29:08] [main/WARN]: ============================================
[13:29:08] [main/WARN]: | server-restarter hasn't been configured! |
[13:29:08] [main/WARN]: ============================================

Whoops! Seems like I forgot to cover when the config directory doesn't exist, you should just be able to create it yourself before I release a fix

tried but it doesn't seem like you have an example config anywhere, and the JSON i found at:
https://github.com/Geek202/server-restarter/blob/main/src/main/resources/fabric.mod.json
i assume is meant for a mod description for fabric.

either way populating it with a file didnt seem to do anything other than get rid of the initial "not found error"

You don't need to create the file itself, just the config folder, then an empty config will be generated

[root server folder]/config/ right? that folder exists, none get created.

if you have discord, i can DM you my info , show you what i have setup, and see if this is a bug or just me not knowing anything about fabric.

just going to put it in here BeastChild#0666

commented

Yeah the config folder exists, but the file server_restarter.json not. Creating an empty file called server_restarter.json solved the issue. This file should be automatically created on first start-up of the mod. In your README is written to create a restart_webhook.txt file with the webhook, but looking at your code the webhook link should probably be saved in `server_restarter.json'. Is this a mistake in the README?

Yeah, the readme isn't up to date, and whoops, I confused this with another mod I made that does generate an empty config when it loads, sorry.
Here's an empty config that I'll add into the README in a second:

{
  "webhook_url": "",
  "scheduled_actions": []
}
commented

Would be cool if you could explain in the README how to use the scheduled_actions option in the config.

Would be cool if you could explain in the README how to use the scheduled_actions option in the config.

Done! Will leave this issue open to remind me to implement empty config generation