Ejemplo n.º 1
0
    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)
Ejemplo n.º 2
0
 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")))
Ejemplo n.º 3
0
 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")))
Ejemplo n.º 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"))
Ejemplo n.º 5
0
 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)
Ejemplo n.º 6
0
 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)
Ejemplo n.º 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