def generateCustomScoreboardCommands(dump, prefix, statSetupFile,
                                     statUninstallFile):
    with open(dump, newline='') as dumpCSV:
        dumpReader = csv.reader(dumpCSV, delimiter=',', quotechar='"')
        # Skip heading
        dumpReader.__next__()
        # For every row of the csv dump file
        for row in dumpReader:
            # The registryID of the custom stat
            registryID = row[1]

            # Generate the internal name
            internalName = replaceXwithY("minecraft.custom:", "", registryID)
            internalName = replaceXwithY("\.", "_", internalName)
            internalName = f'{prefix}_{internalName}'

            # Generate the displayName
            displayName = replaceXwithY("minecraft.custom:minecraft.", "",
                                        registryID)
            displayName = f'"{displayNameFromRegistry(displayName)}"'

            # Generate the setup command
            setupCommand = f'scoreboard objectives add {internalName} {registryID} {displayName}'

            # Write the setup command
            writeToFile(setupCommand, statSetupFile)

            # Generate the uninstall command
            uninstallCommand = f'scoreboard objectives remove {internalName}'

            # Write the uninstall command
            writeToFile(uninstallCommand, statUninstallFile)
예제 #2
0
 def writeToFile(self):
     utils.writeToFile(self.intent, self.filepath + self.name + '.json')
예제 #3
0
 def writeToFile(self):
     utils.writeToFile(self.intent, self.filepath + self.name + '.json')
     utils.writeToFile(self.usersays,
                       self.filepath + self.name + '_usersays_en.json')
예제 #4
0
from utils.querys import fetchGraphQL
from utils.utils import writeToFile
import json
"""
reportSet = set()
for page in range(1, 6):
    query = f'''
    {{
        worldData {{
            encounter(id: 1120) {{
                characterRankings(
                    className: "Mage"
                    includeCombatantInfo: false
                    page: {page}
                )
            }}
        }}
    }}
    '''
    response = fetchGraphQL(query).get('worldData').get('encounter').get('characterRankings').get('rankings')
    for item in response:
        reportSet.add(item.get('report').get('code'))
writeToFile(data=list(reportSet), filename='rankings.json')
"""
"""
data = open('rankings.json')
data = json.load(data)
for code in data:
    query = f'''
        {{
            reportData {{
예제 #5
0
                         f'setup{customStatTypeNoun}Stats.mcfunction')
    statUninstallFile = Path(uninstallDir /
                             f'uninstall{customStatTypeNoun}Stats.mcfunction')

    # Generates the setup and uninstall commands
    generateCustomScoreboardCommands(customDump, customStatTypePrefix,
                                     statSetupFile, statUninstallFile)

# Generates all general stats
for generalStatTypeNoun, generalStatTypePrefix in generalStatTypeNouns.items():
    # Generate the file path for the setup and uninstall file
    statSetupFile = Path(setupDir /
                         f'setup{generalStatTypeNoun}Stats.mcfunction')
    statUninstallFile = Path(uninstallDir /
                             f'uninstall{generalStatTypeNoun}Stats.mcfunction')

    # Generates the setup and uninstall commands
    generateGeneralScoreboardCommands(generalDump, generalStatTypePrefix,
                                      statSetupFile, statUninstallFile)

for file in os.listdir(setupDir):
    file = Path(setupDir / file)
    with open(file) as setupFile:
        writeToFile(setupFile.read(), Path(outputDir / 'setup.mcfunction'))

for file in os.listdir(uninstallDir):
    file = Path(uninstallDir / file)
    with open(file) as uninstallFile:
        writeToFile(uninstallFile.read(),
                    Path(outputDir / 'uninstall.mcfunction'))
예제 #6
0
 def writeToFile(self):
     utils.writeToFile(self.json,
                       self.filepath + self.name + '_usersays_en.json')
예제 #7
0
 def writeToFile(self):
     utils.writeToFile(self.entrys, self.filepath)