20
20
class MCServer :
21
21
22
22
def __init__ (self ):
23
- print "System initializing..."
23
+ print "MCStation initializing..."
24
24
self .props = properties .PROPS
25
25
self .p = None
26
26
self .lock = threading .Lock ()
27
27
self .thread_id = 0
28
28
self .check_platform ()
29
29
self .startup ()
30
- print "System initialized."
30
+ print "MCStation initialized."
31
31
32
32
#Validates the users system and properties
33
33
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 ()
44
44
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 ):
47
48
# Checks to see if mapping utility can be found.
48
49
try :
49
50
self .props [properties .CLI_RUNMAPPER ]
@@ -61,7 +62,22 @@ def startup(self):
61
62
else :
62
63
print "Mapping software not found. Add mapper to properties.py if you want to enable mapping functionality"
63
64
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" )
65
81
66
82
def start (self ):
67
83
if self .p is None :
@@ -161,6 +177,7 @@ def run_server(self):
161
177
print "Thread " + thread .name + " started..."
162
178
except KeyboardInterrupt :
163
179
print "\n Keyboard Interrupt Occurred. Exiting."
180
+ self .stop ()
164
181
break
165
182
166
183
def run_server_cmd (self , cmd ):
@@ -293,7 +310,8 @@ def log(self, log_string):
293
310
294
311
def main ():
295
312
server = MCServer ()
296
- print "Running server..."
313
+ print "Starting Minecraft server..."
314
+ server .start ()
297
315
server .run_server ()
298
316
299
317
0 commit comments