2021-12-14 18:09:16 -06:00
|
|
|
#!/bin/python
|
|
|
|
# Setup Parser
|
|
|
|
import parsers.paperMC
|
|
|
|
import argparse
|
2021-12-14 20:02:16 -06:00
|
|
|
import shutil
|
2021-12-14 18:09:16 -06:00
|
|
|
parser = argparse.ArgumentParser(description='A command-line tool to update a Minecraft Server.')
|
|
|
|
parser.add_argument('api', metavar='api', help='which API to use')
|
|
|
|
parser.add_argument('project', metavar='project', help='which project to query for')
|
|
|
|
parser.add_argument('action', metavar='action', help='what action to execute')
|
|
|
|
parser.add_argument('subAction', metavar='subAction', help='what sub action to execute')
|
|
|
|
args = parser.parse_args()
|
|
|
|
print("mcUp.py, written by Caleb Fontenot")
|
|
|
|
|
|
|
|
# PaperMC command functions
|
|
|
|
def paperMC(project, action, subAction):
|
|
|
|
if action == "get":
|
|
|
|
if subAction == "versions":
|
|
|
|
print(parsers.paperMC.getVersions(project))
|
|
|
|
elif subAction == "latest":
|
|
|
|
latestVersion = parsers.paperMC.getLatest(project)
|
|
|
|
buildNumber = parsers.paperMC.getBuildNumber(project, latestVersion)
|
|
|
|
print("Latest version of "+project+" is "+latestVersion+" build #"+str(buildNumber[-1]))
|
2021-12-14 20:02:16 -06:00
|
|
|
if action == "download":
|
|
|
|
if subAction == "latest":
|
|
|
|
latestVersion = parsers.paperMC.getLatest(project)
|
|
|
|
output = parsers.paperMC.getJarInfo(project, latestVersion)
|
|
|
|
print(output["name"])
|
|
|
|
with parsers.paperMC.downloadVersion(project, latestVersion) as raw:
|
|
|
|
with open(output["name"], 'wb') as file_object:
|
|
|
|
shutil.copyfileobj(raw.raw, file_object)
|
|
|
|
print("Downloaded "+latestVersion+" to "+output["name"])
|
|
|
|
|
|
|
|
|
|
|
|
#latestVersion = parsers.paperMC.getLatest(project)
|
|
|
|
#jarInfo = parsers.paperMC.getJarInfo(project, latestVersion)
|
|
|
|
#print(jarInfo)
|
|
|
|
#print(jarInfo[0])
|
|
|
|
#print(type(jarInfo))
|
2021-12-14 18:09:16 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#print(type(getVersionVelocity))
|
|
|
|
|
|
|
|
#print("Latest build of velocity is", parsers.paperMC.getLatest#("velocity"))
|
|
|
|
|
|
|
|
# Determine which API to use:
|
|
|
|
if args.api == "paperMC":
|
|
|
|
paperMC(args.project, args.action, args.subAction)
|
|
|
|
else:
|
|
|
|
print("Error: Unknown API: "+args.api)
|