-
-
Notifications
You must be signed in to change notification settings - Fork 17
/
generateLiteloader.py
executable file
·88 lines (79 loc) · 3.32 KB
/
generateLiteloader.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/usr/bin/python3
from liteloaderutil import *
from jsonobject import *
from datetime import datetime
from pprint import pprint
import copy
# load the locally cached version list
def loadLiteloaderJson():
with open("upstream/liteloader/versions.json", 'r', encoding='utf-8') as f:
return LiteloaderIndex(json.load(f))
remoteVersionlist = loadLiteloaderJson()
def processArtefacts(mcVersion, liteloader, notSnapshots):
versions = []
lookup = {}
latestVersion = None
latest = None
for id, artefact in liteloader.items():
if id == 'latest':
latestVersion = artefact.version
continue
version = MultiMCVersionFile(name="LiteLoader", uid="com.mumfrey.liteloader", version=artefact.version)
version.requires = [DependencyEntry(uid='net.minecraft', equals=mcVersion)]
version.releaseTime = datetime.utcfromtimestamp(int(artefact.timestamp))
version.addTweakers = [artefact.tweakClass]
version.mainClass = "net.minecraft.launchwrapper.Launch"
version.order = 10
if notSnapshots:
version.type = "release"
else:
version.type = "snapshot"
lookup[version.version] = version
libraries = artefact.libraries
# hack to make broken liteloader versions work
for lib in libraries:
if lib.name == GradleSpecifier("org.ow2.asm:asm-all:5.0.3"):
lib.url = "https://repo.maven.apache.org/maven2/"
if lib.name == GradleSpecifier("org.ow2.asm:asm-all:5.2"):
lib.url = "http://repo.liteloader.com/"
liteloaderLib = MultiMCLibrary(
name=GradleSpecifier("com.mumfrey:liteloader:%s" % version.version),
url = "http://dl.liteloader.com/versions/"
)
if not notSnapshots:
liteloaderLib.mmcHint = "always-stale"
libraries.append(liteloaderLib)
version.libraries = libraries
versions.append(version)
if latestVersion:
latest = lookup[latestVersion]
return versions, latest
allVersions = []
recommended = []
for mcVersion, versionObject in remoteVersionlist.versions.items():
# ignore this for now. It should be a jar mod or something.
if mcVersion == "1.5.2":
continue
latestSnapshot = None
latestRelease = None
version = []
if versionObject.artefacts:
versions, latestRelease = processArtefacts(mcVersion, versionObject.artefacts.liteloader, True)
allVersions.extend(versions)
if versionObject.snapshots:
versions, latestSnapshot = processArtefacts(mcVersion, versionObject.snapshots.liteloader, False)
allVersions.extend(versions)
if latestRelease:
recommended.append(latestRelease.version)
recommended.sort()
allVersions.sort(key=lambda x: x.releaseTime, reverse=True)
for version in allVersions:
outFilepath = "multimc/com.mumfrey.liteloader/%s.json" % version.version
with open(outFilepath, 'w') as outfile:
json.dump(version.to_json(), outfile, sort_keys=True, indent=4)
sharedData = MultiMCSharedPackageData(uid = 'com.mumfrey.liteloader', name = 'LiteLoader')
sharedData.recommended = recommended
sharedData.description = remoteVersionlist.meta.description
sharedData.projectUrl = remoteVersionlist.meta.url
sharedData.authors = [remoteVersionlist.meta.authors]
sharedData.write()