-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.py
59 lines (42 loc) · 1.41 KB
/
main.py
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
import os
import shutil
import json
from termcolor import colored
import colorama
import getpass
config = []
colorama.init()
print("Loading Config...")
with open('config.json') as i:
config = json.load(i)
print(f"Loaded Config ({len(config)} items)")
print(f"\nNow detecting files...")
#os.rename()
files = []
for r, d, f in os.walk("./mods"):
for file in f:
if '.jar' in file:
files.append(os.path.join(r, file))
print(colored(f"[SUCCESS] Detected {file}","green"))
else:
print(colored(f"[ERROR] {file} is not a mod! All mods must be a java file (.jar)","red"))
if files == []:
print(colored(f"[WARN] No mods found in the mods folder. (Program Exited)","yellow"))
exit
print(f"Detected {len(files)} files!")
print("Copying files...\n")
success = []
fail = []
for file in files:
try:
fl = file.split('./mods\\')
fl = "".join(fl)
os.rename(file,f"C:\\Users\\{getpass.getuser()}\\AppData\\{config['MinecraftDirectory']}\\{fl}")
print(colored(f"[SUCCESS] Copied {fl} over","green"))
success.append(fl)
except:
fl = file.split('./mods\\')
fl = "".join(fl)
print(colored(f"[ERROR] Failed to copy {fl}","red"))
fail.append(fl)
print(f"\nFinished!\n\nCopied {len(success)} files\nFailed on {len(fail)} files")