Skip to content

Commit 4565f63

Browse files
author
Kendrick
committed
Merge branch 'master' of https://github.com/kvimber/MCStation
2 parents 87f5b77 + 1eadea2 commit 4565f63

File tree

3 files changed

+36
-17
lines changed

3 files changed

+36
-17
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
/server/
2020
# ignore pass file
2121
/core/pass.txt
22+
/core/pass.mcs
2223
# ignore mapping system
2324
/mapper/
2425
# ignore binary files

core/mc_security.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import getpass
1111

1212
SEPARATOR = ":::"
13-
FILENAME = "../core/pass.txt"
13+
FILENAME = "../core/pass.mcs"
1414

1515
def get_creds(setting=False):
1616
user_name = raw_input("Username: ")

core/mc_server.py

+34-16
Original file line numberDiff line numberDiff line change
@@ -20,30 +20,31 @@
2020
class MCServer:
2121

2222
def __init__(self):
23-
print "System initializing..."
23+
print "MCStation initializing..."
2424
self.props = properties.PROPS
2525
self.p = None
2626
self.lock = threading.Lock()
2727
self.thread_id = 0
2828
self.check_platform()
2929
self.startup()
30-
print "System initialized."
30+
print "MCStation initialized."
3131

3232
#Validates the users system and properties
3333
def startup(self):
34-
# Checks to see if java is available
35-
self.jtest = subprocess.Popen(shlex.split(self.java_cmd), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
36-
(child_stdout, child_stderr) = self.jtest.communicate()
37-
if(child_stderr.startswith("java version")):
38-
print "Java found"
39-
else:
40-
raise RuntimeError("Unable to locate Java. Verify you have it installed and on your path")
41-
# Checks to see if minecraft_server.jar can be found
42-
if(os.path.exists(self.props[properties.PATH_SERVER] + "/minecraft_server.jar")):
43-
print "Minecraft found"
34+
self.check_java()
35+
self.check_minecraft()
36+
self.check_mapper()
37+
self.check_auth_system()
38+
# TODO: Check for mailer
39+
40+
def check_auth_system(self):
41+
if not os.path.exists(mc_sec.FILENAME):
42+
print "No authentication available, please create a new user below:"
43+
mc_sec.add_new_user_to_pass_store()
4444
else:
45-
raise RuntimeError("Unable to find minecraft_server.jar. Double check PROPS[PATH_SERVER] in properties.py")
46-
45+
print "Authentication system ready."
46+
47+
def check_mapper(self):
4748
# Checks to see if mapping utility can be found.
4849
try:
4950
self.props[properties.CLI_RUNMAPPER]
@@ -61,7 +62,22 @@ def startup(self):
6162
else:
6263
print "Mapping software not found. Add mapper to properties.py if you want to enable mapping functionality"
6364

64-
# TODO: Check for mailer
65+
66+
def check_minecraft(self):
67+
# Checks to see if minecraft_server.jar can be found
68+
if(os.path.exists(self.props[properties.PATH_SERVER] + "/minecraft_server.jar")):
69+
print "Minecraft found"
70+
else:
71+
raise RuntimeError("Unable to find minecraft_server.jar. Double check PROPS[PATH_SERVER] in properties.py")
72+
73+
def check_java(self):
74+
# Checks to see if java is available
75+
self.jtest = subprocess.Popen(shlex.split(self.java_cmd), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
76+
(child_stdout, child_stderr) = self.jtest.communicate()
77+
if(child_stderr.startswith("java version")):
78+
print "Java found"
79+
else:
80+
raise RuntimeError("Unable to locate Java. Verify you have it installed and on your path")
6581

6682
def start(self):
6783
if self.p is None:
@@ -161,6 +177,7 @@ def run_server(self):
161177
print "Thread " + thread.name + " started..."
162178
except KeyboardInterrupt:
163179
print "\nKeyboard Interrupt Occurred. Exiting."
180+
self.stop()
164181
break
165182

166183
def run_server_cmd(self, cmd):
@@ -293,7 +310,8 @@ def log(self, log_string):
293310

294311
def main():
295312
server = MCServer()
296-
print "Running server..."
313+
print "Starting Minecraft server..."
314+
server.start()
297315
server.run_server()
298316

299317

0 commit comments

Comments
 (0)