From b7b97707094bc6534dc3e8617236924712cfb497 Mon Sep 17 00:00:00 2001 From: Bigsk <1332540+bigskcode@user.noreply.gitee.com> Date: Wed, 19 Aug 2020 02:07:35 +0800 Subject: [PATCH] =?UTF-8?q?update=20=5F=5Fmain=5F=5F.py.=201.=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3=E4=BA=86=E9=83=A8=E5=88=86=E7=89=88=E6=9C=AC=E6=97=A0?= =?UTF-8?q?=E6=B3=95=E5=90=AF=E5=8A=A8=E7=9A=84BUG=202.=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E4=BA=86=E9=83=A8=E5=88=86=E6=96=87=E4=BB=B6=E6=97=A0=E6=B3=95?= =?UTF-8?q?=E4=B8=8B=E8=BD=BDBUG=203.=E4=BF=AE=E5=A4=8D=E4=BA=86=E6=97=A0?= =?UTF-8?q?=E6=B3=95=E5=90=AF=E5=8A=A8=E6=9F=90=E4=BA=9B=E5=88=9A=E5=88=9A?= =?UTF-8?q?=E4=B8=8B=E8=BD=BD=E7=9A=84=E6=96=B0=E6=B8=B8=E6=88=8F=E6=96=87?= =?UTF-8?q?=E4=BB=B6BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- __main__.py | 61 ++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 49 insertions(+), 12 deletions(-) diff --git a/__main__.py b/__main__.py index d3c3b32..255546d 100644 --- a/__main__.py +++ b/__main__.py @@ -296,7 +296,10 @@ if(parser.type=="download_file"): count=0 for i in range(0,urljson['number']): 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: log("error","Some errors happened while downloading files,please check and try again.") count=count+1 @@ -305,6 +308,8 @@ if(parser.type=="download_file"): deadly_error() except: try: + dirpath=parser.download_path.replace(os.path.basename(parser.download_path),"") + make_dir_exist(dirpath) download(parser.download_url,parser.download_path) except: 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"')): 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']['classifiers']['javadoc']['path'].replace('/','\\'),game_config['libraries'][number]['downloads']['classifiers']['javadoc']['url']) 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'): - 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: - 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: pass number=number+1 @@ -565,17 +587,26 @@ elif(parser.type=="launcher_game"): try: unzip(dir_i + '\\libraries\\' + game_config['libraries'][number]['downloads']['classifiers']['natives-windows']['path'].replace('/','\\'),dir_i + '\\versions\\' + parser.version + '\\natives') 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'): try: unzip(dir_i + '\\libraries\\' + game_config['libraries'][number]['downloads']['classifiers']['natives-linux']['path'].replace('/','\\'),dir_i + '\\versions\\' + parser.version + '\\natives') 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: try: unzip(dir_i + '\\libraries\\' + game_config['libraries'][number]['downloads']['classifiers']['natives-macos']['path'].replace('/','\\'),dir_i + '\\versions\\' + parser.version + '\\natives') 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 cp="" number=0 @@ -583,7 +614,10 @@ elif(parser.type=="launcher_game"): try: cp=cp + dir_i + '\\libraries\\' + game_config['libraries'][number]['downloads']['artifact']['path'].replace('/','\\') + ';' except: - pass + try: + cp=cp + dir_i + '\\libraries\\' + game_config['patches'][0]['libraries'][number]['downloads']['artifact']['path'].replace('/','\\') + ';' + except: + pass number=number+1 cp=cp + dir_i + '\\versions\\' + parser.version + '\\' + parser.version + '.jar' return_data('Checking java environment.') @@ -606,10 +640,13 @@ elif(parser.type=="launcher_game"): return_info.close() else: memory=parser.memory - asset_index=game_config['assetIndex']['id'] - asset_index="1.16" - 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' + try: + asset_index=game_config['assetIndex']['id'] + 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) + print(command) else: 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!')