implement working 3rd party launcher detection

This commit is contained in:
Obie Hinojosa 2025-05-28 21:20:26 -05:00
parent b727633f74
commit 0e8e4973c5

View File

@ -120,16 +120,14 @@ def check_if_exists_and_delete_file(filepath):
else: else:
pass pass
global detectedlauncher
detectedlauncher = "null"
def check_for_launcher_files(filepath, launchername): def check_for_launcher_files(filepath, launchername):
#checks for evidence of 3rd party launchers and sets a variable flag if a launcher is installed #checks for evidence of 3rd party launchers and sets a variable flag if a launcher is installed
if os.path.exists(filepath): if os.path.exists(filepath):
print("[INFO]: Detected Minecraft launcher: " + str(launchername)) global detectedlauncher
detectedlauncher = str(launchername) detectedlauncher = str(launchername)
print("[INFO]: Detected Minecraft launcher: " + str(launchername))
else: else:
raise customerror("[ERR!]: File not detected.") print("[DBUG]: " + launchername + " not detected.")
# --------------------the real shit!------------------------ # --------------------the real shit!------------------------
@ -144,18 +142,19 @@ global modfolder
# `global` sets these variables to exist outside of the scope of these specific `if` statements. # `global` sets these variables to exist outside of the scope of these specific `if` statements.
if platform.system() == "Linux": if platform.system() == "Linux":
print("Operating system detected: Linux") print("[INFO]: Operating system detected: Linux")
try: detectedlauncher = "OfficialLauncher"
check_for_launcher_files(str(Path.cwd()) + "/.local/share/PrismLauncher", "PrismLauncherPackage") check_for_launcher_files(str(Path.cwd()) + "/.local/share/PrismLauncher", "PrismLauncherPackage")
check_for_launcher_files(str(Path.cwd()) + "/.var/app/org.prismlauncher.Prism.Launcher", "PrismLauncherFlatpak") check_for_launcher_files(str(Path.cwd()) + "/.var/app/org.prismlauncher.Prism.Launcher", "PrismLauncherFlatpak")
except customerror as e:
pass if detectedlauncher == "OfficialLauncher":
print("[INFO]: No 3rd party launchers detected, falling back to default official launcher directories")
os.chdir(".minecraft") os.chdir(".minecraft")
mcfolder = str(Path.cwd()) mcfolder = str(Path.cwd())
modfolder = mcfolder + '/mods' modfolder = mcfolder + '/mods'
print("Changed current working directory to '" + str(mcfolder) + "'") print("[INFO]: Changed current working directory to '" + str(mcfolder) + "'")
time.sleep(1) time.sleep(1)
print() print()
@ -204,7 +203,7 @@ except:
extract_tar('mods.tar.gz', 'mods') extract_tar('mods.tar.gz', 'mods')
# ('tarfile', 'directory to extract to') # ('tarfile', 'directory to extract to')
print(); print("sigma!") print(""); print("sigma!")
print("all done!") print("all done!")
print("This window will exit and close in ten seconds. :)") print("This window will exit and close in ten seconds. :)")
time.sleep(9) time.sleep(9)