-
Notifications
You must be signed in to change notification settings - Fork 3
/
eclient.pyw
386 lines (323 loc) · 11.4 KB
/
eclient.pyw
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
import json
from tkinter import *
from tkinter import ttk
from ttkbootstrap import Style
from ttkbootstrap import *
from tkinter.ttk import Progressbar
from tkinter.messagebox import askquestion, showinfo
from tkinter import Label, Canvas, PhotoImage
import tkinter as tk
import sys, subprocess
import os
import time, requests
from threading import Thread
from tkvideo import tkvideo
import platform
import psutil
import platform
import base64
from ctypes import windll
import ctypes, getpass
windll.shcore.SetProcessDpiAwareness(1)
myappid = u'vpun215.eclient.idk.1.0' # arbitrary string
ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(myappid)
first=False
currn_dir = os.getcwd()
usr_accnt = getpass.getuser()
mc_dir = r"C:\\users\\{}\\AppData\\Roaming\\.minecraft".format(usr_accnt)
os_name = platform.platform()
def update():
os.system("python update.py")
sys.exit(0)
def con():
pass
top.destroy()
response = requests.get("https://api.github.com/repos/v-pun215/eClient/releases/latest")
lv = response.json()["name"]
if not lv == "1.5":
print("Update available!")
def get_size(bytes, suffix="B"):
#Found this on some website, i don't remember now. Used to get the total ram in GB.
"""
Scale bytes to its proper format
e.g:
1253656 => '1.20MB'
1253656678 => '1.17GB'
"""
factor = 1024
for unit in ["", "K", "M", "G", "T", "P"]:
if bytes < factor:
return f"{bytes:.2f}{unit}{suffix}"
bytes /= factor
svmem = psutil.virtual_memory()
if os_name.startswith("Linux"):
settings = {
"accessToken": None,
"clientToken": None,
"User-info" : [
{
"username": None,
"AUTH_TYPE": None,
"UUID": None
}
],
"PC-info" : [
{
"OS": platform.platform(),
"Total-Ram": f"{get_size(svmem.total)}",
}
],
"Minecraft-home" : mc_dir,
"selected-version": None,
"Fps-Boost" : False,
"Tor-Enabled" : False,
"setting-info" : [
{
"fps_boost_selected" : False,
"tor_enabled_selected" : False,
"allocated_ram_selected" : None,
}
],
"allocated_ram" : None,
"jvm-args": None,
"executablePath": "java",
"ramlimiterExceptionBypassed": False,
"ramlimiterExceptionBypassedSelected": False
#"executablePath": r"{}/runtime/jre-legacy/linux/jre-legacy/bin/java".format(mc_dir)
}
elif os_name.startswith("Windows"):
settings = {
"accessToken": None,
"clientToken": None,
"User-info" : [
{
"username": None,
"AUTH_TYPE": None,
"UUID": None
}
],
"PC-info" : [
{
"OS": platform.platform(),
"Total-Ram": f"{get_size(svmem.total)}",
}
],
"Minecraft-home" : mc_dir,
"selected-version": None,
"Fps-Boost" : False,
"Tor-Enabled" : False,
"setting-info" : [
{
"fps_boost_selected" : False,
"tor_enabled_selected" : False,
"allocated_ram_selected" : 3000
}
],
"allocated_ram" : 3000,
"jvm-args": None,
"executablePath": r"C:\\Program Files\\BellSoft\\LibericaJDK-17\\bin\\java",
"ramlimiterExceptionBypassed": False,
"ramlimiterExceptionBypassedSelected": False,
"verbose": False
#"executablePath": r"{}/runtime/jre-legacy/windows/jre-legacy/bin/java".format(mc_dir)
}
if not os.path.exists(r"{}/settings.json".format(currn_dir)):
with open("settings.json", "w") as js_set:
json.dump(settings, js_set, indent=4)
js_set.close()
first = True
else:
pass
with open("settings.json", "r") as js_read:
s = js_read.read()
s = s.replace('\t','') #Trailing commas in dict cause file read problems, these lines will fix it.
s = s.replace('\n','')
s = s.replace(',}','}')
s = s.replace(',]',']')
data = json.loads(s)
#print(json.dumps(data, indent=4,))
os_name = data["PC-info"][0]["OS"]
username = data["User-info"][0]["username"]
mc_home = data["Minecraft-home"]
fps_boost = data["Fps-Boost"]
tor_enabled = data["Tor-Enabled"]
fps_boost_selected = data["setting-info"][0]["fps_boost_selected"]
tor_enabled_selected = data["setting-info"][0]["tor_enabled_selected"]
ramlimiterExceptionBypassed = data["ramlimiterExceptionBypassed"]
ramlimiterExceptionBypassedSelected = data["ramlimiterExceptionBypassedSelected"]
verbose = data["verbose"]
style = Style(theme="flatly")
isit = None
if verbose == True:
isit=False
elif verbose == False:
isit=True
root = style.master
t2 = Thread(target=lambda: subprocess.call("main.bat", shell=isit))
f = open("first.txt", "r")
fr = f.read()
if fr == "no":
t2.start()
root.withdraw()
root.destroy()
else:
pass
root.title("eClient Loader")
root.iconbitmap("mc.ico")
root.geometry("761x403+140+50")
Tk_Width = 761
Tk_Height = 403
x_Left = int(root.winfo_screenwidth()/2 - Tk_Width/2)
y_Top = int(root.winfo_screenheight()/2 - Tk_Height/2)
root.geometry(f"+{x_Left}+{y_Top}")
root.resizable(False, False)
canvas = Canvas(
root,
bg = "#3a3a3a",
height = 768,
width = 1024,
bd = 0,
highlightthickness = 0,
relief = "ridge")
canvas.place(x = 0, y = 0)
background_img = PhotoImage(file = "img/mc1.png")
background = canvas.create_image(
380.5,201.5,
image=background_img)
'''if not lv == "v1.7":
print("Update available!")
top= Toplevel(root)
top.geometry("450x200")
top.title("Update Available: {}".format(lv))
Label(top, text= "Update Available", font=("SF Pro Display", 25,'bold')).place(x=60,y=20)
Label(top, text= "Version {} is available. Would you like to download it?".format(lv), font=("SF Pro Display", 11)).place(x=10,y=90)
Button(top,text = "Yes", bootstyle="success-outline", command=update).place(x=150, y=140)
Button(top,text = "No", bootstyle="danger-outline", command=con).place(x=250, y=140)
'''
if not os.path.exists(r"{}/settings.json".format(currn_dir)):
c1 = Label(
text = "Generating settings.....",
font = ("SF Pro Display", int(13.0)),
bg="#3a3a3a",
fg="cyan1")
first=True
else:
c1 = Label(
text = "Reading settings.....",
font = ("SF Pro Display", int(13.0)),
bg="#3a3a3a",
fg="cyan1")
c1.place(x=248, y=350)
def save(root):
'''Saves the minecraft home dir path, which is entered.'''
global mc_home
mc_home = root.entry0.get()
data["Minecraft-home"] = mc_home
with open("settings.json", "w") as js_set:
json.dump(data, js_set, indent=4)
js_set.close()
def open_popup():
top= Toplevel(root)
top.geometry("800x550")
top.title("Welcome to eClient!")
Label(top, text= "Welcome to eClient!", font=("SF Pro Display", 25,'bold')).place(x=25,y=20)
Label(top, text= "If you have any issues, fell free to report them at eClient's ", font=("SF Pro Display", 11)).place(x=10,y=90)
Label(top, text= "GitHub.", font=("SF Pro Display", 11)).place(x=10,y=110)
Label(top, text= "Enter Minecraft Directory:", font=("SF Pro Display", 20, 'bold')).place(x=10,y=110)
root.entry0 = Entry(
root.window_s,
bd = 0,
bg = "#c4c4c4",
font = ("SF Pro Display", 20),
highlightthickness = 0)
root.entry0.insert(0, f"{mc_home}")
root.curn_path = root.entry0.get()
root.entry0.place(
x = 10.0, y = 147.0,
width = 547.0,
height = 62)
root.b7 = Button(
root.canvas5,
text="Save",
command = root.save,
bootstyle="success-outline")
root.b7.place(
x = 790, y = 147,
width = 119,
height = 60)
#root.after(10000)
'''if first == True:
open_popup()'''
root.after(10000, lambda: c1.configure(text="Getting everything ready...."))
canvas.create_text(
400, 200,
text = "eClient Launcher",
fill = "black",
font = ("SF Pro Display", int(26.0), "bold"))
#l1 = Label(root)
#l1.pack()
#v1 = tkvideo(r"{}/intro_gif.mp4".format(currn_dir), l1, loop=1, size=(640,360))
pb1 = Progressbar(root, value=0, style='info.Horizontal.TProgressbar', length=300, mode="indeterminate")
pb1.place(x=250, y=400)
def open1():
CREATE_NO_WINDOW = 0x08000000
subprocess.call("main.bat", creationflags=CREATE_NO_WINDOW)
t1 = Thread(target=lambda: os.system("./main.sh"))
t2 = Thread(target=open1)
#t3 = Thread(target=lambda: v1.play())
def checksettings():
'''A small hack to check settings and start the launcher accordingly.'''
if tor_enabled and tor_enabled_selected == True:
#time.sleep(20.0)
#pb1.stop()
if os_name.startswith("Linux"):
res2 = askquestion(title="Grant permission", message="Grant permission to permform administrative task?")
if res2 == "yes":
showinfo(title="Ok", message="Please enter your password in the next window to start tor")
os.system("gksudo service tor start")
elif res2 == "no":
showinfo(title="Abort", message="Tor cannot start without administrative privileges.")
sys.exit(0)
with open("main.sh", "w") as f:
f.write("torsocks python3 main.py\n")
f.close()
os.system("chmod 700 main.sh")
root.after(23000, lambda:t1.start())
elif os_name.startswith("Windows"):
with open("main.bat", "w") as f:
f.write("taskkill /f /im python.exe\n") #frees up cpu and memory
f.write("yeah.cmd")
f.close()
root.after(23000, lambda: t2.start())
else:
#time.sleep(20.0)
#pb1.stop()
if os_name.startswith("Linux"):
with open("main.sh", "w") as f:
f.write("python3 main.py\n")
f.close()
os.system("chmod 700 main.sh")
root.after(23000, lambda: t1.start())
elif os_name.startswith("Windows"):
with open("main.bat", "w") as f:
f.write("taskkill /f /im python.exe\n") #frees up cpu and memory
f.write("yeah.cmd")
f.close()
root.after(23000, lambda: t2.start())
#root.after(1000, lambda:t3.start())
#root.after(2000, lambda:pb1.start())
window_running = True
pb1.start()
checksettings()
#root.after(20000, lambda: pb1.stop())
f = open("first.txt", "w")
f.write("no")
f.close()
root.after(24000, lambda: root.withdraw())
root.after(30000, lambda: root.destroy())
if t1.is_alive() or t2.is_alive():
pb1.stop()
try:
root.mainloop()
except KeyboardInterrupt:
print("Program Exited")