added logging config

This commit is contained in:
Samuel Walker 2024-10-30 15:58:05 -06:00
parent 2bbb4b8cf0
commit 3720f1e524
8 changed files with 189 additions and 39 deletions

View File

@ -169,6 +169,7 @@ func (i *InstanceManager)InstallVanilla(version string, instanceName string) {
fmt.Printf("Libs Downloaded") fmt.Printf("Libs Downloaded")
} }
InstallNatives(version, filepath.Join(dir, "FCLauncher", "instances", instanceName, "minecraft", "natives")) InstallNatives(version, filepath.Join(dir, "FCLauncher", "instances", instanceName, "minecraft", "natives"))
DownloadLoggingConfig(version, filepath.Join(dir, "FCLauncher", "instances", instanceName, "minecraft"))
err = DownloadExecutable(version, filepath.Join(dir, "FCLauncher", "bin"), *i.app) err = DownloadExecutable(version, filepath.Join(dir, "FCLauncher", "bin"), *i.app)
if err != nil { if err != nil {
fmt.Printf("Unable to download binaries: %s\n", err) fmt.Printf("Unable to download binaries: %s\n", err)

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

File diff suppressed because one or more lines are too long

View File

@ -93,6 +93,15 @@ type McDownload struct {
Url string Url string
} }
type McLogging struct {
Client McLoggingClient
}
type McLoggingClient struct {
Argument string
File McDownload
}
type McMetadata struct { type McMetadata struct {
Arguments McArguments Arguments McArguments
AssetIndex McAssetIndex AssetIndex McAssetIndex
@ -102,13 +111,13 @@ type McMetadata struct {
Id string Id string
JavaVersion McJavaVersion JavaVersion McJavaVersion
Libraries []McLibrary Libraries []McLibrary
Logging interface{}
MainClass string MainClass string
MinimumLauncherVersion int MinimumLauncherVersion int
ReleaseTime time.Time ReleaseTime time.Time
Time time.Time Time time.Time
Type string Type string
MinecraftArguments string MinecraftArguments string
Logging McLogging
} }
func GetVersionManifest() (McVersionManifest, error) { func GetVersionManifest() (McVersionManifest, error) {
@ -437,6 +446,19 @@ func InstallNatives(mcVersion string, nativesDir string){
} }
} }
func DownloadLoggingConfig(mcVersion string, gameDir string){
metadata, _ := GetVersionMetadata(mcVersion)
resp, err := http.Get(metadata.Logging.Client.File.Url)
if err != nil {
fmt.Printf("Error downloading logging config: %s\n", err)
}
defer resp.Body.Close()
os.MkdirAll(gameDir, 0755)
f, _ := os.OpenFile(filepath.Join(gameDir, "log4j2.xml"), os.O_CREATE|os.O_RDWR, 0755)
defer f.Close()
io.Copy(f, resp.Body)
}
func DownloadExecutable(mcVersion string, binDir string, a App) error { func DownloadExecutable(mcVersion string, binDir string, a App) error {
metadata, err := GetVersionMetadata(mcVersion) metadata, err := GetVersionMetadata(mcVersion)
if err != nil { if err != nil {
@ -512,6 +534,7 @@ func GetBaseLaunchArgs(mcVersion string, libDir string, binDir string, assetDir
args = append(args, "-Djna.tmpdir="+filepath.Join(gameDir, "natives")) args = append(args, "-Djna.tmpdir="+filepath.Join(gameDir, "natives"))
args = append(args, "-Dorg.lwjgl.system.SharedLibraryExtractpath="+filepath.Join(gameDir, "natives")) args = append(args, "-Dorg.lwjgl.system.SharedLibraryExtractpath="+filepath.Join(gameDir, "natives"))
args = append(args, "-Dio.netty.native.workdir="+filepath.Join(gameDir, "natives")) args = append(args, "-Dio.netty.native.workdir="+filepath.Join(gameDir, "natives"))
args = append(args, strings.ReplaceAll(metadata.Logging.Client.Argument, "${path}", filepath.Join(gameDir, "log4j2.xml")))
args = append(args, "-Xms512m") args = append(args, "-Xms512m")
args = append(args, "-Xmx1024m") args = append(args, "-Xmx1024m")
args = append(args, "-cp") args = append(args, "-cp")