feat: extract bundled cloud assets to config dir on init
Add ZenClient.extractCloudAssets() that copies panel.png, ptr.png, lie.wav and truth.wav from /assets/zen/cloud_assets/ on the classpath into ConfigManager.CONFIG_DIR (~/.zen/configs). Existing files are left untouched so user-replaced assets stick around. Called from init() right after ConfigManager is constructed, since LieDetector's TextureUtil/SoundUtil look up these files there. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -3,6 +3,10 @@ package shit.zen;
|
||||
import asm.patchify.loader.PatchAgent;
|
||||
import asm.patchify.loader.PatchRegistry;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.lang.reflect.Field;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
@@ -55,6 +59,8 @@ public class ZenClient extends ClientBase {
|
||||
public static String configDir = System.getProperty("user.home") + File.separator + ".zen";
|
||||
public static String username = "";
|
||||
|
||||
private static final String[] CLOUD_ASSET_NAMES = { "panel.png", "ptr.png", "lie.wav", "truth.wav" };
|
||||
|
||||
private EventBus eventBus;
|
||||
private RotationHandler rotationHandler;
|
||||
private ModuleManager moduleManager;
|
||||
@@ -87,6 +93,7 @@ public class ZenClient extends ClientBase {
|
||||
this.hudManager = new HudManager();
|
||||
this.commandManager = new CommandManager();
|
||||
this.configManager = new ConfigManager();
|
||||
this.extractCloudAssets();
|
||||
this.lagManager = new LagManager();
|
||||
this.targetManager = new TargetManager();
|
||||
this.eventBus.register(this.hudManager);
|
||||
@@ -140,6 +147,29 @@ public class ZenClient extends ClientBase {
|
||||
}
|
||||
}
|
||||
|
||||
private void extractCloudAssets() {
|
||||
File targetDir = ConfigManager.CONFIG_DIR;
|
||||
if (!targetDir.exists() && !targetDir.mkdirs()) {
|
||||
logger.warn("Failed to create config directory at {}", targetDir);
|
||||
return;
|
||||
}
|
||||
for (String name : CLOUD_ASSET_NAMES) {
|
||||
File outFile = new File(targetDir, name);
|
||||
if (outFile.exists()) continue;
|
||||
try (InputStream in = ZenClient.class.getResourceAsStream("/assets/zen/cloud_assets/" + name)) {
|
||||
if (in == null) {
|
||||
logger.warn("Cloud asset missing on classpath: {}", name);
|
||||
continue;
|
||||
}
|
||||
try (OutputStream out = new FileOutputStream(outFile)) {
|
||||
in.transferTo(out);
|
||||
}
|
||||
} catch (IOException ioException) {
|
||||
logger.error("Failed to extract cloud asset {}", name, ioException);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void registerPatches() {
|
||||
PatchRegistry.register(MinecraftPatch.class);
|
||||
PatchRegistry.register(LocalPlayerPatch.class);
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
package shit.zen.utils;
|
||||
|
||||
import java.security.SecureRandom;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class ByteCipher {
|
||||
private final byte[] key;
|
||||
|
||||
public ByteCipher(byte[] keyBytes) {
|
||||
this.key = Arrays.copyOf(keyBytes, keyBytes.length);
|
||||
}
|
||||
|
||||
public byte[] encrypt(byte[] input, int shift) {
|
||||
byte[] output = new byte[input.length];
|
||||
for (int i = 0; i < input.length; ++i) {
|
||||
output[i] = (byte)(input[i] + this.key[i % this.key.length] + shift);
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
public byte[] decrypt(byte[] input, int shift) {
|
||||
byte[] output = new byte[input.length];
|
||||
for (int i = 0; i < input.length; ++i) {
|
||||
output[i] = (byte)(input[i] - this.key[i % this.key.length] - shift);
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
static {
|
||||
new SecureRandom();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user