45 lines
1.8 KiB
Python
45 lines
1.8 KiB
Python
import zipfile, os, subprocess, shutil
|
|
|
|
jar = r'e:\MCStudioDownload\work\3027246179@qq.com\Cpp\AddOn\309c2d420bc84ee986db9cdd070ff02a\_sa_hanhua_out\sa_essentials-forge-1.20.1-1.0.0.jar'
|
|
out = r'e:\MCStudioDownload\work\3027246179@qq.com\Cpp\AddOn\309c2d420bc84ee986db9cdd070ff02a\_sa_hanhua_out\_tmp\classes'
|
|
|
|
targets = [
|
|
'com/ogaba/sa_combat/client/event/SACombatClientForgeEvents.class',
|
|
'com/ogaba/sa_combat/client/model/SAWeaponGeoModel.class',
|
|
'com/ogaba/sa_combat/client/render/NailGunAimClient.class',
|
|
'com/ogaba/sa_combat/combat/weapon/NailGunItem.class',
|
|
'com/ogaba/sa_combat/network/packet/FireNailGunC2SPacket.class',
|
|
]
|
|
|
|
with zipfile.ZipFile(jar) as z:
|
|
for t in targets:
|
|
p = os.path.join(out, t.replace('/', os.sep))
|
|
os.makedirs(os.path.dirname(p), exist_ok=True)
|
|
with open(p, 'wb') as f:
|
|
f.write(z.read(t))
|
|
print('extracted:', t)
|
|
|
|
javap = r'D:\我的世界\bin\javap.EXE'
|
|
if not os.path.exists(javap):
|
|
javap = shutil.which('javap')
|
|
|
|
report = []
|
|
for t in targets:
|
|
cname = t[:-6].replace('/', '.')
|
|
r = subprocess.run([javap, '-c', '-p', '-classpath', out, cname], capture_output=True, text=True, encoding='utf-8', errors='replace')
|
|
text = r.stdout if r.returncode == 0 else r.stderr
|
|
report.append('='*20 + ' ' + cname + ' ' + '='*20 + '\n' + text)
|
|
|
|
full = '\n\n'.join(report)
|
|
with open(r'e:\MCStudioDownload\work\3027246179@qq.com\Cpp\AddOn\309c2d420bc84ee986db9cdd070ff02a\_sa_hanhua_out\_tmp\javap_reload.txt', 'w', encoding='utf-8') as f:
|
|
f.write(full)
|
|
print('written len:', len(full))
|
|
|
|
# 输出 Reloading 相关上下文
|
|
lines = full.splitlines()
|
|
for i, line in enumerate(lines):
|
|
if 'Reload' in line or 'reload' in line.lower():
|
|
# 打印该行及其后几行(字符串常量会出现在 ldc 之后)
|
|
print('\n'.join(lines[max(0,i-1):i+6]))
|
|
print('...')
|