diff --git a/gmclc.py b/gmclc.py index 4f68b51..9abd8d1 100644 --- a/gmclc.py +++ b/gmclc.py @@ -14,11 +14,11 @@ config_json=config_open.read() config_open.close() try: config=json.loads(config_json) - config_state=True + config_status=True except: - config_state=False + config_status=False Log=Log + '\n' + "[Program]" + '[' + time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) + ']' + '[INFO]Starting to read config file.' -if(config_state==True): +if(config_status==True): Log=Log + '\n' + "[" + config['name'] + "]" + '[' + time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) + ']' + '[INFO]Read config successfully.' else: Log=Log + '\n' + "[Program]" + '[' + time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) + ']' + '[ERROR]Read config failed.' @@ -38,7 +38,7 @@ parser=argparse.ArgumentParser() parser.add_argument("--launcher_name", help="The name of the launcher.") parser.add_argument("--launcher_version", help="The version of the launcher.") parser.add_argument("--type", help="The type of task,{\"launcher_game\",\"search_file\",\"get_game_version_list\",\"get_java_path\",\"get_system_memory\",\"get_online_source_list\",\"install_online_source\",\"get_uuid\",\"download_file\",\"clean_logs\",\"clean_temp\",\"clean\",\"clean_logs_without_output\",\"clean_without_output\"}") -parser.add_argument("--copyright", help="The copyright of the game,true of false.") +parser.add_argument("--copyright", help="The copyright of the game,true of false.The default is false.") #Launcher Game Parameter Area. #Search File Area. parser.add_argument("--file_name", help="The name of file which you want to search.") @@ -285,6 +285,11 @@ make_dir_exist("temp") #-------------------------------------------------------# +#Use Statistics Area. +open_s=requests.get('https://open.gmclc.statistics.ghink.net', headers=UA) + +#-------------------------------------------------------# + log("info","Start to deal the tasks that need to do.") if(parser.type=="download_file"): log("info","Download file(s) mode.") @@ -509,26 +514,77 @@ elif(parser.type=="launcher_game"): deadly_error() else: dir_i=parser.dir - return_data('Checking player id.') - log('info','Checking player id.') - if(parser.id==None): - return_data('There has a error in parameters you input,please check if the parameter "id" is correct.') - log('error','There has a error in parameters you input,please check if the parameter "id" is correct.') - deadly_error() - else: - return_data('Checking player uuid.') - log('info','Checking player uuid.') - if(parser.uuid==None): - uuid=get_uuid(parser.id,'gmclc') - elif(parser.uuid=='gmclc'): - uuid=get_uuid(parser.id,'gmclc') - elif(parser.uuid=='hmcl'): - uuid=get_uuid(parser.id,'hmcl') - elif(len(parser.uuid)==32): - uuid=parser.uuid + return_data('Checking game copyright.') + log('info','Checking game copyright.') + if(parser.copyright==None): + if(parser.id==None): + return_data('There has a error in parameters you input,please check if the parameter "id" is correct.') + log('error','There has a error in parameters you input,please check if the parameter "id" is correct.') + deadly_error() else: - return_data('There has a error in parameters you input,please check if the parameter "uuid" is correct.') - log('error','There has a error in parameters you input,please check if the parameter "uuid" is correct.') + return_data('Checking player uuid.') + log('info','Checking player uuid.') + if(parser.uuid==None): + uuid=get_uuid(parser.id,'gmclc') + elif(parser.uuid=='gmclc'): + uuid=get_uuid(parser.id,'gmclc') + elif(parser.uuid=='hmcl'): + uuid=get_uuid(parser.id,'hmcl') + elif(len(parser.uuid)==32): + uuid=parser.uuid + else: + return_data('There has a error in parameters you input,please check if the parameter "uuid" is correct.') + log('error','There has a error in parameters you input,please check if the parameter "uuid" is correct.') + deadly_error() + access_token=uuid + id_i=parser.id + elif(parser.copyright=='false'): + if(parser.id==None): + return_data('There has a error in parameters you input,please check if the parameter "id" is correct.') + log('error','There has a error in parameters you input,please check if the parameter "id" is correct.') + deadly_error() + else: + return_data('Checking player uuid.') + log('info','Checking player uuid.') + if(parser.uuid==None): + uuid=get_uuid(parser.id,'gmclc') + elif(parser.uuid=='gmclc'): + uuid=get_uuid(parser.id,'gmclc') + elif(parser.uuid=='hmcl'): + uuid=get_uuid(parser.id,'hmcl') + elif(len(parser.uuid)==32): + uuid=parser.uuid + else: + return_data('There has a error in parameters you input,please check if the parameter "uuid" is correct.') + log('error','There has a error in parameters you input,please check if the parameter "uuid" is correct.') + deadly_error() + access_token=uuid + id_i=parser.id + elif(parser.copyright=='true'): + if(parser.email==None): + return_data('There has a error in parameters you input,please check if the parameter "email" is correct.') + log('error','There has a error in parameters you input,please check if the parameter "email" is correct.') + deadly_error() + elif(parser.email.count('@')==1): + email=parser.email + else: + return_data('There has a error in parameters you input,please check if the parameter "email" is correct.') + log('error','There has a error in parameters you input,please check if the parameter "email" is correct.') + deadly_error() + if(parser.password==None): + return_data('There has a error in parameters you input,please check if the parameter "password" is correct.') + log('error','There has a error in parameters you input,please check if the parameter "password" is correct.') + deadly_error() + else: + password=parser.password + if(json.loads(requests.get('https://authserver.mojang.com/', headers=UA).text)['Status']=='OK'): + rq_r=json.loads(requests.post('https://authserver.mojang.com/authenticate', '{"agent": {"name": "Minecraft","version": 1},"username": "' + parser.email + '","password": "' + parser.password + '"}', headers=UA).text) + access_token=rq_r['accessToken'] + id_i=rq_r['selectedProfile']['name'] + uuid=rq_r['selectedProfile']['id'] + else: + return_data('There has a error while login to mojang account,the auth server has failed.') + log('error','There has a error while login to mojang account,the auth server has failed.') deadly_error() return_data('Checking game version(s).') log('info','Checking game version(s).') @@ -644,9 +700,10 @@ elif(parser.type=="launcher_game"): 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'] + '"' + 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 ' + id_i + ' --version "' + config['default_launcher_name'] + ' ' + config['version'] + '" --gameDir ' + dir_i + ' --assetsDir ' + dir_i + '\\assets --assetIndex ' + asset_index + ' --uuid ' + uuid + ' --accessToken ' + access_token + ' --userProperties {} --userType mojang --versionType "' + config['default_launcher_name'] + ' ' + config['version'] + '"' subprocess.Popen(command, shell=True) - print(command) + open_s=requests.get('https://launch.gmclc.statistics.ghink.net', headers=UA) + #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!')