From 7b9a314a32904e25c4f196d6a9097d4dcbe20260 Mon Sep 17 00:00:00 2001 From: JackGlobetrotter Date: Thu, 4 May 2023 21:43:13 +0200 Subject: [PATCH 1/3] Correct path/filename for server.jar for Fabric --- lib/config/config-utils.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/config/config-utils.go b/lib/config/config-utils.go index 2e7732a..7784da9 100644 --- a/lib/config/config-utils.go +++ b/lib/config/config-utils.go @@ -166,7 +166,13 @@ func (c *Configuration) loadIcon() *errco.MshLog { // // (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)) + var serverFilename = c.Server.FileName + + if strings.Contains(c.Server.FileName, "fabric-server-launch.jar") { + serverFilename = filepath.Join("versions", c.Server.Version, "server-"+c.Server.Version+".jar") + } + + 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()) } From 05dcce26953d07617308f1e2bc9e1823cf5d238e Mon Sep 17 00:00:00 2001 From: JackGlobetrotter Date: Sat, 20 May 2023 12:47:13 +0200 Subject: [PATCH 2/3] GetVersion error handeling for non-default names --- lib/config/config-utils.go | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/config/config-utils.go b/lib/config/config-utils.go index 7784da9..acd5f8d 100644 --- a/lib/config/config-utils.go +++ b/lib/config/config-utils.go @@ -165,14 +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) { - var serverFilename = c.Server.FileName - - if strings.Contains(c.Server.FileName, "fabric-server-launch.jar") { - serverFilename = filepath.Join("versions", c.Server.Version, "server-"+c.Server.Version+".jar") +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)) + 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()) } @@ -204,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("server.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") } From 86e8669e0ffd5f55f858dbdd5548233d2e8b1531 Mon Sep 17 00:00:00 2001 From: JackGlobetrotter Date: Fri, 22 Sep 2023 14:36:12 +0200 Subject: [PATCH 3/3] Changed file path from fabric-lagacy to new path --- lib/config/config-utils.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/config/config-utils.go b/lib/config/config-utils.go index acd5f8d..1ded23d 100644 --- a/lib/config/config-utils.go +++ b/lib/config/config-utils.go @@ -204,7 +204,7 @@ func (c *Configuration) getVersionInfo(altServerName ...string) (string, int, *e } if c.Server.FileName != "server.jar" { //check if it matches the deafult name, if not - return c.getVersionInfo("server.jar") //fallback to default naming scheme + 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")