SteamWar/BungeeCore
Archiviert
13
2
Dieses Repository wurde am 2024-08-05 archiviert. Du kannst Dateien ansehen und es klonen, aber nicht pushen oder Issues/Pull-Requests öffnen.
BungeeCore/deployarena.py
Lixfel 0c3f200a91
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Fix deployarena.py gamemode file loading
Signed-off-by: Lixfel <agga-games@gmx.de>
2023-08-19 12:59:00 +02:00

86 Zeilen
3.5 KiB
Python
Ausführbare Datei

#!/usr/bin/env python3
import datetime
import os
import shutil
import sys
import tarfile
from os import path
# Non stdlib
import yaml
from nbt import nbt
if __name__ == "__main__":
configfile = f'/configs/GameModes/{sys.argv[1]}'
version = int(sys.argv[2])
worldname = sys.argv[3]
with open(configfile, 'r') as file:
gamemode = yaml.load(file, Loader=yaml.CLoader)
builderworld = path.expanduser(f'~/builder{version}/{worldname}')
arenaworld = f'/servers/{gamemode["Server"]["Folder"]}/arenas/{worldname}'
if path.exists(arenaworld):
backupworld = path.expanduser(f'~/backup/arenas/{datetime.datetime.now()}-{worldname}-{version}.tar.xz')
with tarfile.open(backupworld, 'w:xz') as tar:
tar.add(arenaworld, arcname=worldname)
shutil.rmtree(arenaworld)
else:
gamemode['Server']['Maps'].append(worldname)
with open(configfile, 'w') as file:
yaml.dump(gamemode, file)
level = nbt.NBTFile(f'{builderworld}/level.dat')
level['Data']['Difficulty'] = nbt.TAG_Byte(2)
gameRules = level['Data']['GameRules']
gameRules['announceAdvancements'] = nbt.TAG_String('false')
gameRules['disableRaids'] = nbt.TAG_String('true')
gameRules['doDaylightCycle'] = nbt.TAG_String('false')
gameRules['doEntityDrops'] = nbt.TAG_String('false')
gameRules['doFireTick'] = nbt.TAG_String('true')
gameRules['doImmediateRespawn'] = nbt.TAG_String('true')
gameRules['doInsomnia'] = nbt.TAG_String('false')
gameRules['doLimitedCrafting'] = nbt.TAG_String('false')
gameRules['doMobLoot'] = nbt.TAG_String('false')
gameRules['doMobSpawning'] = nbt.TAG_String('false')
gameRules['doPatrolSpawning'] = nbt.TAG_String('false')
gameRules['doTileDrops'] = nbt.TAG_String('true')
gameRules['doTraderSpawning'] = nbt.TAG_String('false')
gameRules['doWardenSpawning'] = nbt.TAG_String('false')
gameRules['doWeatherCycle'] = nbt.TAG_String('false')
gameRules['drowningDamage'] = nbt.TAG_String('true')
gameRules['fallDamage'] = nbt.TAG_String('true')
gameRules['fireDamage'] = nbt.TAG_String('true')
gameRules['freezeDamage'] = nbt.TAG_String('true')
gameRules['keepInventory'] = nbt.TAG_String('true')
gameRules['lavaSourceConversion'] = nbt.TAG_String('false')
gameRules['maxEntityCramming'] = nbt.TAG_String('24')
gameRules['mobGriefing'] = nbt.TAG_String('false')
gameRules['naturalRegeneration'] = nbt.TAG_String('false')
gameRules['randomTickSpeed'] = nbt.TAG_String('3')
gameRules['reducedDebugInfo'] = nbt.TAG_String('true')
gameRules['snowAccumulationHeight'] = nbt.TAG_String('1')
gameRules['spawnRadius'] = nbt.TAG_String('0')
gameRules['spectatorsGenerateChunks'] = nbt.TAG_String('true')
gameRules['waterSourceConversion'] = nbt.TAG_String('true')
level.write_file()
if path.exists(arenaworld):
shutil.rmtree(arenaworld)
os.makedirs(f'{arenaworld}/backup')
shutil.copy2(f'{builderworld}/level.dat', f'{arenaworld}/backup/level.dat')
shutil.copytree(f'{builderworld}/region', f'{arenaworld}/backup/region')
shutil.copy2(f'{builderworld}/level.dat', f'{arenaworld}/level.dat')
shutil.copytree(f'{builderworld}/region', f'{arenaworld}/region')
shutil.copy2(f'{builderworld}/config.yml', f'{arenaworld}/config.yml')
if path.exists(f'{builderworld}/paper-world.yml'):
shutil.copy2(f'{builderworld}/paper-world.yml', f'{arenaworld}/backup/paper-world.yml')
shutil.copy2(f'{builderworld}/paper-world.yml', f'{arenaworld}/paper-world.yml')