-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMinecraftFingerprinter.py
46 lines (39 loc) · 1.7 KB
/
MinecraftFingerprinter.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
import FingerPrinter
import sys
import os
import urllib.request
import requests
import zipfile
versionData = "https://piston-meta.mojang.com/mc/game/version_manifest_v2.json"
def getVersionURL(version):
data = requests.get(versionData).json()
versions = data["versions"]
for x in versions:
if x["id"] == version:
return x["url"]
def DownloadJar(version,side):
print('Downloading')
data = requests.get(getVersionURL(version)).json()["downloads"]
url = data[side]["url"]
zip = urllib.request.urlopen(url).read()
open(str(version)+"_"+side + '_temp.jar', 'wb+').write(zip)
if __name__ == "__main__":
version = sys.argv[1]
side = sys.argv[2]
DownloadJar(version,side)
zip = zipfile.ZipFile(str(version)+"_"+side + '_temp.jar')
if "META-INF/versions/"+str(version)+"/server-"+str(version)+".jar" in zip.namelist():
zip_in = zip.open("META-INF/versions/"+str(version)+"/server-"+str(version)+".jar", mode='r')
out = open(str(version)+"_"+side + '.jar','wb+')
out.write(zip_in.read())
zip_in.close()
out.close()
zip.close()
os.remove(str(version)+"_"+side + '_temp.jar')
else:
zip.close()
os.rename(str(version)+"_"+side + '_temp.jar',str(version)+"_"+side + '.jar')
FingerPrinter.BuildClassFilesAndHash(str(version)+"_"+side + '.jar',ignoreDirs=["commons-logging","ca","oshi-project","it","commons-io","io","org","net","com","commons-codec"],ignoreFiles=[".xsd",".xml",".dtd","der"],keepDirs=["net/minecraft","com/mojang"])
FingerPrinter.GenerateClassFingerPrint()
FingerPrinter.ExportFingerPrint(version+".jar")
os.remove(str(version)+"_"+side + '.jar')