-
Notifications
You must be signed in to change notification settings - Fork 0
/
mc_mod_installer.py
79 lines (59 loc) · 2.24 KB
/
mc_mod_installer.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import os
import sys
import zipfile
import urllib
import urllib.request
import colorama
from colorama import Fore, Back, Style
import pyunpack
import progressbar
def installMods():
global pbar
pbar = None
def show_progress(block_num, block_size, total_size):
global pbar
if pbar is None:
pbar = progressbar.ProgressBar(maxval=total_size)
total_size = total_size
downloaded = block_num * block_size
if downloaded < total_size:
pbar.update(downloaded)
else:
pbar.finish()
pbar = None
colorama.init()
print("Grüße von 1Day2Die")
input("Drücke -Enter- um das Modpack zu installieren")
home = os.path.join(os.path.expanduser("~"), "AppData", "Roaming", ".minecraft", "")
n = 0
old_mods_folder_name = "old_mods" + str(n)
while os.path.exists(os.path.join(home, str(old_mods_folder_name))):
n += 1
old_mods_folder_name = "old_mods" + str(n)
#print(n)
if os.path.exists(os.path.join(home, "mods")):
os.rename(os.path.join(home, "mods"), os.path.join(home, str(old_mods_folder_name)))
os.mkdir(os.path.join(home, "mods"))
try:
print(Fore.MAGENTA + "Downloading Modpack")
urllib.request.urlretrieve("http://downloads.hafuga.de/minecraft/mods.zip", os.path.join(home, "mods", "") + "mods.zip", show_progress)
except Exception as e: print(e)
try:
pyunpack.Archive(os.path.join(home, "mods", "") + "mods.zip").extractall(os.path.join(home, "mods"))
except Exception as e: print(e)
os.remove(os.path.join(home, "mods", "") + "mods.zip")
print("")
print(Fore.GREEN + "Mods sind Installiert!")
print(Fore.CYAN + "Deine alten Mods findest du unter")
print(home + old_mods_folder_name)
print("")
print("")
print(Back.GREEN, Fore.BLACK + "Den Server erreichst du unter:")
print("games.oesterland.de:25595")
print(Style.RESET_ALL)
input("Das Fenster kann geschlossen werden")
else:
print(Fore.RED + "Spigot Installation nicht gefunden unter " + home)
print("Kein 'mods' Ordner vorhanden?")
print(Style.RESET_ALL)
installMods()