Skip to content

Commit

Permalink
Merge pull request #226 from JackGlobetrotter/master
Browse files Browse the repository at this point in the history
Correct path/filename for server.jar for Fabric
  • Loading branch information
gekigek99 committed Jul 25, 2024
2 parents df8a224 + 86e8669 commit 0595ec9
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions lib/config/config-utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,13 @@ func (c *Configuration) loadIcon() *errco.MshLog {
// In case of error "", -1, *errco.MshLog are returned.
//
// (checkout version.json info: https://minecraft.fandom.com/wiki/Version.json)
func (c *Configuration) getVersionInfo() (string, int, *errco.MshLog) {
reader, err := zip.OpenReader(filepath.Join(c.Server.Folder, c.Server.FileName))
func (c *Configuration) getVersionInfo(altServerName ...string) (string, int, *errco.MshLog) {
var serverFileName = c.Server.FileName
if len(altServerName) > 0 {
serverFileName = altServerName[0]
}

reader, err := zip.OpenReader(filepath.Join(c.Server.Folder, serverFileName))
if err != nil {
return "", -1, errco.NewLog(errco.TYPE_WAR, errco.LVL_3, errco.ERROR_VERSION_LOAD, err.Error())
}
Expand Down Expand Up @@ -198,6 +203,10 @@ func (c *Configuration) getVersionInfo() (string, int, *errco.MshLog) {
return utility.FirstNon("", info.Version1, info.Version2), info.Protocol, nil
}

if c.Server.FileName != "server.jar" { //check if it matches the deafult name, if not
return c.getVersionInfo(filepath.Join("versions", c.Server.Version, "server-"+c.Server.Version+".jar")) //fallback to default naming scheme
}

return "", -1, errco.NewLog(errco.TYPE_ERR, errco.LVL_3, errco.ERROR_VERSION_LOAD, "minecraft server version and protocol could not be extracted from version.json")
}

Expand Down

0 comments on commit 0595ec9

Please sign in to comment.