-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patholdservermaker.py
239 lines (213 loc) · 10.4 KB
/
oldservermaker.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
import os,requests
import concurrent.futures
def serverstart():
print("starting batch script")
import subprocess
subprocess.call([r'run.bat'])
def download(url):
try:
get_response = requests.get(url,stream=True)
file_name = url.split("/")[-1]
with open("server.jar", 'wb') as f:
for chunk in get_response.iter_content(chunk_size=1024):
if chunk: # filter out keep-alive new chunks
f.write(chunk)
print("download done")
return 0
except:
print("download failed")
return 1
def versionfinder():
global version
if version == "1.16.2":
return "https://launcher.mojang.com/v1/objects/c5f6fb23c3876461d46ec380421e42b289789530/server.jar"
if version == "1.16.1":
return "https://launcher.mojang.com/v1/objects/a412fd69db1f81db3f511c1463fd304675244077/server.jar"
if version == "1.16":
return "https://launcher.mojang.com/v1/objects/a0d03225615ba897619220e256a266cb33a44b6b/server.jar"
else:
print("currently not stored as script is in alpha")
return "n"
def getSystemRam():
import platform,socket,re,uuid,json,psutil
try:
return int(round(psutil.virtual_memory().total / (1024.0 **3)))
except Exception as e:
print(e)
def web(url):
try:
import webbrowser
webbrowser.open(url, new=0, autoraise=True)
except:
print("problem opening website")
def eulamaker():
file = open("eula.txt","w")
content = "#By changing the setting below to TRUE you are indicating your agreement to our EULA (https://account.mojang.com/documents/minecraft_eula).\n#Mon Aug 17 19:04:18 BST 2020\neula=True"
file.write(content)
file.close()
def config():
global port, serverip
file = open("server.properties","w")
print("tool loaded")
run = True
while run == True:
try:
spawnp = str("spawn-protection=" + str(int(input("how many block of spawn do you want protected? "))) + "\n")
tickmax = "max-tick-time=60000\n"
port = str(int(input("what is the port number of server default minecraft server is 25565 > "))) + "\n"
qport = "querry.port =" + str(port)
generator = "generator-setting=\n"
sync = "sync-chunk-writes=true\n"
force = "force-gamemode=false"
nether = "allow-nether="+ str(input("allow nether?\nwrite false to disable\nwrite true to enable\n > ") + "\n")
enforcwhitelist = "enforce-whitelist=false\n"
gamemode = "force-gamemode=false\n"
console = "broadcast-console-to-ops=" + str(input("would you like to broadcast console to operators/op?\nwrite true to enable\nwrite false to disable\n > "))+ "\n"
enqury = "enable-query=false\n"
monsters = "spawn-monsters=" + str(input("would you like to spawn monsters?\nwrite true to enable\nwrite false to disable\n > ")) + "\n"
broadron = "broadcast-rcon-to-ops=true\n"
oppremission = "op-permission-level=" + str(4) + "\n"
pvp = "pvp=" + str(input("would you like pvp?\nwrite true to enable\nwrite false to disable\n > ")) + "\n"
enitbroad = "entity-broadcast-range-percentage=100\n"
difficulty = "difficulty=" + str(input("what difficulty would you want?\nwrite 0 for peaceful\nwrite 1 for easy\nwrite 2 for medium\nwrite 3 for hard\n > ")) + "\n"
playeridletimeout = "player-idle-timeout=0" + "\n"
snooper = "snooper-enable=true" + "\n"
level = "level-type=" + input("what level type would you want? superflat or default? ") + "\n"
enablestatus = "enablestatus=true\n"
hardcore = "hardcore=" + str(input("active hardcore?\nwrite false to disable\nwrite true to enable\n > "))+ "\n"
commandblock = "enable-command-block=" + str(input("allow commandblock?\nwrite false to disable\nwrite true to enable\n > "))+ "\n"
playersize = "max-player=" + str(input("how many player allowed to join recommended for normal system 10-20? ")) + "\n"
networkcompressionthreshold = "network-compression-threshold=256" + "\n"
worldsize = "max-world-size=29999984\n"
resourcepacksha1= "resource-pack-sha1=\n"
funcpre = "function-permission-level=2\n"
rconport = "rcon.port=25575" + "\n"
serverport = "server-port=" + str(port) + "\n"
import socket
serverip = "server-ip=" + str(socket.gethostbyname(socket.gethostname())) + "\n"
npc = "spawn-npcs="+ str(input("allow spawning of npcs?\nwrite false to disable\nwrite true to enable\n > "))+ "\n"
flight = "allow-flight=" + str(input("allow flight in none creative can be unstable?\nwrite false to disable\nwrite true to enable\n > "))+ "\n"
levelname = "level-name=world\n"
viewdistance = "view-distance=" + str(input("what view distance do you want on server recommended for normal system 10-20? ")) + "\n"
resourcepack= "resource-pack=\n"
spawnanimal = "spawn-animal=" + str(input("allow spawning of animals?\nwrite false to disable\nwrite true to enable\n > "))+ "\n"
whitelist = "whitelist=false\n"
rpass = "rcon.password=\n"
generatestruc = "generate-structures=" + str(input("allow generating of structures?\nwrite false to disable\nwrite true to enable\n > "))+ "\n"
onlinemode = "online-mode=" + str(input("disable or enable online mode this will allow if disabled cracked accounts but allows game to run without internet?\nwrite false to disable\nwrite true to enable\n > "))+ "\n"
maxbuild = "max-build-height=256\n"
levelseed = "level-seed=" + input("what is the seed? ") + "\n"
proxy = "prevent-proxy-conenctions=false\n"
unt = "use-native-transport=true\n"
enablejmx = "enable-jmx-monitoring=false\n"
motd = "motd=" + input("what is the moto of the server? ") + "\n"
enablercon = "enable-rcon=false\n"
final = spawnp + tickmax + qport + generator + sync + force + nether + enforcwhitelist + gamemode + console + enqury + playeridletimeout + difficulty +broadron+monsters+oppremission+pvp+enitbroad+snooper+level+enablestatus+hardcore+commandblock+playersize+networkcompressionthreshold+worldsize+resourcepacksha1
final = final + funcpre +rconport + serverport +serverip+npc+flight+levelname+viewdistance+resourcepack+spawnanimal+whitelist+rpass+generatestruc+onlinemode+maxbuild+levelseed+proxy+unt+enablejmx+motd+enablercon
print("generating properties file")
print(final)
file.write(final)
run = False
except:
print("invaild")
file.close()
def isOpen(ip, port):
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.settimeout(timeout)
try:
s.connect((ip, int(port)))
s.shutdown(socket.SHUT_RDWR)
return True
except:
return False
finally:
s.close()
def ipconfig():
print("opening ipconfig script")
file = open("ipconfig.bat","w")
file.write("c:\windows\system32\ipconfig\necho gateway is what you need\npause")
file.close()
import subprocess
subprocess.call([r'ipconfig.bat'])
def portforwarding():
global port, serverip
print("\n\n")
print("this is the hard part")
print("because I am one person who lives in one country I can't say what your router port forwarding looks like")
print("but i can give you default gateway and a checker and search youtube.")
choice= input("before that do you just want lan only? if so you can skip to starting the server?\n1.yes\n2.no\n> ")
if choice == "1":
print("okay")
else:
runport = True
while runport == True:
with concurrent.futures.ThreadPoolExecutor(max_workers=4) as executor:
routername = input("what is your routers name? ")
print("your port number is " + str(port))
print("your local ip is " + str(serverip))
web("https://www.youtube.com/results?search_query=" + routername + "+portforwarding")
executor.submit(ipconfig)
input("hit enter to continue...")
print("\n\n")
runport = False
def startup():
global version, port
print("hello lets start off with somethings.")
print("\n")
print("forge/craftbucket/beta and alpha autocomplete is not in this version of script")
print("format e.g 1.16.2, 1.9.")
print("\n")
run = 1
while run == 1:
version = input("what version of minecraft are you playing? ")
print("\n\n")
print("starting download don't close program...")
result = versionfinder()
if result == "n":
print("not vaild version")
print("\n")
else:
print("version found " + version)
run = download(result)
print("\n\n")
print("making batch launcher for server")
print("calculating recommend ram")
rama = getSystemRam()
ramamount = int(rama * 0.425 * 1024)
print("using recommend size of " + str(ramamount) + "M")
batch = "echo starting server\njava -Xmx" + str(ramamount) + "M -Xms512M -jar server.jar\necho server stopped"
file = open("run.bat","w")
file.write(batch)
file.close()
print("done eula required")
run = True
while run == True:
print("\n\n")
agree = input("do you agree to mojang eula.\nplease write yes\nto see eula type web.\n> ")
if agree == "no":
run = False
quit
if agree == "web":
web("https://account.mojang.com/documents/minecraft_eula")
if agree == "yes":
eulamaker()
run = False
print("time to config worlds and options")
print("starting configuation tool")
config()
print("laststep port forwarding ")
portforwarding()
print("your ready to start")
print("\n\n\n\n")
def main():
try:
f = open("server.jar","r")
f.close()
input("press enter to start server....")
serverstart()
print("server stopped")
quit
except:
startup()
if __name__ == '__main__':
main()