-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
145 lines (120 loc) · 4.41 KB
/
main.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
import makerbot, oldservermaker
import time
from subprocess import check_output
def autoSetup():
GenerateStartup()
runner = True
while runner:
print("Attempting to Start jar file")
print("please type Stop into console to finish")
output= check_output(['java', '-jar', 'server.jar'])
decoded = output.decode()
print(decoded + "\n\n\n")
if decoded.find("You need to agree to the EULA in order to run the server") != -1:
file = open("eula.txt","r")
hold =file.read()
file.close()
run = True
while run:
try:
choice = int(input(hold + "\nDo you agree to the Eula\n1.yes\n2.no\n>"))
if (choice == 1):
run = False
print("Accepting Eula")
file = open("eula.txt","w")
hold = hold.replace("false","true")
print(hold)
file.write(hold)
file.close()
elif (choice ==2):
print("you can't proceed with setting up Mincraft")
return False
except Exception as e:
print("\nnot a valid choice\n")
time.sleep(1)
else:
print("\nSuccess your server runs... Exiting\n")
run = False
runner = False
def ChangeConfig():
run = True
while run:
try:
choice = int(input("\n1.Lagacy Creation config file(long)\n2.Search file\n3.Exit\n>"))
if choice == 1:
oldservermaker.config()
elif choice == 2:
search =input("Search Property?")
file = open("server.properties","r")
find = file.read().split("\n")
index = -1
file.close()
for i in range(0,len(find)):
if find[i].find(search) != -1:
index = i
if index == -1:
print("not found")
else:
print(find[index] + "\nedit?\n")
edit = input(">")
find[index] = find[index].split("=")[0] + "=" + edit
print(find[index])
print("Writting")
file = open("server.properties","w")
for item in find:
file.write(item + "\n")
file.close()
elif choice == 3:
run = False
except:
print("\nnot valid\n")
def GenerateStartup():
#get ram in gigabytes
rama =oldservermaker.getSystemRam()
ramamount = int(rama * 0.3 * 1024)
print("using recommend size of " + str(ramamount) + "M")
batch = "echo starting server\njava -Xmx" + str(ramamount) + "M -jar server.jar\necho server stopped"
from sys import platform
if platform == "win32":
# Windows...
file = open("run.bat","w")
file.write(batch)
file.close()
else:
# linux etc..?
file = open("run.sh","w")
file.write(batch)
file.close()
def main():
run = True
while run:
try:
choice = int(input("1.output all Minecraft versions\n2.slient Load\n>"))
if (choice == 1):
run = False
ClassRunner = makerbot.MakerBot(False)
elif (choice ==2):
run = False
ClassRunner = makerbot.MakerBot(True)
except Exception as e:
print("\nnot a valid choice\n")
time.sleep(1)
run = True
while run:
try:
choice = int(input("\n1.AutoSetup\n2.ChangeConfig\n3.StartupMaker\n4.Exit\n>"))
if (choice ==1):
autoSetup()
elif (choice ==2):
print("not in use")
elif (choice ==3):
GenerateStartup()
elif (choice ==4):
run = False
quit()
except Exception as e:
print("\nnot a valid choice\n")
print(e)
time.sleep(1)
#runs main class
main()