Skip to content

Commit

Permalink
Update Scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
hitime1234 committed Oct 5, 2023
1 parent 5bacdd9 commit 9cf9fcf
Show file tree
Hide file tree
Showing 3 changed files with 155 additions and 30 deletions.
143 changes: 143 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
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:
config = int(input("\n1.AutoSetup\n2.ChangeConfig\n3.StartupMaker\n4.Exit\n>"))
if (choice ==1):
autoSetup()
elif (choice ==2)

elif (choice ==3):
GenerateStartup()
elif (choice ==4):
run = False
quit()

except Exception as e:
print("\nnot a valid choice\n")
time.sleep(1)



#runs main class
#main()
autoSetup()
20 changes: 0 additions & 20 deletions makerbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,23 +91,3 @@ def __init__(self,slient):

print("inital Download Complete :3")


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(False)
elif (choice ==2):
run = False
ClassRunner = MakerBot(True)
except Exception as e:
print("\nnot a valid choice\n")
time.sleep(1)


#runs main class
main()
22 changes: 12 additions & 10 deletions oldservermaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,17 +221,19 @@ def startup():
print("\n\n\n\n")


try:
f = open("server.jar","r")
f.close()
input("press enter to start server....")
serverstart()
print("server stopped")
quit
except:
startup()

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()


0 comments on commit 9cf9fcf

Please sign in to comment.