28 lines
1.2 KiB
Python
28 lines
1.2 KiB
Python
import zipfile, os, subprocess
|
|
|
|
base = r"e:\MCStudioDownload\work\3027246179@qq.com\Cpp\AddOn\0aaaa4f2f16c46e8964025a5ab0ecc02\_sa_hanhua_out"
|
|
jar = os.path.join(base, "sa_essentials-forge-1.20.1-1.0.0.jar")
|
|
out = os.path.join(base, "_tmp", "herb_javap")
|
|
os.makedirs(out, exist_ok=True)
|
|
|
|
classes = [
|
|
"com/ogaba/sa_survival/item/common/ConsumableEffectItem.class",
|
|
"com/ogaba/sa_survival/item/common/ConsumableEffectItem$Builder.class",
|
|
"com/ogaba/sa_survival/loot/HostileHerbLootModifier.class",
|
|
]
|
|
with zipfile.ZipFile(jar) as z:
|
|
for c in classes:
|
|
if c in z.namelist():
|
|
with open(os.path.join(out, os.path.basename(c)), 'wb') as f:
|
|
f.write(z.read(c))
|
|
else:
|
|
print("MISSING", c)
|
|
|
|
for c in classes:
|
|
name = os.path.basename(c)[:-6]
|
|
full = "com.ogaba.sa_survival." + c.split("com/ogaba/sa_survival/")[1][:-6].replace('/', '.')
|
|
txt = subprocess.run(["javap", "-p", "-c", "-classpath", jar, full],
|
|
capture_output=True, text=True, errors='ignore').stdout
|
|
with open(os.path.join(out, name + ".txt"), 'w', encoding='utf-8') as f:
|
|
f.write(txt)
|
|
print("WROTE", name, len(txt)) |