add custom exception and barebones error handling to launcher detection

This commit is contained in:
Obie Hinojosa 2025-05-28 20:06:02 -05:00
parent 7ce1216f71
commit b727633f74

View File

@ -29,6 +29,11 @@ from pathlib import Path
# as far as i can tell, i wanted to add an "option" to the function that toggled the warning m-
# -essage, so i dont have to use all this space here defining functions i dont really need.
class customerror(Exception):
def __init__(self, message):
self.message = message
super().__init__(self.message)
def delete_directory_warn(directory_to_delete, warn=False):
#this defines a function to delete a directory (no shit)
try:
@ -115,13 +120,16 @@ def check_if_exists_and_delete_file(filepath):
else:
pass
global detectedlauncher
detectedlauncher = "null"
def check_for_launcher_files(filepath, launchername):
#checks for evidence of 3rd party launchers and sets a variable flag if a launcher is installed
if os.path.exists(filepath):
print("Alternative Minecraft launcher detected: " + str(launchername))
print("[INFO]: Detected Minecraft launcher: " + str(launchername))
detectedlauncher = str(launchername)
else:
pass
raise customerror("[ERR!]: File not detected.")
# --------------------the real shit!------------------------
@ -138,8 +146,11 @@ global modfolder
if platform.system() == "Linux":
print("Operating system detected: Linux")
try:
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()) + "/.local/share/PrismLauncher/prismlauncher.cfg", "PrismLauncherPackage")
except customerror as e:
pass
os.chdir(".minecraft")
mcfolder = str(Path.cwd())