windows fixes
This commit is contained in:
@@ -13,6 +13,7 @@ MODPACK_RELEASES_URL = "https://git.233hfd.com/api/v1/repos/joey/FishPogPixelmon
|
||||
MULTIMC_DOWNLOAD_URL_WINDOWS = "https://files.multimc.org/downloads/mmc-develop-win32.zip"
|
||||
MULTIMC_PARENT_DIR = ""
|
||||
MULTIMC_DIR = ""
|
||||
INSTANCE_DIR = ""
|
||||
|
||||
if OS == "darwin":
|
||||
cprint("no support for macos yet", "red")
|
||||
@@ -21,12 +22,12 @@ if OS == "darwin":
|
||||
if OS == "linux":
|
||||
MULTIMC_PARENT_DIR = f"{os.getenv('HOME')}/.local/share"
|
||||
MULTIMC_DIR = f"{MULTIMC_PARENT_DIR}/multimc"
|
||||
INSTANCE_DIR = f"{MULTIMC_DIR}/instances/FishPogPixelmon"
|
||||
|
||||
if OS == "windows":
|
||||
MULTIMC_PARENT_DIR = f"{os.getenv('APPDATA')}/FishPog"
|
||||
MULTIMC_DIR = f"{MULTIMC_PARENT_DIR}/MultiMC"
|
||||
|
||||
INSTANCE_DIR = f"{MULTIMC_DIR}/instances/FishPogPixelmon"
|
||||
if OS == "win32":
|
||||
MULTIMC_PARENT_DIR = f"{os.getenv('APPDATA')}\\FishPog"
|
||||
MULTIMC_DIR = f"{MULTIMC_PARENT_DIR}\\MultiMC"
|
||||
INSTANCE_DIR = f"{MULTIMC_DIR}\\instances\\FishPogPixelmon"
|
||||
|
||||
|
||||
# main
|
||||
@@ -44,7 +45,7 @@ def run_mmc():
|
||||
cprint("ready to go! starting multimc!", "green")
|
||||
os.chdir(MULTIMC_DIR)
|
||||
|
||||
if OS == "windows":
|
||||
if OS == "win32":
|
||||
subprocess.Popen(["MultiMC.exe"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
||||
|
||||
if OS == "linux":
|
||||
@@ -55,7 +56,7 @@ def run_mmc():
|
||||
def mods():
|
||||
os.chdir(INSTANCE_DIR)
|
||||
|
||||
if not os.path.exists(f"{INSTANCE_DIR}/downloader.zip"):
|
||||
if not os.path.exists(os.path.join(INSTANCE_DIR, "downloader.zip")):
|
||||
cprint("downloader.zip not found - downloading", "yellow")
|
||||
r = requests.get(MOD_DOWNLOADER_URL, allow_redirects=True)
|
||||
open("downloader.zip", "wb").write(r.content)
|
||||
@@ -63,11 +64,15 @@ def mods():
|
||||
cprint("downloading mods. this may take a while, please wait.", "green")
|
||||
subprocess.run(["python", "downloader.zip", "manifest.json"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
||||
|
||||
for file in glob.glob(f"{INSTANCE_DIR}/mods/*"):
|
||||
name = os.path.basename(file)
|
||||
shutil.move(file, os.path.join(f"{INSTANCE_DIR}/.minecraft/mods", name))
|
||||
for file in glob.glob(os.path.join(INSTANCE_DIR, ".minecraft", "mods", "*")):
|
||||
if os.path.basename(file) == "OptiFine_1.16.5_HD_U_G8.jar":
|
||||
continue
|
||||
os.remove(file)
|
||||
|
||||
shutil.rmtree(f"{INSTANCE_DIR}/mods")
|
||||
for file in glob.glob(os.path.join(INSTANCE_DIR, "mods", "*")):
|
||||
shutil.move(file, os.path.join(INSTANCE_DIR, ".minecraft", "mods", os.path.basename(file)))
|
||||
|
||||
shutil.rmtree(os.path.join(INSTANCE_DIR, "mods"))
|
||||
|
||||
cprint("mods downloaded successfully", "green")
|
||||
|
||||
@@ -97,7 +102,7 @@ def instance():
|
||||
|
||||
|
||||
def download_instance(release: dict[str, Any]):
|
||||
os.makedirs(f"{INSTANCE_DIR}/.minecraft", exist_ok=True)
|
||||
os.makedirs(os.path.join(INSTANCE_DIR, ".minecraft"), exist_ok=True)
|
||||
|
||||
TMP = tempfile.mkdtemp()
|
||||
os.chdir(TMP)
|
||||
@@ -108,24 +113,35 @@ def download_instance(release: dict[str, Any]):
|
||||
shutil.unpack_archive("instance.zip", ".")
|
||||
os.remove("instance.zip")
|
||||
|
||||
for file in glob.glob(f"{TMP}/overrides/*"):
|
||||
if file == f"{TMP}/overrides/options.txt" and os.path.exists(f"{INSTANCE_DIR}/.minecraft/options.txt"):
|
||||
for file in glob.glob(os.path.join(TMP, "overrides", "*")):
|
||||
if file == os.path.join(TMP, "overrides", "options.txt") and os.path.exists(
|
||||
os.path.join(INSTANCE_DIR, ".minecraft", "options.txt")
|
||||
):
|
||||
continue
|
||||
name = os.path.basename(file)
|
||||
shutil.move(file, os.path.join(f"{INSTANCE_DIR}/.minecraft", name))
|
||||
if os.path.exists(os.path.join(INSTANCE_DIR, ".minecraft", os.path.basename(file))):
|
||||
if os.path.isdir(os.path.join(INSTANCE_DIR, ".minecraft", os.path.basename(file))):
|
||||
shutil.rmtree(os.path.join(INSTANCE_DIR, ".minecraft", os.path.basename(file)))
|
||||
else:
|
||||
os.remove(os.path.join(INSTANCE_DIR, ".minecraft", os.path.basename(file)))
|
||||
shutil.move(file, os.path.join(INSTANCE_DIR, ".minecraft", os.path.basename(file)))
|
||||
|
||||
shutil.rmtree(f"{TMP}/overrides")
|
||||
shutil.rmtree(os.path.join(TMP, "overrides"))
|
||||
|
||||
for file in glob.glob(f"{TMP}/*"):
|
||||
name = os.path.basename(file)
|
||||
shutil.move(file, os.path.join(INSTANCE_DIR, name))
|
||||
|
||||
shutil.rmtree(TMP)
|
||||
for file in glob.glob(os.path.join(TMP, "*")):
|
||||
if os.path.exists(os.path.join(INSTANCE_DIR, os.path.basename(file))):
|
||||
if os.path.isdir(os.path.join(INSTANCE_DIR, os.path.basename(file))):
|
||||
shutil.rmtree(os.path.join(INSTANCE_DIR, os.path.basename(file)))
|
||||
else:
|
||||
os.remove(os.path.join(INSTANCE_DIR, os.path.basename(file)))
|
||||
shutil.move(file, os.path.join(INSTANCE_DIR, os.path.basename(file)))
|
||||
|
||||
os.chdir(INSTANCE_DIR)
|
||||
shutil.copy(
|
||||
os.path.join(INSTANCE_DIR, "fishpog_pixelmon.png"), os.path.join(MULTIMC_DIR, "icons", "fishpog_pixelmon.png")
|
||||
)
|
||||
if not os.path.exists(os.path.join(MULTIMC_DIR, "icons", "fishpog_pixelmon.png")):
|
||||
os.makedirs(os.path.join(MULTIMC_DIR, "icons"), exist_ok=True)
|
||||
shutil.copy(
|
||||
os.path.join(INSTANCE_DIR, "fishpog_pixelmon.png"),
|
||||
os.path.join(MULTIMC_DIR, "icons", "fishpog_pixelmon.png"),
|
||||
)
|
||||
|
||||
f = open(".version", "w")
|
||||
f.write(release["tag_name"])
|
||||
@@ -136,7 +152,7 @@ def multimc():
|
||||
if os.path.exists(MULTIMC_DIR):
|
||||
return
|
||||
|
||||
if OS != "windows":
|
||||
if OS != "win32":
|
||||
cprint("multimc is not installed - please install it", "red")
|
||||
exit(1)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user