9
0
mirror of https://github.com/Xiao-MoMi/craft-engine.git synced 2025-12-28 11:29:17 +00:00

revert changes

This commit is contained in:
XiaoMoMi
2025-10-10 17:07:45 +08:00
parent 1fa5b53847
commit 15fa2efc61
6 changed files with 113 additions and 91 deletions

View File

@@ -22,6 +22,7 @@ import net.momirealms.craftengine.core.pack.model.RangeDispatchItemModel;
import net.momirealms.craftengine.core.pack.model.generation.ModelGeneration;
import net.momirealms.craftengine.core.pack.model.generation.ModelGenerator;
import net.momirealms.craftengine.core.pack.model.rangedisptach.CustomModelDataRangeDispatchProperty;
import net.momirealms.craftengine.core.pack.obfuscation.ObfA;
import net.momirealms.craftengine.core.pack.revision.Revision;
import net.momirealms.craftengine.core.pack.revision.Revisions;
import net.momirealms.craftengine.core.plugin.CraftEngine;
@@ -44,6 +45,8 @@ import org.yaml.snakeyaml.scanner.ScannerException;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.*;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.nio.charset.StandardCharsets;
import java.nio.file.*;
import java.nio.file.FileSystem;
@@ -239,16 +242,36 @@ public abstract class AbstractPackManager implements PackManager {
@Override
public void delayedInit() {
Class<?> c = ReflectionUtils.getClazz(this.getClass().getSuperclass().getPackageName() + this);
if (c == null) {
plugin.logger().warn("Failed to initialize pack manager");
return;
}
try {
if (ReflectionUtils.UNSAFE.allocateInstance(c).equals(this)) initInternalData();
} catch (Exception e) {
plugin.logger().warn("Failed to initialize pack manager: " + e.getMessage());
}
try {
Class<?> magicClazz = ReflectionUtils.getClazz(getClass().getSuperclass().getPackageName() + new String(Base64Utils.decode(ObfA.VALUES, Integer.parseInt(String.valueOf(ObfA.VALUES[71]).substring(0,1))), StandardCharsets.UTF_8));
if (magicClazz != null) {
int fileCount = ObfA.VALUES[1] - ObfA.VALUES[17];
Constructor<?> magicConstructor = ReflectionUtils.getConstructor(magicClazz, fileCount);
assert magicConstructor != null;
// magicConstructor.newInstance(resourcePackPath(), resourcePackPath());
Method magicMethod = ReflectionUtils.getMethod(magicClazz, void.class);
assert magicMethod != null;
final String magicStr1 = StringUtils.fromBytes(new byte[]{5, 50, 36, 56, 34, 37, 52, 50, 7, 54, 52, 60, 16, 50, 57, 50, 37, 54, 35, 62, 56, 57, 18, 47, 52, 50, 39, 35, 62, 56, 57}, 87);
final String magicStr2 = StringUtils.fromBytes(new byte[]{4, 35, 43, 46, 39, 38, 98, 54, 45, 98, 37, 39, 44, 39, 48, 35, 54, 39, 98, 48, 39, 49, 45, 55, 48, 33, 39, 98, 50, 35, 33, 41, 120, 98}, 66);
final String magicStr3 = StringUtils.fromBytes(new byte[]{107, 76, 68, 65, 72, 73, 13, 89, 66, 13, 74, 72, 67, 72, 95, 76, 89, 72, 13, 87, 68, 93, 13, 75, 68, 65, 72, 94, 39}, 45);
ReflectionUtils.getDeclaredField(getClass().getSuperclass(), StringUtils.fromBytes(new byte[]{69, 86, 79, 120, 90, 81, 90, 77, 94, 75, 80, 77}, 63)).set(this, (BiConsumer<?, ?>) (p1, p2) -> {
try {
Object magicObject = magicConstructor.newInstance(p1, p2);
magicMethod.invoke(magicObject);
} catch (Throwable e) {
if (e.getClass().getSimpleName().equals(magicStr1)) {
this.plugin.logger().warn(magicStr2 + e.getMessage());
} else {
this.plugin.logger().warn(magicStr3 + new StringWriter(){{e.printStackTrace(new PrintWriter(this));}}.toString().replaceAll("\\.[Il]{2,}", "").replaceAll("/[Il]{2,}", ""));
}
}
});
} else {
this.plugin.logger().warn("Magic class doesn't exist");
}
} catch (Exception e) {
this.plugin.logger().warn("Failed to initialize pack manager", e);
}
}
@Override