-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.py
More file actions
executable file
·74 lines (58 loc) · 2.47 KB
/
Copy pathinstall.py
File metadata and controls
executable file
·74 lines (58 loc) · 2.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/usr/bin/env python3
import os
import shutil
import logging
from pathlib import Path
from utils import DIST_DIR
def run_install(build_files):
"""
Takes a list of Path objects (ZIP files) and deploys them to the appropriate Minecraft instance folders based on their filename suffixes.
"""
if not build_files:
logging.warning("No build files provided for installation.")
return
instance_path = os.getenv("INSTANCE_PATH")
WORLD_NAME = os.getenv("WORLD_NAME", "New World") # Default to standard name
if not instance_path:
logging.error("INSTANCE_PATH not defined in .env. Skipping installation.")
return
# Define standard Minecraft destination paths
datapack_dir = Path(instance_path) / "saves" / WORLD_NAME / "datapacks"
resource_dir = Path(instance_path) / "resourcepacks"
mods_dir = Path(instance_path) / "mods"
try:
# Ensure destination directories exist
datapack_dir.mkdir(parents=True, exist_ok=True)
resource_dir.mkdir(parents=True, exist_ok=True)
for file_path in build_files:
filename = file_path.name
# Determine destination based on the file suffix logic from build.py
if filename.lower().endswith("-dp.zip"):
dest = datapack_dir / filename
shutil.copy2(file_path, dest)
logging.info(f"Installed Datapack: {filename}")
elif filename.lower().endswith("-rp.zip"):
dest = resource_dir / filename
shutil.copy2(file_path, dest)
logging.info(f"Installed Resourcepack: {filename}")
elif filename.lower().endswith("-mod.jar"):
dest = mods_dir / filename
shutil.copy2(file_path, dest)
logging.info(f"Installed Mod: {filename}")
else:
# Copy to all as a fallback.
shutil.copy2(file_path, datapack_dir / filename)
shutil.copy2(file_path, resource_dir / filename)
shutil.copy2(file_path, mods_dir / filename)
logging.warning(
f"Installed unrecognized pack: {filename} (to all folders)"
)
except Exception as e:
logging.error(f"Failed to install files: {e}")
return None
return True
if __name__ == "__main__":
for d in DIST_DIR.iterdir():
if d.is_file():
run_install([d])
logging.info("Installation process complete.")