|
14 | 14 | import subprocess |
15 | 15 | import zipfile |
16 | 16 | from pathlib import Path |
17 | | -from typing import Optional |
| 17 | +from typing import Optional, Tuple |
18 | 18 |
|
19 | 19 | import click |
20 | 20 | import minecraft_launcher_lib as mll |
@@ -253,20 +253,20 @@ def install_fabric(mc_version: str, mc_dir: str) -> str: |
253 | 253 | str: The Fabric version id. Formatted as `fabric-loader-{fabric_version}-{game_version}`. |
254 | 254 | """ |
255 | 255 | meta_placeholder = "https://meta.fabricmc.net/v2/versions/loader/{}/{}/profile/zip" |
256 | | - pack_toml_url = f"https://raw.githubusercontent.com/Fabulously-Optimized/Fabulously-Optimized/main/Packwiz/{mc_version}/pack.toml" |
| 256 | + pack_toml_url = convert_version(mc_version) |
257 | 257 |
|
258 | | - if (response := requests.get(pack_toml_url)).status_code == 200: |
| 258 | + # if (response := requests.get(pack_toml_url)).status_code == 200: |
| 259 | + response = requests.get(pack_toml_url) |
| 260 | + pack_info = toml.parse(response.text) |
| 261 | + game_version = pack_info["versions"]["minecraft"] |
| 262 | + fabric_version = pack_info["versions"]["fabric"] |
| 263 | + meta_url = meta_placeholder.format(game_version, fabric_version) |
259 | 264 |
|
260 | | - pack_info: dict = toml.loads(response.text) |
261 | | - game_version = pack_info.get("versions", {}).get("minecraft") |
262 | | - fabric_version = pack_info.get("versions", {}).get("fabric") |
263 | | - meta_url = meta_placeholder.format(game_version, fabric_version) |
264 | | - |
265 | | - if (response := requests.get(meta_url)).status_code == 200: |
266 | | - with zipfile.ZipFile(io.BytesIO(response.content)) as archive: |
267 | | - version_id = f"fabric-loader-{fabric_version}-{game_version}" |
268 | | - path = str(Path(mc_dir).resolve() / "versions") |
269 | | - archive.extractall(path) |
| 265 | + response = requests.get(meta_url) |
| 266 | + version_id = f"fabric-loader-{fabric_version}-{game_version}" |
| 267 | + with zipfile.ZipFile(io.BytesIO(response.content)) as archive: |
| 268 | + path = str(Path(mc_dir).resolve() / "versions") |
| 269 | + archive.extractall(path) |
270 | 270 |
|
271 | 271 | return version_id |
272 | 272 |
|
@@ -312,7 +312,7 @@ def install_pack( |
312 | 312 | logger.debug("Installing the pack now.") |
313 | 313 | os.chdir(mc_dir) |
314 | 314 | os.makedirs(f"{get_dir()}/", exist_ok=True) |
315 | | - pack_toml = f"https://raw.githubusercontent.com/Fabulously-Optimized/Fabulously-Optimized/main/Packwiz/{mc_version}/pack.toml" |
| 315 | + pack_toml = convert_version(mc_version) |
316 | 316 | try: |
317 | 317 | ran = command( |
318 | 318 | f"{get_java(java_ver)} -jar {packwiz_installer_bootstrap} {pack_toml}" |
@@ -380,7 +380,10 @@ def get_pack_mc_versions() -> dict: |
380 | 380 | # In this case, fall back to a local file since in the latter you'll likely have the whole repo cloned. |
381 | 381 | # For this to work, you need to be in the root directory of the repository running this, otherwise the files will not be found. |
382 | 382 | logger.warning("GitHub failed, falling back to local...") |
383 | | - local_path = Path("vanilla_installer/assets").resolve() / "versions.json" |
| 383 | + try: |
| 384 | + local_path = Path("vanilla_installer/assets").resolve() / "versions.json" |
| 385 | + except: |
| 386 | + local_path = Path("assets").resolve() / "versions.json" |
384 | 387 | response = json.loads(local_path.read_bytes()) |
385 | 388 |
|
386 | 389 | return_value = dict(response) |
|
0 commit comments