@@ -4,6 +4,7 @@ from tkinter.scrolledtext import ScrolledText
44from tkinter import messagebox , filedialog
55from PIL import ImageTk , Image
66from urllib .request import urlretrieve
7+ from urllib .error import *
78from zipfile import ZipFile
89import os
910import json
@@ -20,7 +21,7 @@ import atexit
2021import webbrowser
2122import configparser
2223
23- VERSION = "0.7 "
24+ VERSION = "0.8 "
2425
2526class AboutPage (Frame ):
2627
@@ -79,8 +80,13 @@ class App:
7980 os .mkdir ("assets" )
8081 if not os .path .isdir ("temp" ):
8182 os .mkdir ("temp" )
82- urlretrieve (url = "https://raw.github.com/SpacePython12/AP-Launcher/main/assets/background.png" , filename = "assets/background.png" )
83- urlretrieve (url = "https://raw.github.com/SpacePython12/AP-Launcher/main/assets/icon.ico" , filename = "assets/icon.ico" )
83+ try :
84+ urlretrieve (url = "https://raw.github.com/SpacePython12/AP-Launcher/main/assets/background.png" , filename = "assets/background.png" )
85+ urlretrieve (url = "https://raw.github.com/SpacePython12/AP-Launcher/main/assets/icon.ico" , filename = "assets/icon.ico" )
86+ except HTTPError :
87+ pass
88+ except URLError :
89+ pass
8490 self .background = ImageTk .PhotoImage (Image .open ("assets/background.png" ))
8591 self .icon = ImageTk .PhotoImage (file = "assets/icon.ico" )
8692 self .win .iconphoto (True , self .icon )
@@ -341,7 +347,7 @@ class App:
341347 stdin = subprocess .DEVNULL
342348 )
343349 while sb .poll () is None :
344- line = sb .stdout .readline ().decode ("unicode-escape " ).rstrip ()
350+ line = sb .stdout .readline ().decode ("ISO-8859-1 " ).rstrip ()
345351 if not line == "" :
346352 self .update_procscreen (line )
347353 self .playbutton .config (state = "normal" , text = "\n Play\n " )
@@ -391,9 +397,11 @@ class App:
391397 with ZipFile (open (filepath , "rb" )) as zf :
392398 folders = list (set ([os .path .dirname (x ).split ("/" )[0 ] for x in zf .namelist ()]))
393399 folders .remove ("indexes" )
400+ folders .remove ("natives" )
401+ folders .remove ("" )
402+ infofile = zf .open ("manifest.json" )
403+ info = json .load (infofile )
394404 for folder in folders :
395- infofile = zf .open (f"{ folder } /manifest.json" )
396- info = json .load (infofile )
397405 if os .path .isdir (os .path .join (self .minecraftdir , "versions" , folder )):
398406 if not messagebox .askyesno ("Confirm" , "There is already a version by this name. Would you like to overwrite it?" ):
399407 zf .close ()
@@ -402,13 +410,16 @@ class App:
402410 shutil .rmtree (os .path .join (self .minecraftdir , "versions" , folder ))
403411 os .mkdir (os .path .join (self .minecraftdir , "versions" , folder ))
404412 for file_ in zf .namelist ():
405- if file_ .startswith (folder ) and not file_ . endswith ( "manifest.json" ) :
413+ if file_ .startswith (folder ):
406414 zf .extract (file_ , os .path .join (self .minecraftdir , "versions" ))
407415 info ["profile" ][list (info ["profile" ].keys ())[0 ]]["created" ] = datetime .datetime .now ().strftime ("%Y-%m-%dT%H:%M:%S.%f" )[:- 3 ] + "Z"
408416 self .accounts ["profiles" ][list (info ["profile" ].keys ())[0 ]] = info ["profile" ][list (info ["profile" ].keys ())[0 ]]
409417 for file_ in zf .namelist ():
410418 if file_ .startswith ("indexes" ):
411419 zf .extract (file_ , os .path .join (self .minecraftdir , "assets" ))
420+ for file_ in zf .namelist ():
421+ if file_ .startswith ("natives" ):
422+ zf .extract (file_ , os .path .join (self .minecraftdir , "bin" ))
412423 messagebox .showinfo ("Success" , "The version was successfully imported. Restart AP Launcher to see changes." )
413424 zf .close ()
414425 return
@@ -432,6 +443,10 @@ class App:
432443 if not os .path .isdir ("update" ):
433444 os .mkdir ("update" )
434445 urlretrieve (url = durl , filename = "update/update.zip" )
446+ if os .path .isfile ("update/APLauncher.exe" ):
447+ os .remove ("update/APLauncher.exe" )
448+ if os .path .isfile ("update/launcher_process.exe" ):
449+ os .remove ("update/launcher_process.exe" )
435450 with ZipFile (open ("update/update.zip" , "rb" )) as zf :
436451 zf .extractall ("update" )
437452 zf .close ()
@@ -447,6 +462,10 @@ class App:
447462 return False
448463
449464 def run_updater (self ):
465+ if os .path .isfile ("APLauncher.exe" ):
466+ os .remove ("APLauncher.exe" )
467+ if os .path .isfile ("launcher_process.exe" ):
468+ os .remove ("launcher_process.exe" )
450469 shutil .move ("update/APLauncher.exe" , "APLauncher.exe" )
451470 shutil .move ("update/launcher_process.exe" , "launcher_process.exe" )
452471
0 commit comments