gekware / minecraft-server-hibernation

Autostart and stop minecraft-server when players join/leave
GNU General Public License v3.0
379 stars 37 forks source link

Correct path/filename for server.jar for Fabric #226

Closed JackGlobetrotter closed 1 month ago

JackGlobetrotter commented 1 year ago

Fabric uses fabric-server-launch.jar to start the server. This file does not contain the version.json. Instead the server.jar containing this file is located under versions/$VERSION/server-$VERSION.jar. This PR corrects the path if Fabric is detected to read the correct file.

A-wels commented 1 year ago

Do you know if this is only the case for fabric servers? I think it could be a good idea to try and read the version as before and, on error, try the other approach.

This may allow for a broader fix. What do you think @JackGlobetrotter @gekigek99

JackGlobetrotter commented 1 year ago

I am not so familliar with other servers than fabric... to do this in "error handeling" might be a better solution yes!

JackGlobetrotter commented 1 year ago

@A-wels made some changes to preserve default methode and failover to default name only if there is an error, what do you think?

JackGlobetrotter commented 11 months ago

@gekigek99 Thanks for your reply, had a quick look at the code (as it has been a while). What fabric is doing: splitting the server.jar into two parts: fabric-server-launcher.jar to start the server and versions\XXX\server-XXX.jar for some classes, version info etc.... What my modification tries to do, without disrupting the already implemented workflow is: letting the default version check run on the provided file (for fabric farbic-server-launcher.jar), this fails as there is no version.json file, then it fails over to versions\XXX\server-XXX.jar where XXX is the provided version in msh-config.json. The method calls itself (which is why the argument has the format altServerName ...string, as to allow default empty params or the new path for fabric as param), now the method has the correct path to work with and reads ou the version.json. This modification was done upon @A-wels request to let the method run as per default and failover to the fabric-specific path only on error. Sorry for the long reply. PS: latest commit provides the universal path of fabric, previsous commit only adresses lagacy fabric server...

gekigek99 commented 1 month ago

Thanks @JackGlobetrotter @A-wels for both the PR and explanation.

Hopefully you'll excuse me for late accept but I was focusing on university in the last months.

A-wels commented 1 month ago

Don't say sorry for that. I know first hand that university can suck all time away. I hope that everything went well for you :)

JackGlobetrotter commented 1 month ago

Can relate to that, please don't be :) Thanks for accepting the PR.