-
Notifications
You must be signed in to change notification settings - Fork 0
/
minecraft-launcher-console.py
153 lines (121 loc) · 6.26 KB
/
minecraft-launcher-console.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
import sys
import minecraft_launcher_lib
import subprocess
from uuid import uuid1
from random_username.generate import generate_username
import threading
ru_l = ["Введите версию: ", "Введите ник: ", "(если его нету нечего не вводите): ", "Загрузчик модов('fabric', 'forge', 'quilt', 'нету'): ", "Сколько RAM выделить в Gygabyte: "]
en_l = ["Enter version: ", "Enter nickname: ", "(if you don't have one, don't enter anything): ", "Mod loader('fabric', 'forge', 'quilt', 'no'): ", "How much RAM to allocate in Gygabyte: "]
ua_l = ["Введіть версію: ", "Введіть нік: ", "(якщо його немає нічого не вводьте): ", "Завантажувач модів('fabric', 'forge', 'quilt', 'нету'): ", "Скільки RAM виділити в Gygabyte: "]
ru_l_s = ["Версия не найдена", "Fabric не поддерживает эту версию", "Forge не поддерживает эту версию", "JVM не может быть запущена", "Quilt не поддерживает эту версию", "RAM должно быть целым числом"]
en_l_s = ["Version not found", "Fabric does not support this version", "Forge does not support this version", "JVM can't start", "Quilt does not support this version", "RAM must be an integer"]
ua_l_s = ["Версія не знайдена", "Fabric не підтримує цю версію", "Forge не підтримує цю версію", "JVM не може бути запущена", "Quilt не підтримує цю версію", "RAM повинно бути цілим числом"]
l_l = []
l_l_s = []
fabric_loader_new = minecraft_launcher_lib.fabric.FabricLoader
quilt_loader_new = minecraft_launcher_lib.quilt.QuiltLoader
def printProgressBar(iteration, total, prefix='', suffix='', decimals=1, length=100, fill='█', printEnd="\r"):
percent = ("{0:." + str(decimals) + "f}").format(100 * (iteration / float(total)))
filledLength = int(length * iteration // total)
bar = fill * filledLength + '-' * (length - filledLength)
print('\r%s |%s| %s%% %s' % (prefix, bar, percent, suffix), end=printEnd)
if iteration == total:
print()
def maximum(max_value, value):
max_value[0] = value
minecraft_directory = ".mc" #minecraft_launcher_lib.utils.get_minecraft_directory()
lang = input("language 'ru', 'en', 'ua': ")
if lang == "ru":
l_l = ru_l
l_l_s = ru_l_s
if lang == "ua":
l_l = ua_l
l_l_s = ua_l_s
else:
l_l = en_l
l_l_s = en_l_s
versionc = input(l_l[0])
username = input(l_l[1])
uuidc = input("UUID" + l_l[2])
access_token = input("Access token" + str(l_l[2]) + ": ")
loader = input(l_l[3])
ram_for_java = input(l_l[4])
ffv = minecraft_launcher_lib.forge.find_forge_version(versionc)
print('=======================================================================================')
if ram_for_java == "":
print(l_l_s[3])
sys.exit()
if ram_for_java is int:
print(l_l_s[5])
sys.exit()
max_value = [0]
callback = {
"setStatus": lambda text: print(text),
"setProgress": lambda value: printProgressBar(value, max_value[0]),
"setMax": lambda value: maximum(max_value, value)
}
def install_mc(versionc, loader):
if loader == "forge":
if minecraft_launcher_lib.forge.supports_automatic_install(versionc):
print(l_l_s[2])
sys.exit()
else:
pass
minecraft_launcher_lib.forge.install_forge_version(minecraft_launcher_lib.forge.find_forge_version(versionc), minecraft_directory, callback=callback)
# support = minecraft_launcher_lib.forge.support_automatic_install(versionc)
if loader == "fabric":
if minecraft_launcher_lib.fabric.is_minecraft_version_supported(versionc):
pass
else:
print(l_l_s[1])
sys.exit()
minecraft_launcher_lib.fabric.install_fabric(str(versionc), minecraft_directory, callback=callback)
if loader == "quilt":
if minecraft_launcher_lib.quilt.is_minecraft_version_supported(versionc):
pass
else:
print(l_l_s[4])
sys.exit()
minecraft_launcher_lib.quilt.install_quilt(str(versionc), minecraft_directory, callback=callback)
else:
# if True:
# minecraft_launcher_lib.install.List()
#
# else:
# print(l_l_s[0])
# sys.exit()
minecraft_launcher_lib.install.install_minecraft_version(versionid=versionc,
minecraft_directory=minecraft_directory, callback=callback)
install_mc(versionc, loader)
def launch_mc(uuidc, username):
if username == "" or " ":
username = generate_username()[0]
if uuidc == "" or " ":
uuidc = uuid1()
options = {
'username': str(username),
'uuid': str(uuidc),
'token': str(access_token)
}
options["jvmArguments"] = ["-Xmx" + ram_for_java + "G", "-Xms128m"]
options["gameDirectory"] = minecraft_directory
if loader == "fabric":
pass
subprocess.call(minecraft_launcher_lib.command.get_minecraft_command(
version="fabric-loader-" + str(fabric_loader_new) + "-" + str(versionc), minecraft_directory=minecraft_directory,
options=options))
if loader == "forge":
subprocess.call(minecraft_launcher_lib.command.get_minecraft_command(
version=str(versionc) + "-forge-" + ffv.replace(versionc + "-", ""), minecraft_directory=minecraft_directory,
options=options))
if loader == "quilt":
subprocess.call(minecraft_launcher_lib.command.get_minecraft_command(
version="quilt-loader-" + str(quilt_loader_new) + "-" + str(versionc), minecraft_directory=minecraft_directory,
options=options))
else:
subprocess.call(minecraft_launcher_lib.command.get_minecraft_command(
version=str(versionc), minecraft_directory=minecraft_directory,
options=options))
threadlaunch_mc = threading.Thread(target=launch_mc, args=(uuidc, username))
threadlaunch_mc.start()
#-Xincgc