update __main__.py.

1.修正了部分版本无法启动的BUG
2.修复了部分文件无法下载BUG
3.修复了无法启动某些刚刚下载的新游戏文件BUG
This commit is contained in:
Bigsk 2020-08-19 02:07:35 +08:00 committed by Gitee
parent de373cf404
commit b7b9770709

View File

@ -296,7 +296,10 @@ if(parser.type=="download_file"):
count=0 count=0
for i in range(0,urljson['number']): for i in range(0,urljson['number']):
try: try:
download(urljson['url'][count],pathjson['path'][count]) filepath=pathjson['path'][count]
dirpath=filepath.replace(os.path.basename(filepath),"")
make_dir_exist(dirpath)
download(urljson['url'][count],filepath)
except: except:
log("error","Some errors happened while downloading files,please check and try again.") log("error","Some errors happened while downloading files,please check and try again.")
count=count+1 count=count+1
@ -305,6 +308,8 @@ if(parser.type=="download_file"):
deadly_error() deadly_error()
except: except:
try: try:
dirpath=parser.download_path.replace(os.path.basename(parser.download_path),"")
make_dir_exist(dirpath)
download(parser.download_url,parser.download_path) download(parser.download_url,parser.download_path)
except: except:
log("error","Some errors happened while downloading files,please check and try again.") log("error","Some errors happened while downloading files,please check and try again.")
@ -545,13 +550,30 @@ elif(parser.type=="launcher_game"):
for i in range(0,game_config_json.count('"path"')): for i in range(0,game_config_json.count('"path"')):
try: try:
make_file_exist(dir_i + '\\libraries\\' + game_config['libraries'][number]['downloads']['artifact']['path'].replace('/','\\'),game_config['libraries'][number]['downloads']['artifact']['url']) make_file_exist(dir_i + '\\libraries\\' + game_config['libraries'][number]['downloads']['artifact']['path'].replace('/','\\'),game_config['libraries'][number]['downloads']['artifact']['url'])
make_file_exist(dir_i + '\\libraries\\' + game_config['libraries'][number]['downloads']['classifiers']['javadoc']['path'].replace('/','\\'),game_config['libraries'][number]['downloads']['classifiers']['javadoc']['url'])
if(platform.system()=='Windows'): if(platform.system()=='Windows'):
make_file_exist(dir_i + '\\libraries\\' + game_config['libraries'][number]['downloads']['classifiers']['natives-windows']['path'].replace('/','\\'),game_config['libraries'][number]['downloads']['classifiers']['natives-windows']['url']) try:
make_file_exist(dir_i + '\\libraries\\' + game_config['libraries'][number]['downloads']['classifiers']['natives-windows']['path'].replace('/','\\'),game_config['libraries'][number]['downloads']['classifiers']['natives-windows']['url'])
except:
try:
make_file_exist(dir_i + '\\libraries\\' + game_config['patches'][0]['libraries'][number]['downloads']['classifiers']['natives-windows']['path'].replace('/','\\'),game_config['patches'][0]['libraries'][number]['downloads']['classifiers']['natives-windows']['url'])
except:
pass
elif(platform.system()=='Linux'): elif(platform.system()=='Linux'):
make_file_exist(dir_i + '\\libraries\\' + game_config['libraries'][number]['downloads']['classifiers']['natives-linux']['path'].replace('/','\\'),game_config['libraries'][number]['downloads']['classifiers']['natives-linux']['url']) try:
make_file_exist(dir_i + '\\libraries\\' + game_config['libraries'][number]['downloads']['classifiers']['natives-linux']['path'].replace('/','\\'),game_config['libraries'][number]['downloads']['classifiers']['natives-linux']['url'])
except:
try:
make_file_exist(dir_i + '\\libraries\\' + game_config['patches'][0]['libraries'][number]['downloads']['classifiers']['natives-linux']['path'].replace('/','\\'),game_config['patches'][0]['libraries'][number]['downloads']['classifiers']['natives-linux']['url'])
except:
pass
else: else:
make_file_exist(dir_i + '\\libraries\\' + game_config['libraries'][number]['downloads']['classifiers']['natives-macos']['path'].replace('/','\\'),game_config['libraries'][number]['downloads']['classifiers']['natives-macos']['url']) try:
make_file_exist(dir_i + '\\libraries\\' + game_config['libraries'][number]['downloads']['classifiers']['natives-macos']['path'].replace('/','\\'),game_config['libraries'][number]['downloads']['classifiers']['natives-macos']['url'])
except:
try:
make_file_exist(dir_i + '\\libraries\\' + game_config['patches'][0]['libraries'][number]['downloads']['classifiers']['natives-macos']['path'].replace('/','\\'),game_config['patches'][0]['libraries'][number]['downloads']['classifiers']['natives-macos']['url'])
except:
pass
except: except:
pass pass
number=number+1 number=number+1
@ -565,17 +587,26 @@ elif(parser.type=="launcher_game"):
try: try:
unzip(dir_i + '\\libraries\\' + game_config['libraries'][number]['downloads']['classifiers']['natives-windows']['path'].replace('/','\\'),dir_i + '\\versions\\' + parser.version + '\\natives') unzip(dir_i + '\\libraries\\' + game_config['libraries'][number]['downloads']['classifiers']['natives-windows']['path'].replace('/','\\'),dir_i + '\\versions\\' + parser.version + '\\natives')
except: except:
pass try:
unzip(dir_i + '\\libraries\\' + game_config['patches'][0]['libraries'][number]['downloads']['classifiers']['natives-windows']['path'].replace('/','\\'),dir_i + '\\versions\\' + parser.version + '\\natives')
except:
pass
elif(platform.system()=='Linux'): elif(platform.system()=='Linux'):
try: try:
unzip(dir_i + '\\libraries\\' + game_config['libraries'][number]['downloads']['classifiers']['natives-linux']['path'].replace('/','\\'),dir_i + '\\versions\\' + parser.version + '\\natives') unzip(dir_i + '\\libraries\\' + game_config['libraries'][number]['downloads']['classifiers']['natives-linux']['path'].replace('/','\\'),dir_i + '\\versions\\' + parser.version + '\\natives')
except: except:
pass try:
unzip(dir_i + '\\libraries\\' + game_config['patches'][0]['libraries'][number]['downloads']['classifiers']['natives-linux']['path'].replace('/','\\'),dir_i + '\\versions\\' + parser.version + '\\natives')
except:
pass
else: else:
try: try:
unzip(dir_i + '\\libraries\\' + game_config['libraries'][number]['downloads']['classifiers']['natives-macos']['path'].replace('/','\\'),dir_i + '\\versions\\' + parser.version + '\\natives') unzip(dir_i + '\\libraries\\' + game_config['libraries'][number]['downloads']['classifiers']['natives-macos']['path'].replace('/','\\'),dir_i + '\\versions\\' + parser.version + '\\natives')
except: except:
pass try:
unzip(dir_i + '\\libraries\\' + game_config['patches'][0]['libraries'][number]['downloads']['classifiers']['natives-macos']['path'].replace('/','\\'),dir_i + '\\versions\\' + parser.version + '\\natives')
except:
pass
number=number+1 number=number+1
cp="" cp=""
number=0 number=0
@ -583,7 +614,10 @@ elif(parser.type=="launcher_game"):
try: try:
cp=cp + dir_i + '\\libraries\\' + game_config['libraries'][number]['downloads']['artifact']['path'].replace('/','\\') + ';' cp=cp + dir_i + '\\libraries\\' + game_config['libraries'][number]['downloads']['artifact']['path'].replace('/','\\') + ';'
except: except:
pass try:
cp=cp + dir_i + '\\libraries\\' + game_config['patches'][0]['libraries'][number]['downloads']['artifact']['path'].replace('/','\\') + ';'
except:
pass
number=number+1 number=number+1
cp=cp + dir_i + '\\versions\\' + parser.version + '\\' + parser.version + '.jar' cp=cp + dir_i + '\\versions\\' + parser.version + '\\' + parser.version + '.jar'
return_data('Checking java environment.') return_data('Checking java environment.')
@ -606,10 +640,13 @@ elif(parser.type=="launcher_game"):
return_info.close() return_info.close()
else: else:
memory=parser.memory memory=parser.memory
asset_index=game_config['assetIndex']['id'] try:
asset_index="1.16" asset_index=game_config['assetIndex']['id']
command='\"' + java.replace('\n','') + '\" -XX:+UnlockExperimentalVMOptions -XX:+UseG1GC -XX:G1NewSizePercent=20 -XX:G1ReservePercent=20 -XX:MaxGCPauseMillis=50 -XX:G1HeapRegionSize=16M -XX:-UseAdaptiveSizePolicy -XX:-OmitStackTraceInFastThrow -Xmn128m -Xmx' + memory + ' -Dfml.ignoreInvalidMinecraftCertificates=true -Dfml.ignorePatchDiscrepancies=true -XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump -Djava.library.path=' + dir_i + '\\versions\\' + parser.version + '\\natives -Dminecraft.launcher.brand=' + config['default_launcher_name'] + ' -Dminecraft.launcher.version=' + config['version'] + ' -cp ' + cp + ' net.minecraft.client.main.Main --username ' + parser.id + ' --version "' + config['default_launcher_name'] + ' ' + config['version'] + '" --gameDir ' + dir_i + ' --assetsDir ' + dir_i + '\\assets --assetIndex ' + asset_index + ' --uuid ' + uuid + ' --accessToken ' + uuid + ' --userProperties {} --userType mojang' except:
asset_index=game_config['patches'][0]['assetIndex']['id']
command='\"' + java.replace('\n','') + '\" -XX:+UnlockExperimentalVMOptions -XX:+UseG1GC -XX:G1NewSizePercent=20 -XX:G1ReservePercent=20 -XX:MaxGCPauseMillis=50 -XX:G1HeapRegionSize=16M -XX:-UseAdaptiveSizePolicy -XX:-OmitStackTraceInFastThrow -Xmn128m -Xmx' + memory + ' -Dfml.ignoreInvalidMinecraftCertificates=true -Dfml.ignorePatchDiscrepancies=true -XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump -Djava.library.path=' + dir_i + '\\versions\\' + parser.version + '\\natives -Dminecraft.launcher.brand=' + config['default_launcher_name'] + ' -Dminecraft.launcher.version=' + config['version'] + ' -cp ' + cp + ' net.minecraft.client.main.Main --username ' + parser.id + ' --version "' + config['default_launcher_name'] + ' ' + config['version'] + '" --gameDir ' + dir_i + ' --assetsDir ' + dir_i + '\\assets --assetIndex ' + asset_index + ' --uuid ' + uuid + ' --accessToken ' + uuid + ' --userProperties {} --userType mojang --versionType "' + config['default_launcher_name'] + ' ' + config['version'] + '"'
subprocess.Popen(command, shell=True) subprocess.Popen(command, shell=True)
print(command)
else: else:
return_data('The version you input is not exist!Please check if the parameter you input is correct!') return_data('The version you input is not exist!Please check if the parameter you input is correct!')
log('error','The vversion you input is not exist!Please check if the parameter you input is correct!') log('error','The vversion you input is not exist!Please check if the parameter you input is correct!')