@@ -119,12 +119,11 @@ def login(username, password):
119119 }
120120
121121 data = requests .post ("https://authserver.mojang.com/authenticate" , json = data )
122- print (data .content )
123122 data = json .loads (data .content )
124123
125124 try :
126- return True , data ["selectedProfile" ]["name" ] + " " + data ["accessToken" ]
127- except AttributeError :
125+ return True , " --username=" + data ["selectedProfile" ]["name" ] + " --session-id= " + data ["accessToken" ]
126+ except KeyError :
128127 return False , None
129128
130129
@@ -203,15 +202,16 @@ def stop(self):
203202class getModpackFS (QThread ):
204203 installModpack = pyqtSignal (str )
205204 starting = pyqtSignal ()
205+ updateIStatus = pyqtSignal (str )
206+ updateStatus = pyqtSignal (str )
206207
207- def __init__ (self , win = None , modpackDir = None ):
208+ def __init__ (self , modpackDir = None ):
208209 super ().__init__ ()
209- self .win = win
210- self .modpackName = modpackDir
210+ self .modpackDir = modpackDir
211211
212212 def run (self ):
213213 self .starting .emit ()
214- if not self .modpackDir or not self . win :
214+ if not self .modpackDir :
215215 modpackName = "Error"
216216 else :
217217 self .updateIStatus .emit ("Retrieving modpack from path..." )
@@ -226,7 +226,10 @@ def run(self):
226226 try :
227227 shutil .copy (self .modpackDir , config .MC_DIR + "/modpackzips/" + modpackName + ".zip" )
228228 except :
229+ traceback .print_exc ()
229230 modpackName = "Error"
231+ self .updateStatus .emit ("Modpack cached. Starting install." )
232+ self .updateIStatus .emit ("Modpack cached. Starting install." )
230233 self .installModpack .emit (modpackName )
231234
232235 def stop (self ):
@@ -283,12 +286,13 @@ def run(self):
283286 print ("Installing modpack" )
284287 try :
285288 if self .modpackName == "Error" or self .modpackName is None :
289+ traceback .print_exc ()
286290 raise IOError ("Modpack does not exist in directory?" )
287291 if not os .path .exists (config .MC_DIR + "/tmp/" + self .modpackName ):
288292 os .makedirs (config .MC_DIR + "/tmp/" + self .modpackName )
289293
290294 # Extracts the zip file to the temp dir.
291- self .updateIStatus .emit ("Extracting modpack..." )
295+ self .updateIStatus .emit ("Extracting modpack..." )
292296 with zipfile .ZipFile (config .MC_DIR + "/modpackzips/" + self .modpackName + ".zip" , "r" ) as zip :
293297 zip .extractall (config .MC_DIR + "/tmp/" + self .modpackName )
294298
@@ -303,6 +307,7 @@ def run(self):
303307 except :
304308 mcVer = None
305309 except :
310+ traceback .print_exc ()
306311 self .updateIStatus .emit ("No modpack name found. Using zip file name. Get the modpack author to create a \" modpack.json\" file in his/her modpack." )
307312 modpackJsonName = self .modpackName
308313 mcVer = None
@@ -338,7 +343,7 @@ def run(self):
338343
339344 # Gotta stay clean!
340345 self .updateIStatus .emit ("Deleting temp files..." )
341- remove_tree (config .MC_DIR + "/tmp/" + self .modpackName )
346+ # remove_tree(config.MC_DIR + "/tmp/" + self.modpackName)
342347 self .updateStatus .emit ("Modpack installed!" , "green" )
343348
344349 # And in case the zip didnt exist in the first place.
@@ -362,6 +367,8 @@ def makeModpack(self, mcVer):
362367 if response .content is None :
363368 raise ConnectionError ("Something went very wrong." )
364369
370+ areYouThere (config .MC_DIR + "/tmp/" + self .modpackName + "/.minecraft/bin" )
371+
365372 self .updateIStatus .emit ("Started connection.." )
366373
367374 dl = 0
@@ -384,13 +391,21 @@ def makeModpack(self, mcVer):
384391
385392 self .updateIStatus .emit ("Extracted.\n Extracting modpack jar and merging jars.." )
386393
387- shutil .unpack_archive (config .MC_DIR + "/tmp/" + self .modpackName + "/.minecraft/bin/minecraft.jar" , config .MC_DIR + "/tmp/" + self .modpackName + "/.minecraft/bin/minecraft" , "zip" )
394+ try :
395+ shutil .unpack_archive (config .MC_DIR + "/tmp/" + self .modpackName + "/.minecraft/bin/minecraft.jar" , config .MC_DIR + "/tmp/" + self .modpackName + "/.minecraft/bin/minecraft" , "zip" )
396+ except :
397+ traceback .print_exc ()
398+ print ("No modpack jar found. Making a vanilla instance with contents of modpack zip." )
388399
389400 self .updateIStatus .emit ("Extracted.\n Archiving.." )
390401
391402 shutil .make_archive (config .MC_DIR + "/tmp/" + self .modpackName + "/.minecraft/bin/minecraft" , "zip" , config .MC_DIR + "/tmp/" + self .modpackName + "/.minecraft/bin/minecraft" )
392403
393- os .remove (config .MC_DIR + "/tmp/" + self .modpackName + "/.minecraft/bin/minecraft.jar" )
404+ try :
405+ os .remove (config .MC_DIR + "/tmp/" + self .modpackName + "/.minecraft/bin/minecraft.jar" )
406+ except :
407+ traceback .print_exc ()
408+
394409 os .rename (config .MC_DIR + "/tmp/" + self .modpackName + "/.minecraft/bin/minecraft.zip" , config .MC_DIR + "/tmp/" + self .modpackName + "/.minecraft/bin/minecraft.jar" )
395410
396411 self .updateIStatus .emit ("Archived.\n Downloading LWJGL for " + config .OS + ".." )
@@ -438,11 +453,11 @@ def rmInstance(instanceName, self):
438453 except :
439454 pass
440455
441- # TODO Remove this if new solution works.
442- """ class minecraftProxy(threading.Thread ):
456+
457+ class minecraftProxy (QThread ):
443458
444459 def __init__ (self , doSkinFix , doSoundFix , doCapeFix , loop ):
445- super(minecraftProxy, self ).__init__()
460+ super ().__init__ ()
446461 self .doSkinFix = doSkinFix
447462 self .doCapeFix = doCapeFix
448463 self .doSoundFix = doSoundFix
@@ -470,57 +485,16 @@ def request(self, flow):
470485 flow .request .host = "resourceproxy.pymcl.net"
471486 flow .request .path = "/capeapi.php?user=" + flow .request .path .split ("/" )[2 ].split ("." )[0 ]
472487
473- return AddHeader(self)
474-
475- def run(self):
476- asyncio.set_event_loop(self.loop)
477- myaddon = self.getHeader()
478- opts = options.Options(listen_host="0.0.0.0", listen_port=25560)
479- pconf = proxy.config.ProxyConfig(opts)
480- self.m = DumpMaster(opts)
481- self.m.server = proxy.server.ProxyServer(pconf)
482- self.m.addons.add(myaddon)
483-
484- self.m.run()
485-
486- def stop(self):
487- self.m.shutdown()
488-
489- def join(self):
490- threading.Thread.join(self)
491- """
492-
493-
494- class minecraftProxy (QThread ):
495-
496- def __init__ (self , doSkinFix , doSoundFix , doCapeFix , loop ):
497- super ().__init__ ()
498- self .doSkinFix = doSkinFix
499- self .doCapeFix = doCapeFix
500- self .doSoundFix = doSoundFix
501- self .loop = loop
502-
503- def getHeader (self ):
504- class AddHeader :
505- def __init__ (self , parent ):
506- self .parent = parent
507-
508- def request (self , flow ):
509- if flow .request .pretty_host == "s3.amazonaws.com" :
510-
511- if self .parent .doSoundFix :
512- if flow .request .path .__contains__ ("MinecraftResources" ):
513- flow .request .host = "resourceproxy.pymcl.net"
514-
488+ if flow .request .pretty_host .__contains__ ("minecraft.net" ):
515489 if self .parent .doSkinFix :
516- if flow .request .path .__contains__ ("MinecraftSkins " ):
490+ if flow .request .path .__contains__ ("skin " ):
517491 flow .request .host = "resourceproxy.pymcl.net"
518492 flow .request .path = "/skinapi.php?user=" + flow .request .path .split ("/" )[2 ].split ("." )[0 ]
519493
520494 if self .parent .doCapeFix :
521- if flow .request .path .__contains__ ("MinecraftCloaks " ):
495+ if flow .request .path .__contains__ ("cloak " ):
522496 flow .request .host = "resourceproxy.pymcl.net"
523- flow .request .path = "/capeapi.php?user=" + flow .request .path .split ("/ " )[2 ]. split ( "." )[ 0 ]
497+ flow .request .path = "/capeapi.php?user=" + flow .request .path .split ("= " )[1 ]
524498
525499 return AddHeader (self )
526500
0 commit comments