-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate.py
29 lines (21 loc) · 986 Bytes
/
create.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
import os
import json
import requests
config = json.load(open('config.json', 'r'))
# URL for jar file
url = 'https://papermc.io/api/v1/paper/'+ config['server_version'] +'/latest/download'
# Downloading jar file
r = requests.get(url)
if r.status_code == 200:
with open('server.jar', 'wb') as f:
f.write(r.content)
print('Finished!')
else: print('Error: '+ str(r.status_code) + '\nYou entered a unsupported version. Try correcting the error in the config.json file')
# Running the jar file to create the eula.txt
ram_size = config['alloted_ram']
os.system(f"java -Xmx{ram_size} -Xms{ram_size} -jar server.jar nogui")
# Accepting EULA
with open('eula.txt', 'r') as file: filedata = file.read()
filedata = filedata.replace('eula=false', 'eula=true')
with open('eula.txt', 'w') as file: file.write(filedata)
print("Dont mind the error, your server is ready. Please run the start.bat to turn it on.\nIt may take longer than usual the first time you turn it on.")