From 7659ec3bc299d7ac2a08297d4c0dd4d760c77c0e Mon Sep 17 00:00:00 2001 From: Shirona1337 Date: Thu, 21 May 2026 22:57:09 +0800 Subject: [PATCH] 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 --- src/main/java/shit/zen/ZenClient.java | 30 ++++++++++++++++++ src/main/java/shit/zen/utils/ByteCipher.java | 32 -------------------- 2 files changed, 30 insertions(+), 32 deletions(-) delete mode 100644 src/main/java/shit/zen/utils/ByteCipher.java diff --git a/src/main/java/shit/zen/ZenClient.java b/src/main/java/shit/zen/ZenClient.java index e82c794..7389fbe 100644 --- a/src/main/java/shit/zen/ZenClient.java +++ b/src/main/java/shit/zen/ZenClient.java @@ -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); diff --git a/src/main/java/shit/zen/utils/ByteCipher.java b/src/main/java/shit/zen/utils/ByteCipher.java deleted file mode 100644 index dbd313a..0000000 --- a/src/main/java/shit/zen/utils/ByteCipher.java +++ /dev/null @@ -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(); - } -} \ No newline at end of file