working on fabric issue

This commit is contained in:
Samuel Walker 2024-10-31 16:46:12 -06:00
parent 0f265ced92
commit 7e728ddff8
3 changed files with 23 additions and 36 deletions

1
.gitignore vendored
View File

@ -4,6 +4,7 @@
debug/ debug/
target/ target/
logs/ logs/
**/logs/
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html # More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html

View File

@ -307,38 +307,14 @@ func (i *InstanceManager)InstallFabric(instance string, fabricVersion string) {
fmt.Printf("unable to get version metadata\n") fmt.Printf("unable to get version metadata\n")
} }
for _, lib := range metadata.LauncherMeta.Libraries.Client { for _, lib := range metadata.LauncherMeta.Libraries.Client {
tokens := strings.SplitN(lib.Name, ".", 2) instanceObject.Libraries = append(instanceObject.Libraries, filepath.Join(ProcessMavenPath(lib.Name), ProcessMavenFilename(lib.Name)))
org1 := tokens[0]
tokens = strings.Split(tokens[1], ":")
org2 := tokens[0]
pack := tokens[1]
version := tokens[2]
instanceObject.Libraries = append(instanceObject.Libraries, filepath.Join(org1, org2, pack, version, pack+"-"+version+".jar"))
} }
for _, lib := range metadata.LauncherMeta.Libraries.Common { for _, lib := range metadata.LauncherMeta.Libraries.Common {
tokens := strings.SplitN(lib.Name, ".", 2) instanceObject.Libraries = append(instanceObject.Libraries, filepath.Join(ProcessMavenPath(lib.Name), ProcessMavenFilename(lib.Name)))
org1 := tokens[0]
tokens = strings.Split(tokens[1], ":")
org2 := tokens[0]
pack := tokens[1]
version := tokens[2]
instanceObject.Libraries = append(instanceObject.Libraries, filepath.Join(org1, org2, pack, version, pack+"-"+version+".jar"))
} }
tokens := strings.SplitN(metadata.Loader.Maven, ".", 2) instanceObject.Libraries = append(instanceObject.Libraries, filepath.Join(ProcessMavenPath(metadata.Loader.Maven), ProcessMavenFilename(metadata.Loader.Maven)))
org1 := tokens[0]
tokens = strings.Split(tokens[1], ":")
org2 := tokens[0]
pack := tokens[1]
version := tokens[2]
instanceObject.Libraries = append(instanceObject.Libraries, filepath.Join(org1, org2, pack, version, pack+"-"+version+".jar"))
tokens = strings.SplitN(metadata.Intermediary.Maven, ".", 2) instanceObject.Libraries = append(instanceObject.Libraries, filepath.Join(ProcessMavenPath(metadata.Intermediary.Maven), ProcessMavenFilename(metadata.Intermediary.Maven)))
org1 = tokens[0]
tokens = strings.Split(tokens[1], ":")
org2 = tokens[0]
pack = tokens[1]
version = tokens[2]
instanceObject.Libraries = append(instanceObject.Libraries, filepath.Join(org1, org2, pack, version, pack+"-"+version+".jar"))
instanceObject.MainClass = metadata.LauncherMeta.MainClass["client"] instanceObject.MainClass = metadata.LauncherMeta.MainClass["client"]
instanceObject.FabricVersion = fabricVersion instanceObject.FabricVersion = fabricVersion

View File

@ -75,13 +75,7 @@ func GetFabricMetadata(mcVersion string, fabricVersion string) (FabricVersion, e
} }
func InstallLib(lib FabricLibrary, libDir string) { func InstallLib(lib FabricLibrary, libDir string) {
tokens := strings.SplitN(lib.Name, ".", 2) path := filepath.Join(ProcessMavenPath(lib.Name), ProcessMavenFilename(lib.Name))
org1 := tokens[0]
tokens = strings.Split(tokens[1], ":")
org2 := tokens[0]
pack := tokens[1]
version := tokens[2]
path := filepath.Join(org1, org2, pack, version, pack+"-"+version+".jar")
if _, err := os.Stat(filepath.Join(libDir, path)); err == nil { if _, err := os.Stat(filepath.Join(libDir, path)); err == nil {
f, _ := os.OpenFile(filepath.Join(libDir, path), os.O_RDONLY, 0755) f, _ := os.OpenFile(filepath.Join(libDir, path), os.O_RDONLY, 0755)
defer f.Close() defer f.Close()
@ -96,7 +90,7 @@ func InstallLib(lib FabricLibrary, libDir string) {
return return
} }
defer resp.Body.Close() defer resp.Body.Close()
os.MkdirAll(filepath.Join(libDir, org1, org2, pack, version), 0755) os.MkdirAll(filepath.Join(libDir, ProcessMavenPath(lib.Name)), 0755)
f, _ := os.OpenFile(filepath.Join(libDir, path), os.O_CREATE|os.O_RDWR, 0755) f, _ := os.OpenFile(filepath.Join(libDir, path), os.O_CREATE|os.O_RDWR, 0755)
defer f.Close() defer f.Close()
io.Copy(f, resp.Body) io.Copy(f, resp.Body)
@ -113,3 +107,19 @@ func InstallFabricLibs(mcVersion string, fabricVersion string, libDir string) {
InstallLib(FabricLibrary{Name: metadata.Loader.Maven, Sha1: "", Url: "https://maven.fabricmc.net/"}, libDir) InstallLib(FabricLibrary{Name: metadata.Loader.Maven, Sha1: "", Url: "https://maven.fabricmc.net/"}, libDir)
InstallLib(FabricLibrary{Name: metadata.Intermediary.Maven, Sha1: "", Url: "https://maven.fabricmc.net/"}, libDir) InstallLib(FabricLibrary{Name: metadata.Intermediary.Maven, Sha1: "", Url: "https://maven.fabricmc.net/"}, libDir)
} }
func ProcessMavenPath(maven string) string {
tokens := strings.Split(maven, ":")
path := filepath.Join(strings.Split(tokens[0], ".")...)
pack := tokens[1]
version := tokens[2]
path = filepath.Join(path, pack, version)
return path
}
func ProcessMavenFilename(maven string) string {
tokens := strings.Split(maven, ":")
pack := tokens[1]
version := tokens[2]
return pack+"-"+version+".jar"
}