def testServerGen(self): gen = MCServerChunkGenerator() print "Version: ", gen.serverVersion level = self.alphalevel.level gen.generateChunkInLevel(level, 50, 50) gen.generateChunksInLevel(level, [(120, 50), (121, 50), (122, 50), (123, 50), (244, 244), (244, 245), (244, 246)])
def _createChunks(): try: if versionChoice: version = versionChoice.selectedChoice else: version = None gen = MCServerChunkGenerator(version=version) except Exception, e: traceback.print_exc() alert( "Failed to start the chunk generator. {0!r}".format(e)) yield "Failed" return
def clearCache(): MCServerChunkGenerator.clearWorldCache()
def GeneratorPanel(): panel = Widget() panel.chunkHeight = 64 panel.grass = True panel.simulate = False jarStorage = MCServerChunkGenerator.getDefaultJarStorage() if jarStorage: jarStorage.reloadVersions() generatorChoice = ChoiceButton(["Minecraft Server", "Flatland"]) panel.generatorChoice = generatorChoice col = [Row((Label("Generator:"), generatorChoice))] noVersionsRow = Label("Will automatically download and use the latest version") versionContainer = Widget() heightinput = IntInputRow("Height: ", ref=AttrRef(panel, "chunkHeight"), min=0, max=128) grassinput = CheckBoxLabel("Grass", ref=AttrRef(panel, "grass")) flatPanel = Column([heightinput, grassinput], align="l") def generatorChoiceChanged(): serverPanel.visible = generatorChoice.selectedChoice == "Minecraft Server" flatPanel.visible = not serverPanel.visible generatorChoice.choose = generatorChoiceChanged versionChoice = None if len(jarStorage.versions): def checkForUpdates(): def _check(): yield jarStorage.downloadCurrentServer() yield showProgress("Checking for server updates...", _check()) versionChoice.choices = sorted(jarStorage.versions, reverse=True) versionChoice.choiceIndex = 0 versionChoice = ChoiceButton(sorted(jarStorage.versions, reverse=True)) versionChoiceRow = (Row(( Label("Server version:"), versionChoice, Label("or"), Button("Check for Updates", action=checkForUpdates)))) panel.versionChoice = versionChoice versionContainer.add(versionChoiceRow) else: versionContainer.add(noVersionsRow) versionContainer.shrink_wrap() menu = Menu("Advanced", [ ("Open Server Storage", "revealStorage"), ("Reveal World Cache", "revealCache"), ("Delete World Cache", "clearCache") ]) def presentMenu(): i = menu.present(advancedButton.parent, advancedButton.topleft) if i != -1: (revealStorage, revealCache, clearCache)[i]() advancedButton = Button("Advanced...", presentMenu) @alertException def revealStorage(): mcplatform.platform_open(jarStorage.cacheDir) @alertException def revealCache(): mcplatform.platform_open(MCServerChunkGenerator.worldCacheDir) #revealCacheRow = Row((Label("Minecraft Server Storage: "), Button("Open Folder", action=revealCache, tooltipText="Click me to install your own minecraft_server.jar if you have any."))) @alertException def clearCache(): MCServerChunkGenerator.clearWorldCache() simRow = CheckBoxLabel("Simulate world", ref=AttrRef(panel, "simulate"), tooltipText="Simulate the world for a few seconds after generating it. Reduces the save file size by processing all of the TileTicks.") simRow = Row((simRow, advancedButton), anchor="lrh") #deleteCacheRow = Row((Label("Delete Temporary World File Cache?"), Button("Delete Cache!", action=clearCache, tooltipText="Click me if you think your chunks are stale."))) serverPanel = Column([versionContainer, simRow, ], align="l") col.append(serverPanel) col = Column(col, align="l") col.add(flatPanel) flatPanel.topleft = serverPanel.topleft flatPanel.visible = False panel.add(col) panel.shrink_wrap() def generate(level, arg): useServer = generatorChoice.selectedChoice == "Minecraft Server" if useServer: def _createChunks(): try: if versionChoice: version = versionChoice.selectedChoice else: version = None gen = MCServerChunkGenerator(version=version) except Exception, e: traceback.print_exc() alert("Failed to start the chunk generator. {0!r}".format(e)) yield "Failed" return if isinstance(arg, BoundingBox): for i in gen.createLevelIter(level, arg, simulate=panel.simulate): yield i else: for i in gen.generateChunksInLevelIter(level, arg, simulate=panel.simulate): yield i else:
def GeneratorPanel(): panel = Widget() panel.chunkHeight = 64 panel.grass = True panel.simulate = False jarStorage = MCServerChunkGenerator.getDefaultJarStorage() if jarStorage: jarStorage.reloadVersions() generatorChoice = ChoiceButton(["Minecraft Server", "Flatland"]) panel.generatorChoice = generatorChoice col = [Row((Label("Generator:"), generatorChoice))] noVersionsRow = Label( "Will automatically download and use the latest version") versionContainer = Widget() heightinput = IntInputRow("Height: ", ref=AttrRef(panel, "chunkHeight"), min=0, max=128) grassinput = CheckBoxLabel("Grass", ref=AttrRef(panel, "grass")) flatPanel = Column([heightinput, grassinput], align="l") def generatorChoiceChanged(): serverPanel.visible = generatorChoice.selectedChoice == "Minecraft Server" flatPanel.visible = not serverPanel.visible generatorChoice.choose = generatorChoiceChanged versionChoice = None if len(jarStorage.versions): def checkForUpdates(): def _check(): yield jarStorage.downloadCurrentServer() yield showProgress("Checking for server updates...", _check()) versionChoice.choices = sorted(jarStorage.versions, reverse=True) versionChoice.choiceIndex = 0 versionChoice = ChoiceButton(sorted(jarStorage.versions, reverse=True)) versionChoiceRow = (Row( (Label("Server version:"), versionChoice, Label("or"), Button("Check for Updates", action=checkForUpdates)))) panel.versionChoice = versionChoice versionContainer.add(versionChoiceRow) else: versionContainer.add(noVersionsRow) versionContainer.shrink_wrap() menu = Menu("Advanced", [("Open Server Storage", "revealStorage"), ("Reveal World Cache", "revealCache"), ("Delete World Cache", "clearCache")]) def presentMenu(): i = menu.present(advancedButton.parent, advancedButton.topleft) if i != -1: (revealStorage, revealCache, clearCache)[i]() advancedButton = Button("Advanced...", presentMenu) @alertException def revealStorage(): mcplatform.platform_open(jarStorage.cacheDir) @alertException def revealCache(): mcplatform.platform_open(MCServerChunkGenerator.worldCacheDir) #revealCacheRow = Row((Label("Minecraft Server Storage: "), Button("Open Folder", action=revealCache, tooltipText="Click me to install your own minecraft_server.jar if you have any."))) @alertException def clearCache(): MCServerChunkGenerator.clearWorldCache() simRow = CheckBoxLabel( "Simulate world", ref=AttrRef(panel, "simulate"), tooltipText= "Simulate the world for a few seconds after generating it. Reduces the save file size by processing all of the TileTicks." ) simRow = Row((simRow, advancedButton), anchor="lrh") #deleteCacheRow = Row((Label("Delete Temporary World File Cache?"), Button("Delete Cache!", action=clearCache, tooltipText="Click me if you think your chunks are stale."))) serverPanel = Column([ versionContainer, simRow, ], align="l") col.append(serverPanel) col = Column(col, align="l") col.add(flatPanel) flatPanel.topleft = serverPanel.topleft flatPanel.visible = False panel.add(col) panel.shrink_wrap() def generate(level, arg): useServer = generatorChoice.selectedChoice == "Minecraft Server" if useServer: def _createChunks(): try: if versionChoice: version = versionChoice.selectedChoice else: version = None gen = MCServerChunkGenerator(version=version) except Exception, e: traceback.print_exc() alert( "Failed to start the chunk generator. {0!r}".format(e)) yield "Failed" return if isinstance(arg, BoundingBox): for i in gen.createLevelIter(level, arg, simulate=panel.simulate): yield i else: for i in gen.generateChunksInLevelIter( level, arg, simulate=panel.simulate): yield i else: