Changed default RAM limit

This commit is contained in:
= 2024-11-25 19:21:20 -07:00
parent 8208434b8f
commit ad736787e9

View File

@ -19,40 +19,40 @@ import (
) )
type McVersionManifestEntry struct { type McVersionManifestEntry struct {
Id string Id string
Type string Type string
Url string Url string
Time time.Time Time time.Time
ReleaseTime time.Time ReleaseTime time.Time
Sha1 string Sha1 string
ComplianceLevel int ComplianceLevel int
} }
type McLatestEntry struct { type McLatestEntry struct {
Release string Release string
Snapshot string Snapshot string
} }
type McVersionManifest struct { type McVersionManifest struct {
Latest McLatestEntry Latest McLatestEntry
Versions []McVersionManifestEntry Versions []McVersionManifestEntry
} }
type McArguments struct { type McArguments struct {
Game []string Game []string
Jvm []string Jvm []string
} }
type McAssetIndex struct { type McAssetIndex struct {
Id string Id string
Sha1 string Sha1 string
Size int Size int
TotalSize int TotalSize int
Url string Url string
} }
type McJavaVersion struct { type McJavaVersion struct {
Component string Component string
MajorVersion int MajorVersion int
} }
@ -60,37 +60,37 @@ type McLibraryArtifact struct {
Path string Path string
Sha1 string Sha1 string
Size int Size int
Url string Url string
} }
type McLibraryDownload struct { type McLibraryDownload struct {
Artifact McLibraryArtifact Artifact McLibraryArtifact
Classifiers map[string]interface{} Classifiers map[string]interface{}
} }
type McRuleOs struct { type McRuleOs struct {
Name string Name string
Version string Version string
ARch string ARch string
} }
type McRule struct { type McRule struct {
Action string Action string
Features map[string]bool Features map[string]bool
Os McRuleOs Os McRuleOs
} }
type McLibrary struct { type McLibrary struct {
Downloads McLibraryDownload Downloads McLibraryDownload
Name string Name string
Rules []McRule Rules []McRule
Natives map[string]string Natives map[string]string
} }
type McDownload struct { type McDownload struct {
Sha1 string Sha1 string
Size int Size int
Url string Url string
} }
type McLogging struct { type McLogging struct {
@ -99,25 +99,25 @@ type McLogging struct {
type McLoggingClient struct { type McLoggingClient struct {
Argument string Argument string
File McDownload File McDownload
} }
type McMetadata struct { type McMetadata struct {
Arguments McArguments Arguments McArguments
AssetIndex McAssetIndex AssetIndex McAssetIndex
Assets string Assets string
ComplianceLevel int ComplianceLevel int
Downloads map[string]McDownload Downloads map[string]McDownload
Id string Id string
JavaVersion McJavaVersion JavaVersion McJavaVersion
Libraries []McLibrary Libraries []McLibrary
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 Logging McLogging
} }
func GetVersionManifest() (McVersionManifest, error) { func GetVersionManifest() (McVersionManifest, error) {
@ -127,7 +127,7 @@ func GetVersionManifest() (McVersionManifest, error) {
defer resp.Body.Close() defer resp.Body.Close()
data, err := io.ReadAll(resp.Body) data, err := io.ReadAll(resp.Body)
if err == nil { if err == nil {
versionManifest := McVersionManifest{} versionManifest := McVersionManifest{}
err = json.Unmarshal(data, &versionManifest) err = json.Unmarshal(data, &versionManifest)
if err == nil { if err == nil {
dir, err := os.UserConfigDir() dir, err := os.UserConfigDir()
@ -191,7 +191,7 @@ func GetVersionMetadata(wantedVersion string) (McMetadata, error) {
defer f.Close() defer f.Close()
if data, err := io.ReadAll(f); err == nil { if data, err := io.ReadAll(f); err == nil {
sha := sha1.Sum(data) sha := sha1.Sum(data)
if hex.EncodeToString(sha[:20]) == version.Sha1{ if hex.EncodeToString(sha[:20]) == version.Sha1 {
metadata := McMetadata{} metadata := McMetadata{}
json.Unmarshal(data, &metadata) json.Unmarshal(data, &metadata)
return metadata, nil return metadata, nil
@ -226,7 +226,7 @@ func GetVersionMetadata(wantedVersion string) (McMetadata, error) {
} }
} }
return metadata, nil return metadata, nil
} }
} }
return McMetadata{}, fmt.Errorf("Unable to find version %s\n", wantedVersion) return McMetadata{}, fmt.Errorf("Unable to find version %s\n", wantedVersion)
@ -398,7 +398,7 @@ func DownloadLibraries(mcVersion string, libPath string, a App) error {
for ind, token := range tokens { for ind, token := range tokens {
if ind != len(tokens)-1 { if ind != len(tokens)-1 {
path = filepath.Join(path, token) path = filepath.Join(path, token)
} }
} }
err = os.MkdirAll(filepath.Join(libPath, path), 0755) err = os.MkdirAll(filepath.Join(libPath, path), 0755)
if err != nil { if err != nil {
@ -415,7 +415,7 @@ func DownloadLibraries(mcVersion string, libPath string, a App) error {
return nil return nil
} }
func InstallNatives(mcVersion string, nativesDir string){ func InstallNatives(mcVersion string, nativesDir string) {
metadata, _ := GetVersionMetadata(mcVersion) metadata, _ := GetVersionMetadata(mcVersion)
for _, lib := range metadata.Libraries { for _, lib := range metadata.Libraries {
if lib.Natives != nil { if lib.Natives != nil {
@ -446,7 +446,7 @@ func InstallNatives(mcVersion string, nativesDir string){
} }
} }
func DownloadLoggingConfig(mcVersion string, gameDir string){ func DownloadLoggingConfig(mcVersion string, gameDir string) {
metadata, _ := GetVersionMetadata(mcVersion) metadata, _ := GetVersionMetadata(mcVersion)
resp, err := http.Get(metadata.Logging.Client.File.Url) resp, err := http.Get(metadata.Logging.Client.File.Url)
if err != nil { if err != nil {
@ -540,7 +540,7 @@ func GetBaseLaunchArgs(mcVersion string, instance Instance, libDir string, binDi
args = append(args, loggingArg) args = append(args, loggingArg)
} }
args = append(args, "-Xms512m") args = append(args, "-Xms512m")
args = append(args, "-Xmx1024m") args = append(args, "-Xmx4096m")
args = append(args, "-cp") args = append(args, "-cp")
arg := "" arg := ""
separater := ":" separater := ":"
@ -556,8 +556,6 @@ func GetBaseLaunchArgs(mcVersion string, instance Instance, libDir string, binDi
arg += filepath.Join(binDir, mcVersion, "client.jar") arg += filepath.Join(binDir, mcVersion, "client.jar")
args = append(args, arg) args = append(args, arg)
args = append(args, instance.MainClass) args = append(args, instance.MainClass)
for _, val := range searchArgs { for _, val := range searchArgs {
@ -586,7 +584,6 @@ func GetBaseLaunchArgs(mcVersion string, instance Instance, libDir string, binDi
return args, nil return args, nil
} }
func GetOfflineLaunchArgs(mcVersion string, instance Instance, libDir string, binDir string, assetDir string, gameDir string, playerName string) ([]string, error) { func GetOfflineLaunchArgs(mcVersion string, instance Instance, libDir string, binDir string, assetDir string, gameDir string, playerName string) ([]string, error) {
args, err := GetBaseLaunchArgs(mcVersion, instance, libDir, binDir, assetDir, gameDir) args, err := GetBaseLaunchArgs(mcVersion, instance, libDir, binDir, assetDir, gameDir)
if err != nil { if err != nil {
@ -594,7 +591,7 @@ func GetOfflineLaunchArgs(mcVersion string, instance Instance, libDir string, bi
} }
for ind, val := range args { for ind, val := range args {
switch val{ switch val {
case "${auth_player_name}": case "${auth_player_name}":
args[ind] = playerName args[ind] = playerName
case "${auth_uuid}": case "${auth_uuid}":
@ -617,7 +614,7 @@ func GetOnlineLaunchArgs(mcVersion string, instance Instance, libDir string, bin
} }
for ind, val := range args { for ind, val := range args {
switch val{ switch val {
case "${auth_player_name}": case "${auth_player_name}":
args[ind] = auth.Name args[ind] = auth.Name
case "${auth_uuid}": case "${auth_uuid}":