def checkTravisBuild(path): if not ServerFS.checkForFile(path, "server.json"): Logger.log("error", "Couldn't find server.json file.") os._exit(1) if os.path.getsize(f'{path}/server.json') == 0: Logger.log("error", "The server.json file is empty.") os._exit(1) print("Build success.") os._exit(0)
def unload(plugin): PluginLoader.setValues(plugin) if PluginLoader.main.rsplit('.', 1)[0] in sys.modules: PluginLoader.pluginModule = importlib.import_module( PluginLoader.main.rsplit('.', 1)[0]) pluginClass = getattr(PluginLoader.pluginModule, PluginLoader.main.rsplit('.', 1)[1]) Logger.log('info', f'Unloading {PluginLoader.name}...') pluginClass.onStop() Logger.log('success', f'Successfully unloaded {PluginLoader.name}!') pluginClass.onStopped() del sys.modules[PluginLoader.main.rsplit('.', 1)[0]] del PluginLoader.loadedPluginFiles[plugin] del PluginLoader.loadedPluginNames[PluginLoader.name] PluginLoader.loadedPluginsList = list( PluginLoader.loadedPluginNames.keys()) PluginLoader.loadedPluginsCount = len( PluginLoader.loadedPluginNames)
def __init__(self, path, withWizard, isTravisBuild=False): super().__init__() startTime = Utils.microtime(True) self.path = path self.withWizard = withWizard if (withWizard): ServerFS.checkAllFiles(path) else: Wizard.skipWizard(path, True) port = self.port print(str(self.podrumLogo)) Wizard.isInWizard = False Logger.log( 'info', str(Base.get("startingServer")).replace( "{ip}", str(Utils.getPrivateIpAddress())).replace("{port}", str(port))) Logger.log( 'info', str(Base.get("extIpMsg")).replace("{ipPublic}", str(Utils.getPublicIpAddress()))) Logger.log('info', str(Base.get("license"))) server = PyRakLibServer(port=19132) handler = ServerHandler(server, None) handler.sendOption( "name", "MCPE;Podrum powered server;407;1.16.0;0;0;0;PodrumPoweredServer;0" ) repeter = 0 while repeater >= 1: pass # Here is going to be the place for the packet handling doneTime = Utils.microtime(True) finishStartupSeconds = "%.3f" % (doneTime - startTime) Logger.log( 'info', f'Done in {str(finishStartupSeconds)}s. Type "help" to view all available commands.' ) if (isTravisBuild): Server.checkTravisBuild(path) else: while Wizard.isInWizard == False: cmd = input('> ') Server.command(cmd, True) cmd = None ticking = True while ticking: time.sleep(0.002)
def command(string, fromConsole): if string.lower() == 'stop': Logger.log('info', 'Stopping server...') Utils.killServer() elif string.lower() == '': return elif string.lower() == 'help': Logger.log('info', '/stop: Stops the server') else: Logger.log('error', str(Base.get("invalidCommand")))
def __init__(self, path, withWizard, isTravisBuild=False): super().__init__() startTime = Utils.microtime(True) self.path = path self.withWizard = withWizard self.tickrate = 20 / 1000 if (withWizard): ServerFS.checkAllFiles(path) else: Wizard.skipWizard(path, True) print(str(self.podrumLogo)) Wizard.isInWizard = False Logger.log( 'info', str(Base.get("startingServer")).replace( "{ip}", str(Utils.getPrivateIpAddress())).replace( "{port}", str(self.port))) Logger.log( 'info', str(Base.get("extIpMsg")).replace("{ipPublic}", str(Utils.getPublicIpAddress()))) Logger.log('info', str(Base.get("license"))) PluginLoader.loadAll() doneTime = Utils.microtime(True) self.queryHandler = QueryHandler(self) self.mainInterface = NetworkInterface(self) self.mainInterface.process() finishStartupSeconds = "%.3f" % (doneTime - startTime) Logger.log( 'info', f'Done in {str(finishStartupSeconds)}s. Type "help" to view all available commands.' ) if (isTravisBuild): Server.checkTravisBuild(path) else: while Wizard.isInWizard == False: cmd = input('> ') Server.command(cmd, True) cmd = None ticking = True while ticking: time.sleep(self.tickrate)
def load(plugin): if Plugin.getName(plugin) in PluginLoader.loadedPluginNames: Logger.log('alert', f'Disabling duplicate plugin {Plugin.getName(plugin)}') return PluginLoader.setValues(plugin) sys.path.insert(0, plugin) PluginLoader.pluginModule = importlib.import_module( PluginLoader.main.rsplit('.', 1)[0]) pluginClass = getattr(PluginLoader.pluginModule, PluginLoader.main.rsplit('.', 1)[1]) Logger.log('info', f'Loading {PluginLoader.name}...') pluginClass.onStart() Logger.log('success', f'Successfully loaded {PluginLoader.name}!') pluginClass.onStarted() PluginLoader.loadedPluginFiles.update({plugin: plugin}) PluginLoader.loadedPluginNames.update( {PluginLoader.name: PluginLoader.name}) PluginLoader.loadedPluginsList = list( PluginLoader.loadedPluginNames.keys()) PluginLoader.loadedPluginsCount = len(PluginLoader.loadedPluginNames)
def command(string, fromConsole): if string.lower() == 'stop': Logger.log('info', 'Stopping server...') PluginLoader.unloadAll() Logger.log('info', 'Server stopped.') Utils.killServer() elif string.lower() == '': return elif string.lower() == 'help': Logger.log('info', '/stop: Stops the server') elif string.lower() == 'reload': PluginLoader.reloadAll() Logger.log('info', 'Reload successful!') elif string.lower() == 'plugins' or string.lower() == 'pl': pluginsString = "" for pluginName in PluginLoader.loadedPluginsList: pluginsString = pluginsString + pluginName if pluginName != PluginLoader.loadedPluginsList[ PluginLoader.loadedPluginsCount - 1]: pluginsString += ", " Logger.log( 'info', f'Plugins({PluginLoader.loadedPluginsCount}): {pluginsString}') else: Logger.log('error', str(Base.get("invalidCommand")))