Files
LihonT/src/RefreshClasses.java
cheb0chik ce1d870d54 LihonT 2 Luna beta: source release
Mod for TikTok 47.1.3 (arm64) in Material 3 style: bottom bar, profile menu, TikTok settings and
comments; downloads without the watermark; switches for ads, live streams and the Shop tab; badges of
other mods next to names and the niche mod badge (members service); app icons; mod settings screen.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-22 20:32:13 +03:00

43 lines
1.8 KiB
Java

import com.android.tools.smali.dexlib2.*;
import com.android.tools.smali.dexlib2.iface.*;
import com.android.tools.smali.dexlib2.writer.pool.DexPool;
import java.util.*;
/**
* Swaps the mod's runtime classes (Llihont/two/) in a dex that already carries them for a fresh build
* of the same classes. Every other class of the dex is kept exactly as it is.
*/
public final class RefreshClasses {
private static final String RUNTIME = "Llihont/two/";
public static void main(String[] args) throws Exception {
Opcodes api = Opcodes.forApi(Integer.parseInt(args[3]));
DexFile host = DexFileFactory.loadDexFile(args[0], api);
DexFile fresh = DexFileFactory.loadDexFile(args[1], api);
Map<String, ClassDef> classes = new LinkedHashMap<>();
int dropped = 0;
for (ClassDef c : host.getClasses()) {
if (c.getType().startsWith(RUNTIME)) {
dropped++;
continue;
}
classes.put(c.getType(), c);
}
int added = 0;
for (ClassDef c : fresh.getClasses()) {
if (!c.getType().startsWith(RUNTIME)) {
throw new IllegalArgumentException("Runtime build holds a foreign class: " + c.getType());
}
classes.put(c.getType(), c);
added++;
}
if (added == 0) throw new IllegalArgumentException("No runtime classes to put in");
DexFile result = new DexFile() {
@Override public Set<? extends ClassDef> getClasses() { return new LinkedHashSet<>(classes.values()); }
@Override public Opcodes getOpcodes() { return api; }
};
DexPool.writeTo(args[2], result);
System.out.println("Replaced " + dropped + " runtime classes with " + added);
}
}