-
-
Notifications
You must be signed in to change notification settings - Fork 17
/
neoforgeutil.py
137 lines (115 loc) · 4.86 KB
/
neoforgeutil.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
from metautil import *
from collections import namedtuple
# A post-processed entry constructed from the reconstructed Neoforge version index
class NeoforgeVersion:
def __init__(self, entry):
self.package = entry.package
self.build = entry.build
self.rawVersion = entry.version
if self.package == "neoforge":
self.rawVersion = entry.longversion
self.mcversion = entry.mcversion
self.mcversion_sane = self.mcversion.replace("_pre", "-pre", 1)
self.branch = entry.branch
self.installer_filename = None
self.installer_url = None
self.universal_filename = None
self.universal_url = None
self.changelog_url = None
self.longVersion = entry.longversion
for classifier, fileentry in entry.files.items():
extension = fileentry.extension
filename = fileentry.filename(self.longVersion)
url = fileentry.url(self.longVersion)
if (classifier == "installer") and (extension == "jar"):
self.installer_filename = filename
self.installer_url = url
if (classifier == "universal" or classifier == "client") and (extension == "jar" or extension == "zip"):
self.universal_filename = filename
self.universal_url = url
if (classifier == "changelog") and (extension == "txt"):
self.changelog_url = url
def name(self):
return "Neoforge %d" % (self.build)
def filename(self):
return self.installer_filename
def url(self):
return self.installer_url
def isSupported(self):
if self.url() == None:
return False
versionElements = self.rawVersion.split('.')
if len(versionElements) < 1:
return False
majorVersionStr = versionElements[0]
if not majorVersionStr.isnumeric():
return False
return True
class NeoforgeFile(JsonObject):
classifier = StringProperty(required=True)
extension = StringProperty(required=True)
legacy = BooleanProperty(required=True)
def filename(self, longversion):
return "%s-%s-%s.%s" % (self.package(), longversion, self.classifier, self.extension)
def url(self, longversion):
return "https://maven.neoforged.net/releases/net/neoforged/%s/%s/%s" % (self.package(), longversion, self.filename(longversion))
def package(self):
return "forge" if self.legacy else "neoforge"
class NeoforgeEntry(JsonObject):
package = StringProperty(required=True,choices=["neoforge","forge"])
longversion = StringProperty(required=True)
mcversion = StringProperty(required=True)
version = StringProperty(required=True)
build = IntegerProperty(required=True)
branch = StringProperty()
latest = BooleanProperty()
recommended = BooleanProperty()
files = DictProperty(NeoforgeFile)
class NeoforgeMcVersionInfo(JsonObject):
latest = StringProperty()
recommended = StringProperty()
versions = ListProperty(StringProperty())
class DerivedNeoforgeIndex(JsonObject):
versions = DictProperty(NeoforgeEntry)
by_mcversion = DictProperty(NeoforgeMcVersionInfo)
class NeoforgeLibrary(MojangLibrary):
url = StringProperty(exclude_if_none=True)
serverreq = BooleanProperty(exclude_if_none=True, default=None)
clientreq = BooleanProperty(exclude_if_none=True, default=None)
checksums = ListProperty(StringProperty)
comment = StringProperty()
class NeoforgeVersionFile(MojangVersionFile):
libraries = ListProperty(NeoforgeLibrary, exclude_if_none=True, default=None) # overrides Mojang libraries
inheritsFrom = StringProperty()
jar = StringProperty()
class DataSpec(JsonObject):
client = StringProperty()
server = StringProperty()
class ProcessorSpec(JsonObject):
jar = StringProperty()
classpath = ListProperty(StringProperty)
args = ListProperty(StringProperty)
outputs = DictProperty(StringProperty)
sides = ListProperty(StringProperty, exclude_if_none=True, default=None)
class NeoforgeInstallerProfileV1(JsonObject):
_comment = ListProperty(StringProperty)
spec = DecimalProperty(required=True, choices=[1])
profile = StringProperty()
version = StringProperty()
icon = StringProperty()
json = StringProperty()
path = GradleSpecifierProperty()
logo = StringProperty()
minecraft = StringProperty()
welcome = StringProperty()
data = DictProperty(DataSpec)
processors = ListProperty(ProcessorSpec)
libraries = ListProperty(MojangLibrary)
hideExtract = BooleanProperty()
serverJarPath = StringProperty()
mirrorList = StringProperty(exclude_if_none=True, default=None)
serverJarPath = StringProperty(exclude_if_none=True, default=None)
class InstallerInfo(JsonObject):
sha1hash = StringProperty()
sha256hash = StringProperty()
size = IntegerProperty()