コード例 #1
0
ファイル: Server.py プロジェクト: Catdontpat/Podrum
    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)
コード例 #2
0
ファイル: Server.py プロジェクト: genisyspromcpe/Podrum
 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")))
コード例 #3
0
ファイル: Server.py プロジェクト: jessehylton/Podrum
 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")))
コード例 #4
0
 def run(self):
     while True:
         line = input()
         if line != "":
             args = line.split()
             command = args[0]
             if CommandManager.isCommand(command):
                 CommandManager.commands[command].execute(self.server, args)
             else:
                 Logger.error(Base.getTranslation("invalidCommand"))
コード例 #5
0
ファイル: Server.py プロジェクト: genisyspromcpe/Podrum
 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)
コード例 #6
0
ファイル: Server.py プロジェクト: NullPointer-Nico-zz/Podrum
 def __init__(self, withWizard):
     super().__init__()
     self.startTime = time()
     if Utils.getOS() == "windows":
         Utils.enableWindowsFormating()
     if Utils.isPacked():
         print(Utils.getPodrumDir())
         Base.addFromZipDir(Utils.getPodrumDir(), "podrum/lang/languages")
     else:
         Base.addFromDir(Utils.getPodrumDir() + "/" + "podrum/lang/languages")
     if not Utils.checkAllFiles() and withWizard:
         Wizard.start()
         while Wizard.isInWizard:
             pass
     self.config = Utils.getDefaultConfig()
     self.ip = self.config.config["server-ip"]
     self.port = int(self.config.config["server-port"])
     print(str(self.podrumLogo))
     Logger.info(str(Base.getTranslation("startingServer")).replace("{ip}", str(self.ip)).replace("{port}", str(self.port)))
     Logger.info(str(Base.getTranslation("license")))
     RegisterVanilla()
     Plugin.pluginsDir = os.getcwd() + "/plugins"
     Plugin.server = self
     Plugin.loadAll()
     self.endTime = time()
     self.timeDiff = "%.3f" % (self.endTime - self.startTime)
     Logger.info(f'Done in {str(self.timeDiff)}s. Type "help" to view all available commands.')
     CommandReader(self)
     Interface(self.ip, self.port)
     while self.isTicking:
         sleep(self.tickrate)
コード例 #7
0
 def start():
     config = Utils.getDefaultConfig()
     step = 0
     while True:
         if step == 0:
             Base.printLanguages()
             userInput = input("> Please, select a language: ")
             if userInput in Base.languages:
                 config.config["language"] = userInput
                 print("- " + Base.getTranslation("langSelectedAsBase"))
                 step += 1
             else:
                 print("[!] That language does not exists. Please, choose one from the list.")
         elif step == 1:
             print(Wizard.podrumLicense)
             userInput = input("> " + Base.getTranslation("acceptLicense") + ": ")
             if Wizard.checkYesNo(userInput):
                 step += 1
             elif not Wizard.checkYesNo(userInput):
                 print(Base.getTranslation("mustAcceptLicense"))
             elif Wizard.checkYesNo(userInput) is None:
                 print(Base.getTranslation("writeYesOrNo"))
         elif step == 2:
             userInput = input("> " + Base.getTranslation("wizardSetup") + ": ")
             if Wizard.checkYesNo(userInput):
                 step += 1
             elif not Wizard.checkYesNo(userInput):
                 print("> " + Base.getTranslation("wizardSkipped"))
                 Wizard.isInWizard = False
                 config.save()
                 break
         elif step == 3:
             print(Wizard.podrumLogo)
             print(">- Podrum - Wizard -<\n\n")
             step += 1
         elif step == 4:
             userInput = input("[>] " + Base.getTranslation("writeServerPort") + " ")
             if userInput == "":
                 config.config["server-port"] = 19132
                 step += 1
             elif userInput.isdigit():
                 config.config["server-port"] = int(userInput)
                 step += 1
         elif step == 5:
             userInput = input("[>] " + Base.getTranslation("writeMOTD") + " ")
             if(userInput != ""):
                 config.config["motd"] = userInput
                 step += 1
         elif step == 6:
             userInput = input("[>] " + Base.getTranslation("writeGamemode") + " ")
             if userInput.isdigit():
                 if int(userInput) >= 0 and int(userInput) <= 3:
                     config.config["gamemode"] = int(userInput)
                     step += 1
         elif step == 7:
             userInput = input("[>] " + Base.getTranslation("writeMaxPlayers") + " ")
             if userInput.isdigit():
                 config.config["max-players"] = int(userInput)
                 step += 1
         elif step == 8:
             print(Base.getTranslation("wizardFinished"))
             Wizard.isInWizard = False
             config.save()
             break