def init(serverPK): """ Init the given server. """ mcServer = MinecraftServer.objects.get(pk = serverPK) # Get the class type that is the right type stype = getServerFromModel(mcServer = mcServer) # Server interaction object server = stype(mcServer = mcServer) # Run the init server.localInit()
def status(serverPK): """ Start a server """ # Get model objects mcServer = MinecraftServer.objects.get(pk = serverPK) # Get the class type that is the right type stype = getServerFromModel(mcServer = mcServer) # Server interaction object server = stype(mcServer = mcServer) return server.localStatus()
def stop(serverPK, warn = True, warnDelaySeconds = 0): """ Start a server """ # Get model objects mcServer = MinecraftServer.objects.get(pk = serverPK) # Get the class type that is the right type stype = getServerFromModel(mcServer = mcServer) # Server interaction object server = stype(mcServer = mcServer) return server.localStopServer(warn = warn, warnDelaySeconds = warnDelaySeconds)
def save_map(serverPK, name, desc = '', version = '', owner = None): """ Save a map. Returns MapSave PK. """ # Get model objects mcServer = MinecraftServer.objects.get(pk = serverPK) # Get the class type that is the right type stype = getServerFromModel(mcServer = mcServer) # Server interaction object server = stype(mcServer = mcServer) mapPK = server.localSaveMap(name = name, desc = desc, version = version, owner = owner) return mapPK
def updateDB_MCConfig(configPK): """ Update the given server.properties config file """ mcp = MinecraftServerProperties.get(docid=configPK) mcServer = MinecraftServer.objects.get(pk=mcp.nc_minecraftServerPK) # Get the class type that is the right type stype = getServerFromModel(mcServer=mcServer) # Server interaction object server = stype(mcServer=mcServer) # # Run the init # server.localInit() cfg = ServerProperitiesConfigFileType(serverDir=server.getServerRoot(), minecraftServerObj=server) server.localUpdateDBConfigFile(cfg)
def loadMap(serverPK, mapPK): """ Init the given server. TODO: Add support for saving the existing map if one exists. """ # Get model objects mcServer = MinecraftServer.objects.get(pk = serverPK) mapSave = MapSave.objects.get(pk = mapPK) # Get the class type that is the right type stype = getServerFromModel(mcServer = mcServer) # Server interaction object server = stype(mcServer = mcServer) # Load the map server.localLoadMap(mapSave)
def createFile_MCConfig(configPK): """ Update the given server.properties config file """ # FIXME: Add in file locking to prevent race conditions around this mcp = MinecraftServerProperties.get(docid=configPK) mcServer = MinecraftServer.objects.get(pk=mcp.nc_minecraftServerPK) # Get the class type that is the right type stype = getServerFromModel(mcServer=mcServer) # Server interaction object server = stype(mcServer=mcServer) # # Run the init # server.localInit() cfg = ServerProperitiesConfigFileType(serverDir=server.getServerRoot(), minecraftServerObj=server) server.localUpdateConfigFile(cfg, preChangeSHA512=None)
def restart(serverPK, warn = True, warnDelaySeconds = 0): """ Restart a server """ # Get model objects mcServer = MinecraftServer.objects.get(pk = serverPK) # Get the class type that is the right type stype = getServerFromModel(mcServer = mcServer) # Server interaction object server = stype(mcServer = mcServer) results=dict(start=None,stop=None) results['stop'] = stop( serverPK = mcServer.pk, warn = warn, warnDelaySeconds = warnDelaySeconds, ) # Make sure the stop worked if results['stop']: results['start'] = start(serverPK = mcServer.pk) return results