-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
LEB-ToolBox.py
1750 lines (1654 loc) · 68.5 KB
/
LEB-ToolBox.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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import os
import requests
import webbrowser
import shutil
from time import sleep
from zipfile import ZipFile
import os.path
import platform
from sys import exit
def stringTF(start,end,s):
return s[s.find(start)+len(start):s.rfind(end)]
def cls():
os.system('cls'
if os.name=='nt'
else 'clear')
################
### Load ###
################
W = '\033[0m' # white
R = '\033[31m' # red
G = '\033[32m' # green
O = '\033[33m' # orange
B = '\033[36m' # blue
P = '\033[35m' # purple
E = '\033[30;1m' #gray
Y = '\033[0;33m' #yellow
def colorize(string):
string = string.replace("$W",W)
string = string.replace("$R",R)
string = string.replace("$G",G)
string = string.replace("$O",O)
string = string.replace("$B",B)
string = string.replace("$P",P)
string = string.replace("$E",E)
string = string.replace("$Y",Y)
string = string.replace(r"\n","\n")
return string
####### PROGRAM VERSION #######
cnt_program = 1.6
#indev 1.6
ver_program = G+"v"+str(cnt_program)+W
ver_info = "$OLEB-ToolBox v1.6 changelog:\n$W-$G NEW $WAdded better logo and styling improvements.\n$W-$G NEW $WAdded status bar to the Main Menu.\n$W-$G NEW $WAdded support for Minecraft 1.19.1, 1.19.2, and 1.19.3.\n$W-$G NEW $WAdded delay when reinstalling to prevent accidents\n$W-$G NEW $WAdded support for newer versions of LEB\n$W-$G NEW $WMade branches menu easier to understand\n$W-$O FIX $WPrevent LEB-ToolBox from being loaded as a library/addon external code.$W\n$W-$O FIX $WFixed installer being broken from repo name change\n$W-$R REMOVED $WLegacy Resetter"
####### PROGRAM VERSION #######
repo = "Legacy-Edition-Minigames"
cfg_branch = "main"
current_hash = R+"unknown"
check_for_updates = -1
online_count_program = 0
fabric = 0
dependencies = 0
optimize = 0
upnp = 0
viafabric = 0
minimotd = 0
styledplayerlist = 0
server_scripts = 0
ram = 0
motd_sync = -1
eula = 0
lebDebugDisableDownloadContent = 0
lebDebugKeepCache = 0
lebDebugSkipPhase2 = 0
lebTBStatus = 0
def readConfig():
global cfg_branch
global current_hash
global motd_sync
global check_for_updates
isUpdating = 0
try:
if os.path.isfile('LEB-ToolBox_old.exe') or os.path.isfile('LEB-ToolBox_old') or os.path.isfile('LEB-ToolBox_DELETE_ME.exe') or os.path.isfile('LEB-ToolBox_DELETE_ME'):
isUpdating = 1
if os.path.isfile('LEB-ToolBox.cfg'):
raw = open("LEB-ToolBox.cfg", "r")
f = raw.read()
file_split = f.split("#/#")
cfg_branch = file_split[0]
motd_sync = int(file_split[1])
current_hash = file_split[2]
check_for_updates = int(file_split[3])
else:
print(O+"***************************************************************************"+W)
print(G+r""" __ __________ ______ ______
/ / / ____/ __ ) /_ __/___ ____ / / __ )____ _ __
/ / / __/ / __ | ______ / / / __ \/ __ \/ / __ / __ \| |/_/
/ /___/ /___/ /_/ / /_____/ / / / /_/ / /_/ / / /_/ / /_/ /> <
/_____/_____/_____/ /_/ \____/\____/_/_____/\____/_/|_|
"""+ver_program+W)
print(O+"***************************************************************************"+W)
print("")
print("Welcome to LEB-ToolBox!")
print("")
print("LEB-ToolBox is a tool designed to make it easy for users to install, update and customize their own LEB instance.")
print("To navigate through the program, wait until a blue <Input:> message appears. Then, use the numbers displayed on screen to select your choice and press ENTER.")
print("")
print("If you encounter any problem, try performing a clean reinstall or contact us on our Discord.")
print(B+"LEB"+W+"-"+G+"ToolBox "+W+"created by Pi"+R+"por"+O+"Games"+W)
print(E+"Legacy Edition"+O+" Battle"+W+" created by "+R+"DBTDerpbox "+E+"+"+B+" contributors"+W)
print("Consider donating at"+O+" Patreon"+W+"! "+O+"patreon.com/DBTDerpbox"+W)
print("")
print("Have fun!")
print("")
action = input(B+"Press ENTER to continue . . ."+W)
raw = open("LEB-ToolBox.cfg", "w")
raw.write("main#/#1#/#unknown#/#1#/#0")
raw.close()
except:
if isUpdating == 0:
print(R+"An error has ocurred while trying to load the configuration file.")
print(W+"If you have updated the program recently, it might mean that the program requires a configuration upgrade.")
print("The program will try to convert the old configuration version to the new format required.")
print("")
print(P+"Do you want to continue?")
action = input(B+"Input [Y/N] (defualt=Yes): "+W)
else:
action = "y"
if action.lower() == "y":
try:
print("")
print("Trying to convert old configuration...")
raw = open("LEB-ToolBox.cfg", "r")
f = raw.read()
file_split = f.split("#/#")
cfg_branch = file_split[0]
motd_sync = int(file_split[1])
current_hash = file_split[2]
check_for_updates = int(file_split[3])
except:
pass
finally:
if cfg_branch == "":
cfg_branch = "main"
if motd_sync == -1:
motd_sync = 1
if current_hash == "":
current_hash = R+"unknown"
if check_for_updates == -1:
check_for_updates = 1
raw.close()
raw = open("LEB-ToolBox.cfg", "w")
print(str(motd_sync))
raw.write(cfg_branch+"#/#"+str(motd_sync)+"#/#"+current_hash+"#/#"+str(check_for_updates)+"#/#0")
raw.close()
print("Conversion finished.")
readConfig()
elif action.lower() == "n":
print("")
else:
raw = open("LEB-ToolBox.cfg", "w")
raw.write("main#/#1#/#unknown#/#1#/#0")
raw.close()
finally:
raw.close()
if os.name=='nt':
os.system('title LEB-ToolBox v'+str(cnt_program))
################
### GUIs ###
################
def mainMenu():
readConfig()
cls()
print("=============================================================================")
print(G+r""" __ __________ ______ ______
/ / / ____/ __ ) /_ __/___ ____ / / __ )____ _ __
/ / / __/ / __ | ______ / / / __ \/ __ \/ / __ / __ \| |/_/
/ /___/ /___/ /_/ / /_____/ / / / /_/ / /_/ / / /_/ / /_/ /> <
/_____/_____/_____/ /_/ \____/\____/_/_____/\____/_/|_|
"""+ver_program+W)
if lebTBStatus == 0:
print("")
elif lebTBStatus == 1:
print(E+"(i) The program is fully updated."+W)
elif lebTBStatus == -1:
print(O+"(!) There are new updates available."+W)
elif lebTBStatus == -2:
print(Y+"(!) There are new updates, but none are available for your system yet."+W)
elif lebTBStatus == -3:
print(R+"[!!!] You are running a developer/pre-release version of this program! "+W)
print("=============================================================================")
print("")
print(P+"Choose an action below:"+W)
print("")
print(Y+"--- Legacy Edition Battle ---"+W)
try:
f = open("fabric-server-launch.jar")
print("0. Start LEB Server")
print("1. Update LEB " + E +"(current commit installed: " +G+current_hash+E+")"+W)
f.close()
except IOError:
print("1. Install LEB")
print("")
print(Y+"--- Customize aspects ---"+W)
print("2. Settings")
print("3. Change branch (current selected branch: ", B+cfg_branch+W, ")")
print("")
print(Y+"--- Documentation ---"+W)
print("4. Open GitHub project page")
print("5. See the Changelog")
print("")
print("")
print("6. Exit")
print("")
action = input(B+"Input: "+W)
if action == "0":
try:
f = open("fabric-server-launch.jar")
f.close()
cls()
print(G+"****************************")
print("*** LEB Server Launching ***")
print("****************************"+W)
print("")
if platform.system() == "Linux":
os.system("./Run-Linux.sh")
elif platform.system() == "Darwin":
os.system("./Run-MacOS.sh")
elif platform.system() == "Windows":
os.system("Run-Windows.cmd")
print("")
print(R+"***************************")
print("*** LEB Server Stopping ***")
print("***************************"+W)
print("")
action = input(B+"Press ENTER to return to the main menu . . ."+W)
mainMenu()
except IOError:
mainMenu()
elif action == "1":
try:
f = open("fabric-server-launch.jar")
f.close()
updateMenu()
except IOError:
installMenu()
elif action == "2":
settingsMenu()
elif action == "3":
changeBranch()
elif action == "4":
webbrowser.open('https://github.com/Legacy-Edition-Minigames/Minigames')
mainMenu()
elif action == "5":
changeLog()
elif action == "6":
exit()
elif action == "debug nodownload": #forces not to download or extract the lebupdatecache/leb.zip file. THIS OPTION WILL MAKE LEB-TOOLBOX UNSTABLE (MIGHT CRASH).
global lebDebugSkipPhase2
lebDebugSkipPhase2 = 1
action = input(B+"forced skip download and install of phase 2"+W)
mainMenu()
elif action == "debug forcecache": #forces to use local lebupdatecache/leb.zip file instead of downloading it from github.
global lebDebugDisableDownloadContent
lebDebugDisableDownloadContent = 1
action = input(B+"forced use local lebupdatecache/leb.zip when on install phase 2 instead of downloading"+W)
mainMenu()
elif action == "debug keepcache": #forces to use keep lebupdatecache/leb.zip file instead of removing it right after extracting the files.
global lebDebugKeepCache
lebDebugKeepCache = 1
action = input(B+"forced keep lebupdatecache/leb.zip folder after installing"+W)
mainMenu()
elif action == "debug reinstall": #opens reinstall GUI
reinstall()
elif action == "debug install": #opens install GUI
installMenu()
elif action == "debug setmotd": #executes the set MOTD function. toggles on and off this feature
setMOTD()
elif action == "debug repo": #changes the repo for update checking to the my own. usefull for experimental features that require changes on the main github.
global repo
repo = "PiporGames"
action = input(B+"changed repo fetching to PiporGames"+W)
mainMenu()
elif action == "debug cfu": #executes the CFU routine function. kinda experimental for now.
var111 = checkForUpdates()
print(str(var111))
input("")
mainMenu()
else:
mainMenu()
def installMenu():
cls()
print("=======================================================")
print(G+"Install LEB"+W)
print("=======================================================")
print("")
print(G+"Welcome to the LEB setup wizard!"+W)
print("Thank you for downloading LEB. This wizard will help you setup your own LEB server instance.")
print("The setup will ask you some questions before proceeding to setup everything.")
print("")
print("Consider donating if you want to support this project.")
print("We hope you have fun!")
print("")
print(P+"Press " + B+ "ENTER " + P+ "to continue . . ." + W)
print("")
action = input("")
installMenu_2()
def installMenu_2():
cls()
print("=======================================================")
print(G+"Install LEB"+W)
print(G+"Install type (1/1)"+W)
print("=======================================================")
print("")
print(G+"Install type:"+W)
print("1. Full Install"+W+":"+E+" This option will install every dependency and enhancement needed for LEB to work as intended."+W)
print("2. Minimal Install"+W+":"+E+" This option will install only necesary dependencies for LEB to work, without any enhancements."+W)
print("3. Custom Install"+W+":"+E+" You will be asked what components to install individually."+W)
print("")
print(P+"Choose a install type from above:"+W)
print("")
action = input(B+"Input: "+W)
global fabric
global dependencies
global optimize
global upnp
global viafabric
global server_scripts
global minimotd
global styledplayerlist
global motd_sync
global EULA
eula = 0
# set 0 / nothing = user choice
# set 1 = install
# set 2 = do not install
if action == "1":
fabric = 1
dependencies = 1
optimize = 1
upnp = 1
viafabric = 1
minimotd = 1
styledplayerlist = 1
server_scripts = 1
motd_sync = 1
installMenu_3()
elif action == "2":
fabric = 1
dependencies = 1
optimize = 2
upnp = 2
viafabric = 2
minimotd = 2
styledplayerlist = 2
server_scripts = 2
motd_sync = 2
installMenu_3()
elif action == "3":
fabric = 0
dependencies = 0
optimize = 0
upnp = 0
viafabric = 0
minimotd = 0
styledplayerlist = 0
server_scripts = 0
motd_sync = 0
installMenu_3()
else:
installMenu_2()
def installMenu_3():
cls()
print("=======================================================")
print(G+"Install LEB"+W)
print(G+"Components (1/2)"+W)
print("=======================================================")
print("")
print(B+"Do you want to install "+G+"Fabric"+B+"?"+W)
print("Fabric is the core server component of the server and it " +R+"MUST"+W+" be installed, not just to make LEB work, but to actually be able to run the server itself.")
print("Besides upgrading the Fabric version because of extraordinary circumstances, you should always install this component.")
print("")
print(R+"WARNING: LEB WON'T WORK IF THIS COMPONENT IS NOT INSTALLED!")
print("")
print(P+"Do you want to install this component?:"+W)
print("")
global fabric
if fabric == 0:
action = input(B+"Input " + G + "[Y/N]" + B + ": "+W)
if action.lower() == "y":
fabric = 1
installMenu_4()
elif action.lower() == "n":
fabric = 2
installMenu_4()
else:
installMenu_3()
else:
installMenu_4()
def installMenu_4():
cls()
print("=======================================================")
print(G+"Install LEB"+W)
print(G+"Components (2/2)"+W)
print("=======================================================")
print("")
print(B+"Do you want to install "+G+"Dependencies (multiple components)"+B+"?"+W)
print("LEB ships with a preset of required dependencies for it to work as intended. This dependencies " +R+"MUST"+W+" be installed to make LEB work as intended.")
print(B+"The list of dependencies contains:")
print(G+"- Fabric API")
print("- ServerUtils")
print("- SnowballKB")
print("- Starlight")
print("- Editable Player NBT Hack")
print("- No Chat Reports"+W)
print("Besides upgrading the dependencies version because of extraordinary circumstances, you should always install this component.")
print("")
print(R+"WARNING: LEB WON'T WORK IF THIS COMPONENT IS NOT INSTALLED!")
print("")
print(P+"Do you want to install this component?:"+W)
print("")
global dependencies
if dependencies == 0:
action = input(B+"Input " + G + "[Y/N]" + B + ": "+W)
if action.lower() == "y":
dependencies = 1
installMenu_4_B()
elif action.lower() == "n":
dependencies = 2
installMenu_4_B()
else:
installMenu_4()
else:
installMenu_4_B()
def installMenu_4_B():
cls()
print("=======================================================")
print(G+"Install LEB"+W)
print(G+"Enhancements (1/9)"+W)
print("=======================================================")
print("")
print(B+"Do you want to install "+G+"Optimization mods"+B+"?"+W)
print("LEB Lobby loading delay and memory usage can be reduced with the help of some lightweight modifications to the server-side code.")
print("Using this will optimize the server to use less of your system's resources without any drawbacks.")
print(B+"The list of optimization mods contains:")
print(G+"- FerriteCore")
print("- Lithium")
print("- Carpet")
print("- Krypton")
print("- ServerCore")
print("- Very Many Players")
print("")
print(E+"This is an optional enhancement."+W)
print("")
print(P+"Do you want to install this component?:"+W)
print("")
global optimize
if optimize == 0:
action = input(B+"Input " + G + "[Y/N]" + B + ": "+W)
if action.lower() == "y":
optimize = 1
installMenu_5()
elif action.lower() == "n":
optimize = 2
installMenu_5()
else:
installMenu_4_B()
else:
installMenu_5()
def installMenu_5():
cls()
print("=======================================================")
print(G+"Install LEB"+W)
print(G+"Enhancements (2/9)"+W)
print("=======================================================")
print("")
print(B+"Do you want to use "+G+"UPnP"+B+"?"+W)
print("Universal PlugAndPlay (UPnP) is a custom port forwarding protocol used to automatically open your router's port to the outside Internet.")
print("This is a neat feature to have if you have problems with Port Forwarding or you don't know much about it, and your friends want to connect to your computer"+E+" (asuming you are not playing in a LAN)"+W+".")
print("This enhancement doesn't work with all types and models of routers out there, check if yours have UPnP before installing!.")
print("")
print(E+"This is an optional enhancement."+W)
print("")
print(P+"Do you want to install this component?:"+W)
print("")
global upnp
if upnp == 0:
action = input(B+"Input " + G + "[Y/N]" + B + ": "+W)
if action.lower() == "y":
upnp = 1
installMenu_6()
elif action.lower() == "n":
upnp = 2
installMenu_6()
else:
installMenu_5()
else:
installMenu_6()
def installMenu_6():
cls()
print("=======================================================")
print(G+"Install LEB"+W)
print(G+"Enhancements (3/9)"+W)
print("=======================================================")
print("")
print(B+"Do you want to use "+G+"ViaFabric & ViaBackwards"+B+"?"+W)
print("ViaFabric & ViaBackwards are mods that provides cross-version compatibility, allowing client versions between 1.16 to 1.19 to join the server.")
print("This is a neat feature to have if your players use mods, resourcepacks, or modified clients that are designed specifically for versions 1.16, 1.17 or 1.19.")
print("")
print(E+"This is an optional enhancement."+W)
print("")
print(P+"Do you want to install this component?:"+W)
print("")
global viafabric
if viafabric == 0:
action = input(B+"Input " + G + "[Y/N]" + B + ": "+W)
if action.lower() == "y":
viafabric = 1
installMenu_6_2()
elif action.lower() == "n":
viafabric = 2
installMenu_6_2()
else:
installMenu_6()
else:
installMenu_6_2()
def installMenu_6_2():
cls()
print("=======================================================")
print(G+"Install LEB"+W)
print(G+"Enhancements (4/9)"+W)
print("=======================================================")
print("")
print(B+"Do you want to use "+G+"MiniMOTD"+B+"?"+W)
print("MiniMOTD is a mod that provides fancy looking server status messages (MOTDs), featuring cool looking gradients, among other things.")
print("This is a neat feature to have if you want to have cool looking server stats.")
print("")
print(E+"This is an optional enhancement."+W)
print("")
print(P+"Do you want to install this component?:"+W)
print("")
global minimotd
if minimotd == 0:
action = input(B+"Input " + G + "[Y/N]" + B + ": "+W)
if action.lower() == "y":
minimotd = 1
installMenu_6_3()
elif action.lower() == "n":
minimotd = 2
installMenu_6_3()
else:
installMenu_6_2()
else:
installMenu_6_3()
def installMenu_6_3():
cls()
print("=======================================================")
print(G+"Install LEB"+W)
print(G+"Enhancements (5/9)"+W)
print("=======================================================")
print("")
print(B+"Do you want to use "+G+"StyledPlayerList"+B+"?"+W)
print("StyledPlayerList is a mod that provides a fancy looking tablist, featuring cool looking gradients, and some useful stats.")
print("This is a neat feature to have if you want to make your tablist look a bit less empty.")
print("")
print(E+"This is an optional enhancement."+W)
print("")
print(P+"Do you want to install this component?:"+W)
print("")
global styledplayerlist
if styledplayerlist == 0:
action = input(B+"Input " + G + "[Y/N]" + B + ": "+W)
if action.lower() == "y":
styledplayerlist = 1
installMenu_7()
elif action.lower() == "n":
styledplayerlist = 2
installMenu_7()
else:
installMenu_6_3()
else:
installMenu_7()
def installMenu_7():
cls()
print("=======================================================")
print(G+"Install LEB"+W)
print(G+"Enhancements (6/9)"+W)
print("=======================================================")
print("")
print(B+"How much "+G+"RAM"+B+" do you want to allocate to LEB?"+W)
print("Modified servers, such as LEB, require extra memory than default Minecraft servers.")
print("You can set whatever amount of RAM (in GB) you want to use.")
print("")
print(E+"It's recommended to use"+G+" at least 3GB of RAM"+E+" to ensure LEB will work as intended."+W)
print("")
print(P+"How much RAM do you want to allocate (in GB)?:"+W)
print("")
global ram
while True:
try:
ram = int(input(B+"Input " + G + "[in GB]" + B + ": "+W))
break;
except ValueError:
installMenu_7()
installMenu_8()
def installMenu_8():
cls()
print("=======================================================")
print(G+"Install LEB"+W)
print(G+"Enhancements (8/9)"+W)
print("=======================================================")
print("")
print(B+"Do you want to use "+G+"MOTD Sync"+B+"?"+W)
print("With MOTD Sync enabled, the server's MOTD Message will be synced with the latest official LEB commit's MOTD.")
print("This is helpfull if you want to quickly determinate if you are running an old version of LEB.")
print("")
print(E+"This is an optional enhancement. You can change this setting at the LEB-Toolbox Settings Page."+W)
print("")
print(P+"Do you want to install this component?:"+W)
print("")
global motd_sync
global cfg_branch
if motd_sync == 0:
action = input(B+"Input " + G + "[Y/N]" + B + ": "+W)
if action.lower() == "y":
try:
f = open("LEB-ToolBox.cfg", "w")
f.write(cfg_branch+"#/#1")
finally:
f.close()
motd_sync = 1
installMenu_9()
elif action.lower() == "n":
motd_sync = 2
installMenu_9()
else:
installMenu_8()
else:
installMenu_9()
def installMenu_9():
cls()
print("=======================================================")
print(G+"Install LEB"+W)
print(G+"Enhancements (9/9)"+W)
print("=======================================================")
print("")
print(B+"Do you want to use "+G+"Server GUI"+B+"?"+W)
print("With Server GUI enabled, upon server start, a detailed window will apear containg a memory graph, player list and command console.")
print("This is a nice way of managing your LEB server, but it consumes some (not that much) resources and might not show error logs properly.")
print("Disabling this component will output instead a black terminal window with lots of debugging logs.")
print("")
print(E+"This is an optional enhancement."+W)
print("")
print(P+"Do you want to install this component?:"+W)
print("")
global server_scripts
if server_scripts == 0:
action = input(B+"Input " + G + "[Y/N]" + B + ": "+W)
if action.lower() == "y":
server_scripts = 1
installMenu_10()
elif action.lower() == "n":
server_scripts = 2
installMenu_10()
else:
installMenu_9()
else:
installMenu_10()
def installMenu_10():
cls()
print("=======================================================")
print(G+"Install LEB"+W)
print(G+"EULA Agreement"+W)
print("=======================================================")
print("")
print(B+"Do you accept the "+G+"Minecraft's EULA"+B+"?"+W)
print("For your server to run you must accept Minecraft's EULA.")
print("The Minecraft's EULA contains information and rules about what you can do and can't do while using the game.")
print("Agreement of the Minecraft's EULA is "+R+"strictly needed"+W+", otherwise your server would be illegal to operate and thus, won't open.")
print("")
print(R+"WARNING: LEB WON'T WORK IF MINECRAFT'S EULA IS NOT AGREED!")
print("")
print(P+"Do you want to accept the "+G+"Minecraft's EULA"+B+"?"+W)
print("")
global eula
if eula == 0:
action = input(B+"Input " + G + "[Y/N]" + B + ": "+W)
if action.lower() == "y":
eula = 1
installMenu_11()
elif action.lower() == "n":
eula = 2
installMenu_11()
else:
installMenu_10()
else:
installMenu_11()
def installMenu_11():
cls()
print("=======================================================")
print(G+"Install LEB"+W)
print(G+"Ready to Install"+W)
print("=======================================================")
print("")
print(G+"Ready to install LEB!"+W)
print("You are now ready to install LEB.")
print("This program will now connect to the internet to download the required files.")
print("")
print(P+"Press " + B+ "ENTER " + P+ "to start downloading . . ." + W)
print("")
action = input("")
installMenu_12()
def installMenu_12():
global fabric
global dependencies
global optimize
global upnp
global viafabric
global minimotd
global styledplayerlist
global server_scripts
global motd_sync
global ram
cls()
print("=======================================================")
print(G+"Install LEB"+W)
print(G+"Installing..."+W)
print("=======================================================")
print("")
print(G+"Installing LEB!"+W)
print("")
prepare()
#fabric
if fabric == 1:
print("Downloading Fabric...", end='')
sleep(0.05)
try:
fabricurl = requests.get('https://maven.fabricmc.net/net/fabricmc/fabric-installer/0.11.1/fabric-installer-0.11.1.jar', allow_redirects=True)
open("fabricinstaller.jar", "wb").write(fabricurl.content)
print(G+"DONE"+W)
print("Installing Fabric...", end='')
sleep(0.05)
os.system('java -jar fabricinstaller.jar server -mcversion 1.19.2 -downloadMinecraft')
print(G+"DONE"+W)
print("Removing Fabric installer files...", end='')
os.remove("fabricinstaller.jar")
print(G+"DONE"+W)
except OSError as error:
print(R+"FAIL (" + str(error) + ")"+W)
else:
print(R+"Skipping Fabric install... FABRIC IS A REQUIRED COMPONENT, BE SURE TO INSTALL IT MANUALLY AFTERWARDS"+W)
sleep(0.05)
#dependencies
if dependencies == 1:
print("Downloading Dependencies "+B+"["+W)
sleep(0.05)
try:
os.mkdir('mods')
except OSError as error:
print(R+"FAIL (" + str(error) + ")"+W)
try:
print("Downloading FabricAPI...", end='')
sleep(0.05)
fabricapiurl = requests.get('https://cdn.modrinth.com/data/P7dR8mSH/versions/mrB7EiW4/fabric-api-0.70.0%2B1.19.2.jar', allow_redirects=True)
open('mods/fabric-api-0.70.0+1.19.2.jar', 'wb').write(fabricapiurl.content)
print(G+"DONE"+W)
except OSError as error:
print(R+"FAIL (" + str(error) + ")"+W)
try:
print("Downloading ServerUtils...", end='')
sleep(0.05)
serverutilsurl = requests.get('https://github.com/kyrptonaught/Server-Utils/releases/download/1.0.5/ServerUtils-1.0.5-1.19.jar', allow_redirects=True)
open('mods/ServerUtils-1.0.5-1.19.jar', 'wb').write(serverutilsurl.content)
print(G+"DONE"+W)
except OSError as error:
print(R+"FAIL (" + str(error) + ")"+W)
try:
print("Downloading SnowballKB...", end='')
sleep(0.05)
snowballkburl = requests.get('https://mediafilez.forgecdn.net/files/3885/676/snowballkb-1.2-1.19.jar', allow_redirects=True)
open('mods/snowballkb-1.2-1.19.jar', 'wb').write(snowballkburl.content)
print(G+"DONE"+W)
except OSError as error:
print(R+"FAIL (" + str(error) + ")"+W)
try:
print("Downloading Starlight...", end='')
sleep(0.05)
starlighturl = requests.get('https://cdn.modrinth.com/data/H8CaAYZC/versions/1.1.1%2B1.19/starlight-1.1.1%2Bfabric.ae22326.jar', allow_redirects=True)
open('mods/starlight-1.1.1+fabric.ae22326.jar', 'wb').write(starlighturl.content)
print(G+"DONE"+W)
except OSError as error:
print(R+"FAIL (" + str(error) + ")"+W)
try:
print("Downloading Editable Player NBT Hack...", end='')
sleep(0.05)
editnbtplayerurl = requests.get('https://cdn.modrinth.com/data/gY2Q7o7X/versions/EDCQqJQg/editableplayernbthack-1.1.0-1.19.2.jar', allow_redirects=True)
open('mods/editableplayernbthack-1.1.0-1.19.2.jar', 'wb').write(editnbtplayerurl.content)
print(G+"DONE"+W)
except OSError as error:
print(R+"FAIL (" + str(error) + ")"+W)
try:
print("Downloading No Chat Reports...", end='')
sleep(0.05)
vmpurl = requests.get('https://cdn.modrinth.com/data/qQyHxfxd/versions/YuX53PIA/NoChatReports-FABRIC-1.19.2-v1.13.12.jar', allow_redirects=True)
open('mods/NoChatReports-FABRIC-1.19.2-v1.13.12.jar', 'wb').write(vmpurl.content)
print(G+"DONE"+W)
except OSError as error:
print(R+"FAIL (" + str(error) + ")"+W)
print(B+"] "+W+"Dependencies "+G+"DONE"+W)
else:
print(R+"Skipping Dependencies... DEPENDENCIES ARE REQUIRED COMPONENTS, BE SURE TO INSTALL THEM MANUALLY AFTERWARDS"+W)
sleep(0.05)
#optimize
if optimize == 1:
print("Downloading Optimizations "+B+"["+W)
sleep(0.05)
try:
os.mkdir('mods')
except OSError as error:
print("", end='')
pass
try:
print("Downloading FerriteCore...", end='')
sleep(0.05)
ferritecoreurl = requests.get('https://cdn.modrinth.com/data/uXXizFIs/versions/kwjHqfz7/ferritecore-5.0.3-fabric.jar', allow_redirects=True)
open('mods/ferritecore-5.0.3-fabric.jar', 'wb').write(ferritecoreurl.content)
print(G+"DONE"+W)
except OSError as error:
print(R+"FAIL (" + str(error) + ")"+W)
try:
print("Downloading Lithium...", end='')
sleep(0.05)
lithiumurl = requests.get('https://cdn.modrinth.com/data/gvQqBUqZ/versions/7scJ9RTg/lithium-fabric-mc1.19.2-0.10.4.jar', allow_redirects=True)
open('mods/lithium-fabric-mc1.19.2-0.10.4.jar', 'wb').write(lithiumurl.content)
print(G+"DONE"+W)
except OSError as error:
print(R+"FAIL (" + str(error) + ")"+W)
try:
print("Downloading Carpet...", end='')
sleep(0.05)
carpeturl = requests.get('https://mediafilez.forgecdn.net/files/4033/215/fabric-carpet-1.19.2-1.4.84%2Bv221018.jar', allow_redirects=True)
open('mods/fabric-carpet-1.19.2-1.4.84+v221018.jar', 'wb').write(carpeturl.content)
print(G+"DONE"+W)
except OSError as error:
print(R+"FAIL (" + str(error) + ")"+W)
try:
print("Downloading Krypton...", end='')
sleep(0.05)
kryptonurl = requests.get('https://cdn.modrinth.com/data/fQEb0iXm/versions/0.2.1/krypton-0.2.1.jar', allow_redirects=True)
open('mods/krypton-0.2.1.jar', 'wb').write(kryptonurl.content)
print(G+"DONE"+W)
except OSError as error:
print(R+"FAIL (" + str(error) + ")"+W)
try:
print("Downloading ServerCore...", end='')
sleep(0.05)
servercoreurl = requests.get('https://cdn.modrinth.com/data/4WWQxlQP/versions/kzD8EGTS/servercore-1.3.3-1.19.2.jar', allow_redirects=True)
open('mods/servercore-1.3.3-1.19.2.jar', 'wb').write(servercoreurl.content)
print(G+"DONE"+W)
except OSError as error:
print(R+"FAIL (" + str(error) + ")"+W)
try:
print("Downloading Very Many Players...", end='')
sleep(0.05)
vmpurl = requests.get('https://cdn.modrinth.com/data/wnEe9KBa/versions/2tNVStHO/vmp-fabric-mc1.19.2-0.2.0%2Bbeta.7.23-all.jar', allow_redirects=True)
open('mods/vmp-fabric-mc1.19.2-0.2.0+beta.7.23-all.jar', 'wb').write(vmpurl.content)
print(G+"DONE"+W)
except OSError as error:
print(R+"FAIL (" + str(error) + ")"+W)
print(B+"] "+W+"Optimizations "+G+"DONE"+W)
else:
print(E+"Skipping Optimizations..."+W)
sleep(0.05)
#upnp
if upnp == 1:
print("Downloading dedicatedUPnP...", end='')
sleep(0.05)
try:
dedicatedmcupnpurl = requests.get('https://mediafilez.forgecdn.net/files/3835/172/dedicatedmcupnp-1.2.1.jar', allow_redirects=True)
open('mods/dedicatedmcupnp-1.2.1.jar', 'wb').write(dedicatedmcupnpurl.content)
print(G+"DONE"+W)
except OSError as error:
print(R+"FAIL (" + str(error) + ")"+W)
else:
print(E+"Skipping UPnP..."+W)
sleep(0.05)
#viafabric
if viafabric == 1:
print("Downloading ViaFabric...", end='')
sleep(0.05)
try:
viafabricurl = requests.get('https://cdn.modrinth.com/data/YlKdE5VK/versions/Su0V35Vs/viafabric-0.4.9%2B22-main.jar', allow_redirects=True)
open('mods/viafabric-0.4.9+22-main.jar', 'wb').write(viafabricurl.content)
print(G+"DONE"+W)
except OSError as error:
print(R+"FAIL (" + str(error) + ")"+W)
print("Downloading ViaBackwards...", end='')
sleep(0.05)
try:
viabackwardsurl = requests.get('https://github.com/ViaVersion/ViaBackwards/releases/download/4.5.1/ViaBackwards-4.5.1.jar', allow_redirects=True)
open('mods/ViaBackwards-4.5.1.jar', 'wb').write(viabackwardsurl.content)
print(G+"DONE"+W)
except OSError as error:
print(R+"FAIL (" + str(error) + ")"+W)
else:
print(E+"Skipping ViaFabric..."+W)
sleep(0.05)
print(E+"Skipping ViaBackwards..."+W)
sleep(0.05)
#minimotd
if minimotd == 1:
print("Downloading MiniMOTD...", end='')
sleep(0.05)
try:
minimotdurl = requests.get('https://cdn.modrinth.com/data/16vhQOQN/versions/c745jM85/minimotd-fabric-mc1.19.2-2.0.9.jar', allow_redirects=True)
open('mods/minimotd-fabric-mc1.19.2-2.0.9.jar', 'wb').write(minimotdurl.content)
print(G+"DONE"+W)
except OSError as error:
print(R+"FAIL (" + str(error) + ")"+W)
else:
print(E+"Skipping MiniMOTD..."+W)
sleep(0.05)
#styledplayerlist
if styledplayerlist == 1:
print("Downloading StyledPlayerList...", end='')
sleep(0.05)
try:
styledplayerlisturl = requests.get('https://cdn.modrinth.com/data/DQIfKUHf/versions/2.2.2%2B1.19.1/styledplayerlist-2.2.2%2B1.19.1.jar', allow_redirects=True)
open('mods/styledplayerlist-2.2.2+1.19.1.jar', 'wb').write(styledplayerlisturl.content)
print(G+"DONE"+W)
except OSError as error:
print(R+"FAIL (" + str(error) + ")"+W)
else:
print(E+"Skipping StyledPlayerList..."+W)
sleep(0.05)
#scripts
ram = (str(ram))
print("Creating server scripts "+B+"["+W)
sleep(0.05)
print(B+"RAM...: " + G + ram + B + " GB"+W)
print(B+"Server GUI...: " + G, end='')
if server_scripts == 1:
print("Yes")
else:
print("No")
print(B+"MOTD Sync...: " + G, end='')
if motd_sync == 1:
print("Yes")
else:
print("No")
try:
if server_scripts == 1:
scriptgui = ""
else:
scriptgui = "nogui"
#Windows
winscript = open("Run-Windows.cmd","w")
#MacOS
macscript = open("Run-MacOS.sh","w")
#Linux
linuxscript = open("Run-Linux.sh","w")
winscript.write("@ECHO OFF\njava -Xmx"+ram+"G -Xms"+ram+"G -jar fabric-server-launch.jar "+scriptgui+"\nPAUSE")
macscript.write("exec java -Xmx"+ram+"G -Xms"+ram+"G -jar fabric-server-launch.jar "+scriptgui)
linuxscript.write("java -Xmx"+ram+"G -Xms"+ram+"G -jar fabric-server-launch.jar "+scriptgui)
winscript.close()
macscript.close()
linuxscript.close()
#linux chmod
if platform.system() == "Linux":