1+ import os
2+ import requests
3+
4+ ##URLs to download things from
5+ #Fabric Installer
6+ fabricurl = requests .get ('https://maven.fabricmc.net/net/fabricmc/fabric-installer/0.10.2/fabric-installer-0.10.2.jar' , allow_redirects = True )
7+ #Fabric API
8+ fabricapiurl = requests .get ('https://github.com/FabricMC/fabric/releases/download/0.45.0%2B1.17/fabric-api-0.45.0+1.17.jar' , allow_redirects = True )
9+ #Switchable Resource Packs
10+ srpurl = requests .get ('https://github.com/kyrptonaught/SwitchableResourcepacks/releases/download/1.0.0/switchableresourcepacks-1.0.0-1.17.jar' , allow_redirects = True )
11+ #Scoreboard Suffix
12+ scoreboardsuffixurl = requests .get ('https://github.com/kyrptonaught/scoreboardsuffix/releases/download/1.0.3/scoreboardsuffix-1.0.3-1.17.jar' , allow_redirects = True )
13+ #Extended Structures
14+ extstructureurl = requests .get ('https://github.com/kyrptonaught/Extended-Structures/releases/download/1.0.0/extendedstructures-1.0.0-1.17.1.jar' , allow_redirects = True )
15+ #SnowballKB
16+ snowballkburl = requests .get ('https://github.com/capitalistspz/SnowballKB/releases/download/1.1/snowballkb-1.1-1.17.jar' , allow_redirects = True )
17+ #dedicatedmcupnp
18+ dedicatedmcupnpurl = requests .get ('https://media.forgecdn.net/files/3525/899/dedicatedmcupnp-1.2.0.jar' , allow_redirects = True )
19+ #ViaFabric
20+ viafabricurl = requests .get ('https://media.forgecdn.net/files/3544/467/viafabric-0.4.5%2B244-main.jar' , allow_redirects = True )
21+
22+ print ("LEB has some Fabric depencencies for the server to work, would you like to automatically install Fabric?" )
23+ installfabric = input ("Install FabricMC? [Y/n] " )
24+
25+ ##Install fabric loader
26+ if installfabric == "n" :
27+ print ("Fabric will not be installed automatically, you still need to install fabric manually for the server to work!" )
28+ else :
29+ #Download Fabric Installer and run it
30+ print ("Ok! Installing Fabric Loader..." )
31+ open ('fabricinstaller.jar' , 'wb' ).write (fabricurl .content )
32+ os .system ('java -jar fabricinstaller.jar server -mcversion 1.17.1 -downloadMinecraft' )
33+
34+ ##Install dependencies
35+ print ("\n Would you like to automatically install the required dependencies?" )
36+ installmods = input ("Install Dependencies? [Y/n] " )
37+
38+ if installmods == "n" :
39+ print ("Requried dependencies will not be installed, they need to be installed manually for the server to work!" )
40+ else :
41+ print ("Installing Dependencies!" )
42+ #Create mods folder
43+ print ("Creating mods folder..." )
44+ try :
45+ os .mkdir ('mods' )
46+ except OSError :
47+ print ("Mods folder already exists!" )
48+ #Download Fabric API
49+ print ("Downloading Fabric API..." )
50+ open ('mods/fabric-api-0.45.0+1.17.jar' , 'wb' ).write (fabricapiurl .content )
51+ #Check if it was downloaded
52+ modexists = os .path .exists ('mods/fabric-api-0.45.0+1.17.jar' )
53+ if modexists :
54+ print ("Installed Fabric API successfuly!" )
55+ else :
56+ print ("Failed to download Fabric API" )
57+ #Download SRP
58+ print ("Downloading Switchable Resource Packs..." )
59+ open ('mods/switchableresourcepacks-1.0.0-1.17.jar' , 'wb' ).write (srpurl .content )
60+ #Check if it was downloaded
61+ modexists = os .path .exists ('mods/switchableresourcepacks-1.0.0-1.17.jar' )
62+ if modexists :
63+ print ("Installed Switchable Resource Packs successfuly!" )
64+ else :
65+ print ("Failed to download Switchable Resource packs" )
66+ #Download Scoreboard Suffix
67+ print ("Downloading Scoreboard Suffix..." )
68+ open ('mods/scoreboardsuffix-1.0.3-1.17.jar' , 'wb' ).write (scoreboardsuffixurl .content )
69+ #Check if it was downloaded
70+ modexists = os .path .exists ('mods/scoreboardsuffix-1.0.3-1.17.jar' )
71+ if modexists :
72+ print ("Installed Scoreboard Suffix successfuly!" )
73+ else :
74+ print ("Failed to download Scoreboard Suffix" )
75+ #Download Extended Structures
76+ print ("Downloading Extended Structures..." )
77+ open ('mods/extendedstructures-1.0.0-1.17.1.jar' , 'wb' ).write (extstructureurl .content )
78+ #Check if it was downloaded
79+ modexists = os .path .exists ('mods/extendedstructures-1.0.0-1.17.1.jar' )
80+ if modexists :
81+ print ("Installed Extended Structures successfuly!" )
82+ else :
83+ print ("Failed to download Extended Structures" )
84+ #Download SnowballKB
85+ print ("Downloading SnowballKB..." )
86+ open ('mods/snowballkb-1.1-1.17.jar' , 'wb' ).write (snowballkburl .content )
87+ #Check if it was downloaded
88+ modexists = os .path .exists ('mods/snowballkb-1.1-1.17.jar' )
89+ if modexists :
90+ print ("Installed SnowballKB successfuly!" )
91+ else :
92+ print ("Failed to download SnowballKB" )
93+
94+ ##Install UPnP
95+ print ("\n Would you like to attempt to use UPnP? This will allow you to skip the Port Forwarding process if your router has UPnP enabled." )
96+ installupnp = input ("Use UPnP? [Y/n] " )
97+
98+ if installupnp == "n" :
99+ print ("UPnP will not be enabled, you will need to Port Forward manually." )
100+ else :
101+ #Download dedicatedmcupnp
102+ print ("Downloading dedicatedmcupnp..." )
103+ open ('mods/dedicatedmcupnp-1.2.0.jar' , 'wb' ).write (dedicatedmcupnpurl .content )
104+ #Check if it was downloaded
105+ modexists = os .path .exists ('mods/dedicatedmcupnp-1.2.0.jar' )
106+ if modexists :
107+ print ("Installed dedicatedmcupnp successfuly!" )
108+ else :
109+ print ("Failed to download dedicatedmcupnp" )
110+
111+ ##Install ViaFabric
112+ print ("\n Would you like to install ViaFabric? This will allow users on 1.18 to be able to join the server." )
113+ installviafabric = input ("Install ViaFabric? [Y/n] " )
114+
115+ if installviafabric == "n" :
116+ print ("ViaFabric will not be installed, users that wish to join will need to play on 1.17.1 to be able to connect." )
117+ else :
118+ #Download ViaFabric
119+ print ("Downloading ViaFabric..." )
120+ open ('mods/viafabric-0.4.5+244-main.jar' , 'wb' ).write (viafabricurl .content )
121+ #Check if it was downloaded
122+ modexists = os .path .exists ('mods/viafabric-0.4.5+244-main.jar' )
123+ if modexists :
124+ print ("Installed ViaFabric successfuly!" )
125+ else :
126+ print ("Failed to download ViaFabric" )
127+
128+ ##Prepare launch scripts
129+ print ("\n Would you like to create your server launch scripts now? These scripts will launch the server for you when ran." )
130+ createscripts = input ("Create Launch Scripts? [Y/n] " )
131+
132+ ##Create launch scripts
133+ if createscripts == "n" :
134+ print ("Launch scripts will not be created, you will need to start the server manually." )
135+ else :
136+ ##Configure
137+ #Use GUI
138+ scriptgui = input ("Use Server GUI? [Y/n] " )
139+ if scriptgui == "n" :
140+ scriptgui = " nogui"
141+ else :
142+ scriptgui = ""
143+ #Get ram amount
144+ print ("How much ram would you like to allocate in Gigabytes? 3 or higher is reconmended." )
145+ while True :
146+ try :
147+ ram = int (input ("RAM: " ))
148+ break ;
149+ except ValueError :
150+ print ("Please enter a number!" )
151+ ##Open scripts
152+ #Windows
153+ winscript = open ("windows.cmd" ,"w" )
154+ #MacOS
155+ macscript = open ("macos.sh" ,"w" )
156+ #Linux
157+ linuxscript = open ("linux.sh" ,"w" )
158+ print ("Writing scripts..." )
159+ ram = (str (ram ))
160+ winscript .write ("@ECHO OFF\n java -Xmx" + ram + "G -Xms" + ram + "G -jar fabric-server-launch.jar" + scriptgui + "\n PAUSE" )
161+ macscript .write ("exec java -Xmx" + ram + "G -Xms" + ram + "G -jar fabric-server-launch.jar" + scriptgui )
162+ linuxscript .write ("java -Xmx" + ram + "G -Xms" + ram + "G -jar fabric-server-launch.jar" + scriptgui )
163+
164+ ##Create EULA file
165+ print ("\n You must agree to the Minecraft End User License Agreeent to be able to run MC servers, by typing \" y\" you are indicating your agreement to Minecraft: Java Edition's EULA (https://account.mojang.com/documents/minecraft_eula)." )
166+ eula = input ("Do you agree to the EULA? [y/N] " )
167+
168+ if eula == "y" :
169+ eulafile = open ("eula.txt" ,"w" )
170+ eulafile .write ("eula=TRUE" )
171+ print ("Agreed to EULA, saving eula.txt..." )
172+ else :
173+ print ("You have not agreed to the Minecraft EULA, your server will fail to start until you agree to the EULA, check eula.txt after running your server" )
174+
175+ print ("Installation complete! to run your server, run the script generated for your operating system." )
0 commit comments