added files.

This commit is contained in:
nitrogenoliquido committed 2026-11-24 15:53:11 -05:00
1 parent 06899e05dd
commit 0ca7be5dd7
274 files changed
+1491 -139

No files matched your search

+31
View File
@@ -126,6 +126,7 @@ public class Augustus {
this.settingNameManager.initialize();
this.clientTabManager.initTabs();
this.configManager.loadAll();
this.migrateRenderLoadFromConfigOnce();
MinotarAvatarCache.preloadAccountAvatars();
try {
@@ -147,11 +148,41 @@ public class Augustus {
});
}
private void migrateRenderLoadFromConfigOnce() {
try {
java.io.File marker = new java.io.File(
net.augustus.config.JsonConfigFile.BASE_CONFIG_DIR + java.io.File.separator + "settings",
".render_loadfromconfig_migrated"
);
if (marker.exists()) {
return;
}
for (Object obj : this.moduleManager.getModules()) {
if (obj instanceof net.augustus.modules.Module) {
net.augustus.modules.Module mod = (net.augustus.modules.Module)obj;
if (mod.getCategorys() == net.augustus.modules.Categorys.RENDER) {
mod.setLoadFromConfig(true);
}
}
}
this.configManager.snapshotAll();
this.configManager.moduleSettingsConfig.save(true);
if (marker.getParentFile() != null && !marker.getParentFile().exists()) {
marker.getParentFile().mkdirs();
}
java.nio.file.Files.write(marker.toPath(), "migrated=true\n".getBytes(java.nio.charset.StandardCharsets.UTF_8));
} catch (Throwable t) {
System.err.println("[OpenAugustus] Failed during one-time Render LoadFromConfig migration:");
t.printStackTrace();
}
}
public void stop() {
if (Minecraft.getMinecraft() != null && Minecraft.getMinecraft().getSession() != null) {
Minecraft.getMinecraft().getSession().updatePlayTime(false);
}
this.configManager.snapshotAll();
this.configManager.saveAll();
try {
@@ -122,7 +122,9 @@ public final class Aes256Ecb {
public byte[] decryptPkcs7(byte[] input, int offset, int length) {
if (length <= 0 || (length % BLOCK_SIZE) != 0) {
throw new IllegalArgumentException("Invalid AES ciphertext length: " + length);
throw new IllegalArgumentException(
"Invalid AES ciphertext length: " + length + " bytes (must be a positive multiple of 16; remainder=" + (length % BLOCK_SIZE) + ")"
);
}
byte[] out = new byte[length];
for (int pos = 0; pos < length; pos += BLOCK_SIZE) {
@@ -130,16 +132,61 @@ public final class Aes256Ecb {
}
int pad = out[length - 1] & 0xFF;
if (pad < 1 || pad > BLOCK_SIZE) {
throw new IllegalArgumentException("Invalid PKCS#7 padding value: " + pad);
throw new IllegalArgumentException(
"Invalid PKCS#7 padding byte at end of ciphertext: 0x" + String.format("%02X", pad) + " (" + pad + "), expected 1..16 (wrong key, non-standard padding, or corrupted final block)"
);
}
for (int i = length - pad; i < length; i++) {
if ((out[i] & 0xFF) != pad) {
throw new IllegalArgumentException("Corrupted PKCS#7 padding byte at offset " + i);
int b = out[i] & 0xFF;
if (b != pad) {
throw new IllegalArgumentException(
"Corrupted PKCS#7 padding byte at offset " + i + " of " + length + ": expected 0x" + String.format("%02X", pad) + ", found 0x" + String.format("%02X", b)
);
}
}
return Arrays.copyOf(out, length - pad);
}
/**
* Lenient AES-256-ECB decryption used strictly as a recovery fallback:
* decrypts all complete 16-byte blocks without throwing on invalid PKCS#7 padding or truncated tails.
*/
public byte[] decryptRawBlocks(byte[] input, int offset, int length) {
if (input == null || length < BLOCK_SIZE) {
return new byte[0];
}
int usable = (length / BLOCK_SIZE) * BLOCK_SIZE;
byte[] out = new byte[usable];
for (int pos = 0; pos < usable; pos += BLOCK_SIZE) {
decryptBlock(input, offset + pos, out, pos);
}
// Strip valid PKCS#7 padding if intact
int pad = out[usable - 1] & 0xFF;
if (pad >= 1 && pad <= BLOCK_SIZE) {
boolean validPkcs7 = true;
for (int i = usable - pad; i < usable; i++) {
if ((out[i] & 0xFF) != pad) {
validPkcs7 = false;
break;
}
}
if (validPkcs7) {
return Arrays.copyOf(out, usable - pad);
}
}
// Otherwise trim trailing NUL/control padding bytes (0x00..0x10)
int end = usable;
while (end > 0) {
int b = out[end - 1] & 0xFF;
if (b == 0x00 || (b >= 0x01 && b <= 0x10 && b != '\t' && b != '\n' && b != '\r')) {
end--;
} else {
break;
}
}
return Arrays.copyOf(out, end);
}
private void encryptBlock(byte[] in, int inOff, byte[] out, int outOff) {
int[] s = new int[16];
for (int i = 0; i < 16; i++) {
@@ -2,6 +2,7 @@ package net.augustus.config;
import net.augustus.Augustus;
import net.augustus.clickgui.ClickGuiScreen;
import net.augustus.modules.render.ClickGui;
import net.augustus.settings.property.ConfigProperty;
import net.augustus.settings.property.codec.JsonCodecRegistryHolder;
import com.google.gson.JsonElement;
@@ -37,13 +38,18 @@ public class ConfigFormatV2 implements ModuleConfigCodec {
if (!(featureBase instanceof Module)) {
return true;
} else {
Module module = (Module)featureBase;
if (!(configProperty instanceof AbstractFeature)) {
if (configProperty.getName().equals("M_T")) {
return ((Module)featureBase).isLoadFromConfig();
String propName = configProperty.getName();
if ("M_T".equals(propName)) {
return !(module instanceof ClickGui) && module.isLoadFromConfig();
} else if ("M_A".equals(propName)) {
return module.isLoadFromConfig();
} else if ("M_K".equals(propName)) {
return Augustus.getInstance().getModuleManager().clientSettings.loadKeysFromConfigs.getValue()
&& module.isLoadFromConfig();
} else {
return Augustus.getInstance().getModuleManager().clientSettings.loadKeysFromConfigs.getValue() && configProperty.getName().equals("M_K")
? ((Module)featureBase).isLoadFromConfig()
: false;
return false;
}
} else {
String name = configProperty.getName();
@@ -52,8 +58,10 @@ public class ConfigFormatV2 implements ModuleConfigCodec {
return false;
} else if (name.contains("Blur")) {
return moduleManager.blur.isLoadFromConfig();
} else if (name.contains("Shadow")) {
return moduleManager.shadow.isLoadFromConfig();
} else {
return name.contains("Shadow") ? moduleManager.shadow.isLoadFromConfig() : ((Module)featureBase).isLoadFromConfig();
return module.isLoadFromConfig();
}
}
}
@@ -89,19 +97,63 @@ public class ConfigFormatV2 implements ModuleConfigCodec {
@Override
public void applyConfig(JsonObject json) {
this.applyConfig(json, ConfigLoadReport.current());
}
public void applyConfig(JsonObject json, ConfigLoadReport report) {
if (json == null) {
return;
}
JsonObject configSection = null;
JsonElement elem = json.get("Configuration");
if (elem != null && elem.isJsonObject()) {
JsonElement elem2 = json.get("Config_Header");
if (elem2 != null && elem2.isJsonObject()) {
JsonObject asJsonObject = elem2.getAsJsonObject();
boolean flag = !asJsonObject.has("Config_Editable") || Boolean.parseBoolean(asJsonObject.get("Config_Editable").getAsString());
Augustus.getInstance().setConfigEditingEnabled(true);
ClickGuiScreen.configEditable = flag;
ClickGuiScreen.protectedConfigCreator = false;
JsonObject asJsonObject2 = json.get("Configuration").getAsJsonObject();
ModuleSettingsConfigSection.abstractFeature.deserialize(JsonCodecRegistryHolder.GSON_SERIALIZER_PROVIDER, asJsonObject2, true, var -> shouldLoadProperty((ConfigProperty)var));
configSection = elem.getAsJsonObject();
} else if (looksLikeFlatModuleMap(json)) {
configSection = json;
if (report != null) {
report.markFallback("Missing 'Configuration' wrapper -> loaded root JSON directly as module map");
}
} else {
if (report != null) {
report.recordError("ConfigFormatV2", "Missing or invalid 'Configuration' JSON object in config", null);
}
return;
}
boolean editable = true;
JsonElement headerElem = json.get("Config_Header");
if (headerElem != null && headerElem.isJsonObject()) {
JsonObject headerObj = headerElem.getAsJsonObject();
editable = !headerObj.has("Config_Editable") || Boolean.parseBoolean(headerObj.get("Config_Editable").getAsString());
} else if (report != null) {
report.markFallback("Missing 'Config_Header' -> defaulted to Config_Version=2, Editable=true");
}
Augustus.getInstance().setConfigEditingEnabled(true);
ClickGuiScreen.configEditable = editable;
ClickGuiScreen.protectedConfigCreator = false;
final JsonObject targetSection = configSection;
ConfigLoadReport.runWithCurrent(report, () -> ModuleSettingsConfigSection.abstractFeature.deserialize(
JsonCodecRegistryHolder.GSON_SERIALIZER_PROVIDER,
targetSection,
true,
var -> shouldLoadProperty((ConfigProperty)var)
));
}
private static boolean looksLikeFlatModuleMap(JsonObject json) {
if (json == null || json.entrySet().isEmpty()) {
return false;
}
for (Object obj : Augustus.getInstance().getModuleManager().getModules()) {
if (obj instanceof Module) {
String name = ((Module)obj).getName();
if (name != null && json.has(name) && json.get(name).isJsonObject()) {
return true;
}
}
}
return false;
}
}
@@ -0,0 +1,220 @@
package net.augustus.config;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
/**
* Tracks exact decryption, JSON parsing, module recovery, and setting-level errors
* during a config load so both in-game warnings and exact console diagnostics are always reported.
*/
public final class ConfigLoadReport {
private static final Logger LOGGER = LogManager.getLogger("OpenAugustus-Config");
private static final ThreadLocal<ConfigLoadReport> ACTIVE = new ThreadLocal<>();
private final String configName;
private final File file;
private long fileSize = -1L;
private String headerHex = "<none>";
private String decryptionMode = "unknown";
private boolean usedFallback = false;
private int loadedModules = 0;
private int defaultedModules = 0;
private int failedModules = 0;
private int failedSettings = 0;
private String shortFailureReason = "unknown error";
private Throwable primaryCause = null;
private final List<String> exactErrors = new ArrayList<>();
private final List<String> warnings = new ArrayList<>();
public ConfigLoadReport(String configName, File file) {
this.configName = configName != null ? configName : "<unnamed>";
this.file = file;
}
public static ConfigLoadReport current() {
return ACTIVE.get();
}
public static void runWithCurrent(ConfigLoadReport report, Runnable task) {
ConfigLoadReport prev = ACTIVE.get();
ACTIVE.set(report);
try {
task.run();
} finally {
if (prev == null) {
ACTIVE.remove();
} else {
ACTIVE.set(prev);
}
}
}
public void inspectRawBytes(byte[] bytes) {
if (bytes == null) {
this.fileSize = 0L;
this.headerHex = "<null>";
return;
}
this.fileSize = bytes.length;
this.headerHex = toHexPreview(bytes, 16);
}
public static String toHexPreview(byte[] bytes, int maxBytes) {
if (bytes == null || bytes.length == 0) {
return "<empty>";
}
int n = Math.min(bytes.length, maxBytes);
StringBuilder sb = new StringBuilder(n * 3);
for (int i = 0; i < n; i++) {
if (i > 0) sb.append(' ');
sb.append(String.format("%02X", bytes[i] & 0xFF));
}
if (bytes.length > n) {
sb.append(" ...");
}
return sb.toString();
}
public void setDecryptionMode(String mode) {
this.decryptionMode = mode;
}
public void markFallback(String warning) {
this.usedFallback = true;
if (warning != null && !warning.isEmpty()) {
this.warnings.add(warning);
}
}
public void recordError(String stage, String detail, Throwable cause) {
String msg = "[" + stage + "] " + detail;
if (cause != null) {
msg += " -> " + cause.getClass().getSimpleName() + ": " + cause.getMessage();
if (this.primaryCause == null) {
this.primaryCause = cause;
}
}
this.exactErrors.add(msg);
if (this.shortFailureReason.equals("unknown error")) {
this.shortFailureReason = cause != null && cause.getMessage() != null
? stage + ": " + cause.getClass().getSimpleName() + ": " + cause.getMessage()
: stage + ": " + detail;
}
}
public void setShortFailureReason(String reason) {
if (reason != null && !reason.isEmpty()) {
this.shortFailureReason = reason;
}
}
public void recordLoadedModule(String moduleName) {
this.loadedModules++;
}
public void recordDefaultedModule(String moduleName) {
this.defaultedModules++;
}
public void recordFailedModule(String moduleName, String detail, Throwable cause) {
this.failedModules++;
this.usedFallback = true;
this.recordError("Module '" + moduleName + "'", detail, cause);
}
public void recordFailedSetting(String path, String detail, Throwable cause) {
this.failedSettings++;
this.usedFallback = true;
this.recordError("Setting '" + path + "'", detail, cause);
}
public boolean isUsedFallback() {
return this.usedFallback;
}
public boolean hasAnyIssue() {
return this.usedFallback || !this.exactErrors.isEmpty() || !this.warnings.isEmpty() || this.failedModules > 0 || this.failedSettings > 0;
}
public int getLoadedModules() {
return this.loadedModules;
}
public int getDefaultedModules() {
return this.defaultedModules;
}
public int getFailedModules() {
return this.failedModules;
}
public int getFailedSettings() {
return this.failedSettings;
}
public int getTotalErrors() {
return this.exactErrors.size();
}
public String getShortFailureReason() {
if (this.shortFailureReason.length() > 140) {
return this.shortFailureReason.substring(0, 137) + "...";
}
return this.shortFailureReason;
}
public String formatDiagnosticReport() {
StringBuilder sb = new StringBuilder();
sb.append("\n================ [OpenAugustus Config Diagnostic] ================\n");
sb.append("Config: ").append(this.configName).append('\n');
sb.append("File: ").append(this.file != null ? this.file.getAbsolutePath() : "<in-memory>");
if (this.fileSize >= 0) {
sb.append(" (").append(this.fileSize).append(" bytes)");
}
sb.append('\n');
sb.append("HeaderHex: ").append(this.headerHex).append('\n');
sb.append("DecryptMode: ").append(this.decryptionMode).append(this.usedFallback ? " [FALLBACK]" : "").append('\n');
sb.append("Modules: loaded=").append(this.loadedModules)
.append(", defaulted=").append(this.defaultedModules)
.append(", failed=").append(this.failedModules)
.append(", failedSettings=").append(this.failedSettings).append('\n');
if (!this.warnings.isEmpty()) {
sb.append("Warnings (").append(this.warnings.size()).append("):\n");
for (int i = 0; i < this.warnings.size(); i++) {
sb.append(" [W").append(i + 1).append("] ").append(this.warnings.get(i)).append('\n');
}
}
if (!this.exactErrors.isEmpty()) {
sb.append("Exact Errors (").append(this.exactErrors.size()).append("):\n");
int limit = Math.min(this.exactErrors.size(), 50);
for (int i = 0; i < limit; i++) {
sb.append(" [E").append(i + 1).append("] ").append(this.exactErrors.get(i)).append('\n');
}
if (this.exactErrors.size() > limit) {
sb.append(" ... (+").append(this.exactErrors.size() - limit).append(" more errors)\n");
}
}
sb.append("==================================================================");
return sb.toString();
}
public void logToConsole() {
String text = this.formatDiagnosticReport();
System.err.println(text);
try {
if (this.primaryCause != null) {
LOGGER.error(text, this.primaryCause);
this.primaryCause.printStackTrace(System.err);
} else {
LOGGER.warn(text);
}
} catch (Throwable ignored) {
if (this.primaryCause != null) {
this.primaryCause.printStackTrace(System.err);
}
}
}
}
@@ -8,9 +8,13 @@ import net.augustus.utils.ChatUtil;
import net.augustus.utils.audio.ClientSounds;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.google.gson.stream.JsonReader;
import java.io.File;
import java.io.StringReader;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.util.Base64;
import java.util.HashMap;
import net.minecraft.client.Minecraft;
import net.minecraft.network.PacketThreadUtil;
@@ -45,21 +49,265 @@ public class ModuleConfigStorage extends JsonConfigFile {
return true;
}
private static boolean hasAesMagicPrefix(byte[] bytes) {
return bytes != null && bytes.length >= 4 && bytes[0] == (byte)0xAE && bytes[1] == (byte)0x53;
}
public static String decryptConfigBytes(byte[] bytes) {
if (bytes == null || bytes.length == 0) {
return "";
ConfigLoadReport silent = new ConfigLoadReport("<bytes>", null);
String text = decryptWithDiagnostics(bytes, silent);
return text != null ? text : "";
}
/**
* Multi-stage decoder with exact error reporting and automatic recovery fallbacks:
* 1. Strict AE 53 01 00 -> AES-256-ECB (PKCS#7) or plain UTF-8 JSON.
* 2. Fallback: lenient AES-256-ECB raw block decryption (corrupted padding / truncated tail / alternate AE 53 xx xx header).
* 3. Fallback: headerless AES-256-ECB decryption.
* 4. Fallback: Base64 / clipboard Name_<x>_<b64> wrapper saved into a file.
* 5. Fallback: UTF-16LE / UTF-16BE BOM or embedded JSON salvage.
*/
public static String decryptWithDiagnostics(byte[] bytes, ConfigLoadReport report) {
if (report != null) {
report.inspectRawBytes(bytes);
}
if (!hasEncryptedHeader(bytes)) {
return new String(bytes, StandardCharsets.UTF_8);
if (bytes == null || bytes.length == 0) {
if (report != null) {
report.setDecryptionMode("empty");
report.recordError("Read", "Config file is empty (0 bytes)", null);
}
return null;
}
// 1. Standard Augustus encrypted header (AE 53 01 00)
if (hasEncryptedHeader(bytes)) {
int payloadLen = bytes.length - ENCRYPTED_MAGIC_HEADER.length;
try {
byte[] decrypted = CONFIG_CIPHER.decryptPkcs7(bytes, ENCRYPTED_MAGIC_HEADER.length, payloadLen);
String text = stripBom(new String(decrypted, StandardCharsets.UTF_8));
if (looksLikeJsonStart(text)) {
if (report != null) {
report.setDecryptionMode("aes256-ecb-pkcs7");
}
return text;
}
if (report != null) {
report.recordError(
"Decrypt (aes256-ecb-pkcs7)",
"Decrypted payload does not start with JSON '{' (first decrypted bytes: "
+ ConfigLoadReport.toHexPreview(decrypted, 16) + "; likely different AES key or unsupported cipher)",
null
);
}
} catch (Exception e) {
if (report != null) {
report.recordError(
"Decrypt (aes256-ecb-pkcs7)",
"Strict AES-256-ECB PKCS#7 decryption failed (total=" + bytes.length + " bytes, payload=" + payloadLen + " bytes)",
e
);
}
}
// 2a. Lenient AES-256-ECB fallback (handles bad padding or truncated final block)
try {
byte[] raw = CONFIG_CIPHER.decryptRawBlocks(bytes, ENCRYPTED_MAGIC_HEADER.length, payloadLen);
String text = stripBom(new String(raw, StandardCharsets.UTF_8));
if (containsJsonMarkers(text)) {
if (report != null) {
report.setDecryptionMode("aes256-ecb-raw-fallback");
report.markFallback("Recovered plaintext via lenient AES-256-ECB block decryption (ignored invalid padding / truncated tail)");
}
return text;
}
if (report != null) {
report.recordError(
"Decrypt Fallback (aes256-ecb-raw)",
"Lenient AES-256-ECB output is not valid JSON text (first decrypted bytes: "
+ ConfigLoadReport.toHexPreview(raw, 16) + "; file is likely encrypted with a different key, custom obfuscator, or severely corrupted)",
null
);
}
} catch (Exception e2) {
if (report != null) {
report.recordError("Decrypt Fallback (aes256-ecb-raw)", "Lenient block decryption failed", e2);
}
}
return null;
}
// 1b. Alternate AE 53 xx xx header (non-standard version bytes)
if (hasAesMagicPrefix(bytes)) {
int payloadLen = bytes.length - 4;
if (report != null) {
report.recordError(
"Header",
"Unexpected encrypted magic header " + ConfigLoadReport.toHexPreview(bytes, 4) + " (expected AE 53 01 00)",
null
);
}
byte[] raw = CONFIG_CIPHER.decryptRawBlocks(bytes, 4, payloadLen);
String text = stripBom(new String(raw, StandardCharsets.UTF_8));
if (containsJsonMarkers(text)) {
if (report != null) {
report.setDecryptionMode("aes256-ecb-alt-header-fallback");
report.markFallback("Recovered config with non-standard AE 53 header via lenient AES-256-ECB fallback");
}
return text;
}
return null;
}
// 1c. UTF-16 BOM detection
if (bytes.length >= 2) {
int b0 = bytes[0] & 0xFF;
int b1 = bytes[1] & 0xFF;
if (b0 == 0xFF && b1 == 0xFE) {
String utf16 = stripBom(new String(bytes, 2, bytes.length - 2, StandardCharsets.UTF_16LE));
if (containsJsonMarkers(utf16)) {
if (report != null) {
report.setDecryptionMode("utf16le-fallback");
report.markFallback("Detected UTF-16LE BOM encoding -> converted to UTF-8");
}
return utf16;
}
} else if (b0 == 0xFE && b1 == 0xFF) {
String utf16 = stripBom(new String(bytes, 2, bytes.length - 2, StandardCharsets.UTF_16BE));
if (containsJsonMarkers(utf16)) {
if (report != null) {
report.setDecryptionMode("utf16be-fallback");
report.markFallback("Detected UTF-16BE BOM encoding -> converted to UTF-8");
}
return utf16;
}
}
}
// 1d. Standard plain UTF-8 JSON
String utf8 = stripBom(new String(bytes, StandardCharsets.UTF_8));
String trimmed = utf8.trim();
if (looksLikeJsonStart(trimmed)) {
if (report != null) {
report.setDecryptionMode("plain-utf8");
}
return utf8;
}
// 2b. Clipboard Base64 / raw Base64 saved directly into a .json file
String b64Decoded = tryDecodeBase64Wrapper(trimmed, report);
if (b64Decoded != null) {
return b64Decoded;
}
// 2c. Headerless AES-256-ECB fallback (missing 4-byte AE 53 01 00 prefix)
if (bytes.length >= 16) {
byte[] rawNoHeader = CONFIG_CIPHER.decryptRawBlocks(bytes, 0, bytes.length);
String text = stripBom(new String(rawNoHeader, StandardCharsets.UTF_8));
if (containsJsonMarkers(text)) {
if (report != null) {
report.setDecryptionMode("aes256-ecb-noheader-fallback");
report.markFallback("Recovered headerless AES-256-ECB payload (4-byte AE 53 01 00 header was missing)");
}
return text;
}
}
// 2d. Embedded JSON salvage (e.g., corrupted prefix bytes before '{')
if (containsJsonMarkers(utf8)) {
int brace = utf8.indexOf('{');
if (brace > 0) {
if (report != null) {
report.setDecryptionMode("embedded-json-fallback");
report.markFallback("Skipped " + brace + " non-JSON leading bytes before '{'");
}
return utf8.substring(brace);
}
}
if (report != null) {
report.setDecryptionMode("failed");
report.recordError(
"Decrypt",
"Unrecognized config format (not plain JSON, not Base64, and not decryptable with Augustus AES-256-ECB key; header="
+ ConfigLoadReport.toHexPreview(bytes, 16) + ")",
null
);
}
return null;
}
private static String tryDecodeBase64Wrapper(String trimmed, ConfigLoadReport report) {
if (trimmed == null || trimmed.isEmpty()) {
return null;
}
String candidate = trimmed;
if (candidate.startsWith("Name_")) {
int underscores = 0;
for (int i = 0; i < candidate.length(); i++) {
if (candidate.charAt(i) == '_' && ++underscores >= 2) {
candidate = candidate.substring(i + 1).trim();
break;
}
}
}
if (candidate.length() < 16 || candidate.contains("{")) {
return null;
}
try {
byte[] decrypted = CONFIG_CIPHER.decryptPkcs7(bytes, ENCRYPTED_MAGIC_HEADER.length, bytes.length - ENCRYPTED_MAGIC_HEADER.length);
return new String(decrypted, StandardCharsets.UTF_8);
} catch (Exception e) {
System.err.println("Failed to decrypt AES-256-ECB config payload (" + bytes.length + " bytes):");
e.printStackTrace();
return "";
byte[] decoded = Base64.getMimeDecoder().decode(candidate);
if (decoded != null && decoded.length > 0) {
if (hasEncryptedHeader(decoded)) {
byte[] raw = CONFIG_CIPHER.decryptRawBlocks(decoded, ENCRYPTED_MAGIC_HEADER.length, decoded.length - ENCRYPTED_MAGIC_HEADER.length);
String text = stripBom(new String(raw, StandardCharsets.UTF_8));
if (containsJsonMarkers(text)) {
if (report != null) {
report.setDecryptionMode("base64-aes256-fallback");
report.markFallback("Decoded Base64-wrapped encrypted config payload");
}
return text;
}
} else {
String text = stripBom(new String(decoded, StandardCharsets.UTF_8));
if (containsJsonMarkers(text)) {
if (report != null) {
report.setDecryptionMode("base64-json-fallback");
report.markFallback("Decoded Base64/clipboard-wrapped JSON config payload");
}
return text;
}
}
}
} catch (IllegalArgumentException ignored) {
}
return null;
}
private static String stripBom(String text) {
if (text != null && !text.isEmpty() && text.charAt(0) == '\uFEFF') {
return text.substring(1);
}
return text;
}
private static boolean looksLikeJsonStart(String text) {
if (text == null) {
return false;
}
String t = text.trim();
return t.startsWith("{");
}
private static boolean containsJsonMarkers(String text) {
if (text == null || text.indexOf('{') < 0) {
return false;
}
return text.contains("\"Configuration\"")
|| text.contains("\"Config_Header\"")
|| text.contains("\"M_T\"")
|| text.contains("\"KillAura\"")
|| text.contains("\"HUD\"")
|| text.contains("\"ArrayList\"")
|| text.trim().startsWith("{");
}
@Override
@@ -77,28 +325,364 @@ public class ModuleConfigStorage extends JsonConfigFile {
}
public void loadConfig(String configName, String subDir, boolean notify) {
JsonObject json = this.readConfigJson(subDir, configName);
if (json == null) {
File file = new File(this.getDirectoryPath() + subDir, configName + ".json");
ConfigLoadReport report = new ConfigLoadReport(configName, file);
long startTime = System.currentTimeMillis();
if (!file.exists()) {
report.recordError("Read", "File does not exist: " + file.getAbsolutePath(), null);
report.logToConsole();
if (notify) {
File file = new File(this.getDirectoryPath() + subDir, configName + ".json");
String message;
if (!file.exists()) {
message = "Config not found: §c" + configName;
} else {
boolean encrypted = false;
try {
encrypted = hasEncryptedHeader(Files.readAllBytes(file.toPath()));
} catch (Exception ignored) {
}
message = encrypted
? "Failed to decrypt config: §c" + configName
: "Failed to load config: §c" + configName;
}
this.notifyConfigStatus(message, NotificationLevel.ERROR);
this.notifyConfigStatus("Config not found: §c" + configName, NotificationLevel.ERROR);
}
return;
}
this.applyConfigJson(json, configName, notify);
byte[] rawBytes;
try {
rawBytes = Files.readAllBytes(file.toPath());
} catch (Exception e) {
report.recordError("Read", "IO error reading file " + file.getAbsolutePath(), e);
report.logToConsole();
if (notify) {
this.notifyConfigStatus(
"Error leyendo config: §c" + configName + " §7(" + e.getClass().getSimpleName() + ": " + e.getMessage() + ")",
NotificationLevel.ERROR
);
}
return;
}
String rawText = decryptWithDiagnostics(rawBytes, report);
if (rawText == null || rawText.trim().isEmpty()) {
report.logToConsole();
if (notify) {
this.notifyConfigStatus(
"No se pudo desencriptar/cargar config: §c" + configName + " §7(" + report.getShortFailureReason() + " - revisa la consola)",
NotificationLevel.ERROR
);
}
return;
}
JsonObject json = parseConfigJsonWithFallback(rawText, report);
if (json == null) {
report.logToConsole();
if (notify) {
this.notifyConfigStatus(
"Config corrupta (JSON ilegible): §c" + configName + " §7(" + report.getShortFailureReason() + " - revisa la consola)",
NotificationLevel.ERROR
);
}
return;
}
this.applyConfigJson(json, configName, notify, report, startTime);
}
/**
* Parses JSON strictly, then leniently, and if truncated/corrupted mid-file,
* salvages every intact "ModuleName": { ... } block so the rest can be filled with defaults.
*/
public static JsonObject parseConfigJsonWithFallback(String rawText, ConfigLoadReport report) {
if (rawText == null || rawText.trim().isEmpty()) {
if (report != null) {
report.recordError("JSON Parse", "Decoded config text is empty", null);
}
return null;
}
// Stage 1: Strict Gson parse
try {
JsonElement elem = new JsonParser().parse(rawText);
if (elem != null && elem.isJsonObject()) {
return elem.getAsJsonObject();
}
if (report != null) {
report.recordError("JSON Parse", "Root JSON element is not an object: " + (elem == null ? "null" : elem.getClass().getSimpleName()), null);
}
} catch (Exception strictEx) {
if (report != null) {
report.recordError("JSON Parse (strict)", "Strict JSON parse failed", strictEx);
}
// Stage 2: Lenient Gson parse (handles trailing garbage, comments, unquoted keys, NaN/Infinity)
try {
JsonReader reader = new JsonReader(new StringReader(rawText));
reader.setLenient(true);
JsonElement elem = new JsonParser().parse(reader);
if (elem != null && elem.isJsonObject()) {
if (report != null) {
report.markFallback("Recovered JSON via lenient parser (fixed minor syntax/trailing garbage)");
}
return elem.getAsJsonObject();
}
} catch (Exception lenientEx) {
if (report != null) {
report.recordError("JSON Parse (lenient)", "Lenient JSON parse also failed", lenientEx);
}
}
// Stage 3: Partial module-by-module salvage for truncated or partially corrupted JSON
JsonObject salvaged = recoverPartialConfigJson(rawText, report);
if (salvaged != null) {
return salvaged;
}
}
return null;
}
private static JsonObject recoverPartialConfigJson(String text, ConfigLoadReport report) {
JsonObject recoveredConfig = new JsonObject();
JsonObject recoveredHeader = null;
int salvagedCount = 0;
int corruptedBlocks = 0;
// Try to extract Config_Header if intact
int headerKeyIdx = text.indexOf("\"Config_Header\"");
if (headerKeyIdx >= 0) {
int objStart = findValueObjectStart(text, headerKeyIdx + "\"Config_Header\"".length());
if (objStart >= 0) {
int objEnd = findMatchingBrace(text, objStart);
if (objEnd > objStart) {
String headerSlice = text.substring(objStart, objEnd + 1);
try {
JsonReader r = new JsonReader(new StringReader(headerSlice));
r.setLenient(true);
JsonElement el = new JsonParser().parse(r);
if (el != null && el.isJsonObject()) {
recoveredHeader = el.getAsJsonObject();
}
} catch (Exception e) {
if (report != null) {
report.recordError("JSON Salvage (Config_Header)", "Could not parse Config_Header block", e);
}
}
}
}
}
// Locate "Configuration": { ... } or fall back to root '{'
int scanStart = -1;
int cfgKeyIdx = text.indexOf("\"Configuration\"");
if (cfgKeyIdx >= 0) {
scanStart = findValueObjectStart(text, cfgKeyIdx + "\"Configuration\"".length());
}
if (scanStart < 0) {
scanStart = text.indexOf('{');
}
if (scanStart < 0) {
return null;
}
// Scan top-level "Key": { ... } entries inside Configuration
int i = scanStart + 1;
int len = text.length();
while (i < len) {
i = skipWhitespaceAndCommas(text, i);
if (i >= len || text.charAt(i) == '}') {
break;
}
if (text.charAt(i) != '"') {
i++;
continue;
}
int keyEnd = findStringEnd(text, i);
if (keyEnd < 0) {
if (report != null) {
report.recordError("JSON Salvage", "Unterminated key string at char offset " + i, null);
}
break;
}
String key = text.substring(i + 1, keyEnd);
int colon = skipWhitespace(text, keyEnd + 1);
if (colon >= len || text.charAt(colon) != ':') {
i = keyEnd + 1;
continue;
}
int valStart = skipWhitespace(text, colon + 1);
if (valStart >= len) {
if (report != null) {
report.recordError("JSON Salvage", "Truncated value for entry '" + key + "' at EOF (char " + valStart + ")", null);
}
break;
}
if (text.charAt(valStart) == '{') {
int valEnd = findMatchingBrace(text, valStart);
if (valEnd < 0) {
corruptedBlocks++;
if (report != null) {
report.recordError("JSON Salvage", "Truncated/unclosed JSON object for module '" + key + "' starting at char " + valStart + " (filled with defaults)", null);
}
break;
}
if (!"Config_Header".equals(key)) {
String slice = text.substring(valStart, valEnd + 1);
try {
JsonReader r = new JsonReader(new StringReader(slice));
r.setLenient(true);
JsonElement parsed = new JsonParser().parse(r);
if (parsed != null && parsed.isJsonObject()) {
recoveredConfig.add(key, parsed.getAsJsonObject());
salvagedCount++;
}
} catch (Exception e) {
corruptedBlocks++;
if (report != null) {
report.recordError("JSON Salvage (Module '" + key + "')", "Corrupted JSON inside module block (char " + valStart + ".." + valEnd + ")", e);
}
}
}
i = valEnd + 1;
} else {
// Skip primitive or array value
int next = skipNonObjectValue(text, valStart);
if (next <= valStart) {
break;
}
i = next;
}
}
if (salvagedCount == 0) {
if (report != null) {
report.recordError("JSON Salvage", "0 intact module blocks could be recovered from corrupted JSON", null);
}
return null;
}
JsonObject result = new JsonObject();
if (recoveredHeader == null) {
recoveredHeader = new JsonObject();
recoveredHeader.addProperty("Config_Version", Integer.valueOf(2));
recoveredHeader.addProperty("Config_Editable", "true");
} else if (!recoveredHeader.has("Config_Version") && !recoveredHeader.has("ConfigVersion")) {
recoveredHeader.addProperty("Config_Version", Integer.valueOf(2));
}
result.add("Config_Header", recoveredHeader);
result.add("Configuration", recoveredConfig);
if (report != null) {
report.markFallback(
"Partial JSON recovery salvaged " + salvagedCount + " intact module block(s)"
+ (corruptedBlocks > 0 ? " (" + corruptedBlocks + " corrupted/truncated block(s) skipped and filled with defaults)" : "")
);
}
return result;
}
private static int skipWhitespace(String s, int idx) {
int n = s.length();
while (idx < n && Character.isWhitespace(s.charAt(idx))) {
idx++;
}
return idx;
}
private static int skipWhitespaceAndCommas(String s, int idx) {
int n = s.length();
while (idx < n) {
char c = s.charAt(idx);
if (Character.isWhitespace(c) || c == ',') {
idx++;
} else {
break;
}
}
return idx;
}
private static int findValueObjectStart(String s, int afterKeyIdx) {
int colon = skipWhitespace(s, afterKeyIdx);
if (colon >= s.length() || s.charAt(colon) != ':') {
return -1;
}
int val = skipWhitespace(s, colon + 1);
return val < s.length() && s.charAt(val) == '{' ? val : -1;
}
private static int findStringEnd(String s, int quoteStart) {
boolean escaped = false;
for (int i = quoteStart + 1; i < s.length(); i++) {
char c = s.charAt(i);
if (escaped) {
escaped = false;
} else if (c == '\\') {
escaped = true;
} else if (c == '"') {
return i;
}
}
return -1;
}
private static int findMatchingBrace(String s, int openIdx) {
int depth = 0;
boolean inString = false;
boolean escaped = false;
for (int i = openIdx; i < s.length(); i++) {
char c = s.charAt(i);
if (inString) {
if (escaped) {
escaped = false;
} else if (c == '\\') {
escaped = true;
} else if (c == '"') {
inString = false;
}
} else {
if (c == '"') {
inString = true;
} else if (c == '{') {
depth++;
} else if (c == '}') {
depth--;
if (depth == 0) {
return i;
}
}
}
}
return -1;
}
private static int skipNonObjectValue(String s, int start) {
int n = s.length();
char c = s.charAt(start);
if (c == '"') {
int end = findStringEnd(s, start);
return end < 0 ? n : end + 1;
}
if (c == '[') {
int depth = 0;
boolean inString = false;
boolean escaped = false;
for (int i = start; i < n; i++) {
char ch = s.charAt(i);
if (inString) {
if (escaped) escaped = false;
else if (ch == '\\') escaped = true;
else if (ch == '"') inString = false;
} else {
if (ch == '"') inString = true;
else if (ch == '[') depth++;
else if (ch == ']') {
depth--;
if (depth == 0) return i + 1;
}
}
}
return n;
}
int i = start;
while (i < n) {
char ch = s.charAt(i);
if (ch == ',' || ch == '}' || ch == ']') {
break;
}
i++;
}
return i;
}
public JsonObject buildConfigJson(String configName, boolean editable) {
@@ -110,7 +694,17 @@ public class ModuleConfigStorage extends JsonConfigFile {
if (!file.exists()) {
return null;
}
return (JsonObject)this.readJsonFile(file);
try {
byte[] bytes = Files.readAllBytes(file.toPath());
ConfigLoadReport silent = new ConfigLoadReport(configName, file);
String text = decryptWithDiagnostics(bytes, silent);
if (text == null || text.trim().isEmpty()) {
return null;
}
return parseConfigJsonWithFallback(text, silent);
} catch (Exception e) {
return null;
}
}
@Override
@@ -119,42 +713,83 @@ public class ModuleConfigStorage extends JsonConfigFile {
}
public void applyConfigJson(JsonObject json, String configName, boolean notify) {
ConfigLoadReport report = new ConfigLoadReport(configName, null);
this.applyConfigJson(json, configName, notify, report, System.currentTimeMillis());
}
private void applyConfigJson(JsonObject json, String configName, boolean notify, ConfigLoadReport report, long startTime) {
if (json == null) {
return;
}
Integer version = this.readConfigVersion(json);
if (version == null) {
System.err.println("Config missing Config_Version in Config_Header: " + configName);
if (notify) {
this.notifyConfigStatus("Invalid config header: §c" + configName, NotificationLevel.ERROR);
}
return;
report.markFallback("Config_Version missing in Config_Header -> falling back to ConfigFormatV2 (version 2)");
version = Integer.valueOf(2);
}
ModuleConfigCodec codec = this.formatCodecs.get(version);
if (codec == null) {
System.err.println("Unsupported Config_Version " + version + " in config: " + configName);
if (notify) {
this.notifyConfigStatus("Unsupported config version (" + version + "): §c" + configName, NotificationLevel.ERROR);
}
return;
report.markFallback("Unsupported Config_Version (" + version + ") -> attempting partial load with ConfigFormatV2");
codec = this.formatCodecs.get(2);
}
final ModuleConfigCodec activeCodec = codec;
try {
long startTime = System.currentTimeMillis();
codec.applyConfig(json);
if (notify) {
long elapsed = System.currentTimeMillis() - startTime;
this.notifyConfigStatus("Config loaded: §c" + configName + " (" + elapsed + "ms)", NotificationLevel.INFO);
if (activeCodec instanceof ConfigFormatV2) {
((ConfigFormatV2)activeCodec).applyConfig(json, report);
} else {
ConfigLoadReport.runWithCurrent(report, () -> activeCodec.applyConfig(json));
}
long elapsed = System.currentTimeMillis() - startTime;
if (report.getLoadedModules() == 0 && report.hasAnyIssue()) {
report.logToConsole();
if (notify) {
this.notifyConfigStatus(
"No se pudo cargar ningún módulo de: §c" + configName + " §7(" + report.getShortFailureReason() + " - revisa la consola)",
NotificationLevel.ERROR
);
}
return;
}
if (Augustus.getInstance().getModuleManager() != null) {
Augustus.getInstance().getModuleManager().sortModules();
}
if (report.hasAnyIssue()) {
report.logToConsole();
if (notify) {
String summary = "Config cargada parcialmente (fallback): §e" + configName
+ " §7[" + report.getLoadedModules() + " cargados, "
+ report.getDefaultedModules() + " en default"
+ (report.getTotalErrors() > 0 ? ", " + report.getTotalErrors() + " errores" : "")
+ " - revisa la consola]";
this.notifyConfigStatus(summary, NotificationLevel.WARNING);
ClientSounds.playSound(ClientSounds.AUGUSTUS_TEXTURE2);
}
} else if (notify) {
this.notifyConfigStatus("Config loaded: §c" + configName + " (" + elapsed + "ms)", NotificationLevel.INFO);
ClientSounds.playSound(ClientSounds.AUGUSTUS_TEXTURE2);
}
} catch (Exception e) {
e.printStackTrace();
report.recordError("ApplyConfig", "Unhandled exception applying config", e);
report.logToConsole();
if (notify) {
this.notifyConfigStatus(
"Error aplicando config: §c" + configName + " §7(" + e.getClass().getSimpleName() + ": " + e.getMessage() + " - revisa la consola)",
NotificationLevel.ERROR
);
}
}
}
public void saveConfig(String configName, String subDir, boolean editable) {
try {
JsonObject json = this.buildConfigJson(configName, editable);
if (json == null) {
System.err.println("[OpenAugustus-Config] Failed to build JSON when saving config: " + configName);
this.notifyConfigStatus("Failed to save config: §c" + configName + " §7(null JSON)", NotificationLevel.ERROR);
return;
}
File file = new File(this.getDirectoryPath() + subDir, configName + ".json");
long startTime = System.currentTimeMillis();
this.writeJsonFile(file, json);
@@ -162,7 +797,9 @@ public class ModuleConfigStorage extends JsonConfigFile {
ClientSounds.playSound(ClientSounds.AUGUSTUS_TEXTURE2);
this.notifyConfigStatus("Config saved: §c" + configName + " (" + elapsed + "ms)", NotificationLevel.INFO);
} catch (Exception e) {
System.err.println("[OpenAugustus-Config] Failed to save config '" + configName + "': " + e);
e.printStackTrace();
this.notifyConfigStatus("Failed to save config: §c" + configName + " §7(" + e.getMessage() + ")", NotificationLevel.ERROR);
}
}
@@ -219,11 +856,11 @@ public class ModuleConfigStorage extends JsonConfigFile {
}
Integer version = this.readConfigVersion(json);
if (version == null) {
return null;
version = Integer.valueOf(2);
}
ModuleConfigCodec codec = this.formatCodecs.get(version);
if (codec == null) {
return null;
codec = this.formatCodecs.get(2);
}
return codec.readHeaderInfo(json);
}
@@ -231,11 +868,14 @@ public class ModuleConfigStorage extends JsonConfigFile {
private Integer readConfigVersion(JsonObject json) {
if (json.has("Config_Header") && json.get("Config_Header").isJsonObject()) {
JsonObject header = json.getAsJsonObject("Config_Header");
if (header.has("Config_Version")) {
return header.get("Config_Version").getAsInt();
}
if (header.has("ConfigVersion")) {
return header.get("ConfigVersion").getAsInt();
try {
if (header.has("Config_Version")) {
return header.get("Config_Version").getAsInt();
}
if (header.has("ConfigVersion")) {
return header.get("ConfigVersion").getAsInt();
}
} catch (Exception ignored) {
}
}
return null;
@@ -88,6 +88,11 @@ public class ModuleSettingsConfigSection extends AbstractFeatureConfigFile {
return "Modules_Settings";
}
@Override
public boolean alwaysReserializeOnSave() {
return true;
}
private static JsonObject deepMergeJson(JsonObject json, JsonObject json2) {
JsonObject json3 = new JsonObject();
@@ -57,8 +57,8 @@ public class MinecraftBridgeImpl implements MinecraftBridge {
@Override
public String getUsername() {
Minecraft.getMinecraft();
return ((net.minecraft.util.Session)null).getUsername();
Session session = Minecraft.getMinecraft().getSession();
return session != null ? session.getUsername() : "";
}
@Override
@@ -40,7 +40,7 @@ public enum GeoDirection {
}
public int getFrontOffsetZ() {
return null == null && this.axis != GeoAxis.Z ? 0 : 0;
return this.axis == GeoAxis.Z ? this.axisDirection.getOffset() : 0;
}
public int getIndex() {
@@ -69,7 +69,7 @@ public enum GeoDirection {
}
public int getFrontOffsetY() {
return null == null && this.axis != GeoAxis.Y ? 0 : 0;
return this.axis == GeoAxis.Y ? this.axisDirection.getOffset() : 0;
}
public GeoDirection rotateAround(GeoAxis geoAxis) {
@@ -115,16 +115,7 @@ public enum GeoDirection {
}
public static GeoDirection byName(String str) {
Object obj2 = str;
if (null == null) {
if (str == null) {
return null;
}
obj2 = NAME_LOOKUP.get(str.toLowerCase());
}
return (GeoDirection)obj2;
return str == null ? null : (GeoDirection)NAME_LOOKUP.get(str.toLowerCase());
}
@Override
@@ -180,7 +171,7 @@ public enum GeoDirection {
}
public int getFrontOffsetX() {
return null == null && this.axis != GeoAxis.X ? 0 : 0;
return this.axis == GeoAxis.X ? this.axisDirection.getOffset() : 0;
}
public IntVector3 getDirectionVec() {
@@ -188,7 +179,7 @@ public enum GeoDirection {
}
public static GeoDirection random(Random rand) {
return (GeoDirection)((Object[])null)[rand.nextInt(((Object[])null).length)];
return VALUES[rand.nextInt(VALUES.length)];
}
public static GeoDirection fromAngle(double d) {
@@ -182,16 +182,12 @@ public class CosmeticTextureManager {
public ResourceLocation getOrCreateResourceLocation(String str, String str2) {
ResourceLocation location = (ResourceLocation)this.resourceLocations.get(str);
ResourceLocation location2 = location;
if (null != null) {
if (location == null) {
this.resourceLocations.put(str, location = new ResourceLocation(str2));
}
location2 = location;
if (location == null) {
location = new ResourceLocation(str2);
this.resourceLocations.put(str, location);
}
return location2;
return location;
}
private void loadRemoteImage(String str, String str2, BufferedImage image, CosmeticImageProcessor cosmeticImageProcessor) {
@@ -22,7 +22,7 @@ public class EventManager {
stringWriter.close();
writer.close();
if (str != null) {
str = str.substring(0, Math.min(str.length() - 1, 1000));
System.err.println("[EventManager] Unhandled listener exception:\n" + str.substring(0, Math.min(str.length(), 1500)));
}
lastExceptionReportTime = currentTimeMs;
@@ -3,6 +3,9 @@ package net.augustus.modules;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import java.util.List;
import net.augustus.config.ConfigLoadReport;
import net.augustus.settings.Setting;
import net.augustus.settings.property.AbstractConfigProperty;
import net.augustus.settings.property.ConfigProperty;
import net.augustus.settings.property.ConfigSerializerProvider;
import net.augustus.utils.UnaryFunction;
@@ -35,30 +38,100 @@ public class AbstractFeature extends FeatureBase implements ConfigProperty {
@Override
public void deserialize(ConfigSerializerProvider configSerializerProvider, JsonObject json, boolean flag, UnaryFunction unaryFunction) {
ConfigLoadReport report = ConfigLoadReport.current();
JsonObject json2;
if (this.getName() != null) {
JsonElement elem = json.get(this.getName());
if (elem == null) {
json2 = json;
} else {
if (!elem.isJsonObject()) {
JsonElement elem = json != null ? json.get(this.getName()) : null;
if (elem == null || elem.isJsonNull()) {
if (flag) {
json2 = new JsonObject();
if (report != null && this instanceof Module && ((Module)this).isLoadFromConfig()) {
report.recordDefaultedModule(this.getName());
}
} else {
json2 = json != null ? json : new JsonObject();
}
} else if (!elem.isJsonObject()) {
if (report != null) {
String detail = "Expected JSON object, found " + elem.getClass().getSimpleName() + ": " + elem;
if (this instanceof Module) {
report.recordFailedModule(this.getName(), detail, null);
} else {
report.recordFailedSetting(this.buildFeaturePath(), detail, null);
}
}
if (flag) {
json2 = new JsonObject();
} else {
return;
}
} else {
json2 = elem.getAsJsonObject();
if (report != null && this instanceof Module && ((Module)this).isLoadFromConfig()) {
report.recordLoadedModule(this.getName());
}
}
} else {
json2 = json;
json2 = json != null ? json : new JsonObject();
}
for (int i = this.getProperties().size() - 1; i >= 0; i--) {
ConfigProperty configProperty = (ConfigProperty)this.getProperties().get(i);
if ((Boolean)unaryFunction.apply(configProperty)) {
configProperty.deserialize(configSerializerProvider, json2, flag, unaryFunction);
try {
if ((Boolean)unaryFunction.apply(configProperty)) {
configProperty.deserialize(configSerializerProvider, json2, flag, unaryFunction);
}
} catch (Throwable t) {
String path = this.buildPropertyPath(configProperty);
JsonElement rawElem = configProperty.getName() != null && json2.has(configProperty.getName())
? json2.get(configProperty.getName())
: null;
String detail = "Failed to deserialize" + (rawElem != null ? " (json=" + rawElem + ")" : "");
if (report != null) {
if (configProperty instanceof Module) {
report.recordFailedModule(configProperty.getName(), detail, t);
} else {
report.recordFailedSetting(path, detail, t);
}
} else {
System.err.println("[OpenAugustus-Config] Error deserializing " + path + ": " + t);
t.printStackTrace();
}
if (flag) {
try {
if (configProperty instanceof AbstractConfigProperty) {
((AbstractConfigProperty)configProperty).resetToDefault();
} else if (configProperty instanceof Setting) {
((Setting)configProperty).resetToDefault();
}
} catch (Throwable ignored) {
}
}
}
}
this.onAfterDeserialize();
try {
this.onAfterDeserialize();
} catch (Throwable t) {
if (report != null) {
report.recordFailedSetting(this.buildFeaturePath(), "onAfterDeserialize failed", t);
} else {
t.printStackTrace();
}
}
}
private String buildFeaturePath() {
if (this.featureBase != null && this.featureBase.getName() != null) {
return this.featureBase.getName() + "." + this.getName();
}
return this.getName() != null ? this.getName() : "<root>";
}
private String buildPropertyPath(ConfigProperty prop) {
String propName = prop != null && prop.getName() != null ? prop.getName() : "<prop>";
String parent = this.buildFeaturePath();
return parent.equals("<root>") ? propName : parent + "." + propName;
}
@Override
@@ -84,7 +84,7 @@ public abstract class Module extends AbstractFeature implements MC, Comparable {
Consumer<Boolean> consumer2 = bool2 -> this.setLoadFromConfig(bool2);
this.loadFromConfigProperty = (BooleanProperty)booleanProperty2.withOnValueChanged(consumer2);
BooleanProperty booleanProperty3 = new BooleanProperty(this, "M_A", true);
Consumer<Boolean> consumer3 = bool3 -> this.onTogglePropertyChanged(bool3);
Consumer<Boolean> consumer3 = bool3 -> this.setShowInArrayList(bool3);
this.showInArrayListProperty = (BooleanProperty)booleanProperty3.withOnValueChanged(consumer3);
BooleanProperty booleanProperty4 = new BooleanProperty(this, "M_S", true);
Consumer<Boolean> consumer4 = bool4 -> this.setToggleSoundEnabled(bool4);
@@ -136,7 +136,7 @@ public abstract class Module extends AbstractFeature implements MC, Comparable {
Consumer<Boolean> consumer2 = bool2 -> this.setLoadFromConfig(bool2);
this.loadFromConfigProperty = (BooleanProperty)booleanProperty2.withOnValueChanged(consumer2);
BooleanProperty booleanProperty3 = new BooleanProperty(this, "M_A", true);
Consumer<Boolean> consumer3 = bool3 -> this.onTogglePropertyChanged(bool3);
Consumer<Boolean> consumer3 = bool3 -> this.setShowInArrayList(bool3);
this.showInArrayListProperty = (BooleanProperty)booleanProperty3.withOnValueChanged(consumer3);
BooleanProperty booleanProperty4 = new BooleanProperty(this, "M_S", true);
Consumer<Boolean> consumer4 = bool4 -> this.setToggleSoundEnabled(bool4);
@@ -175,7 +175,7 @@ public abstract class Module extends AbstractFeature implements MC, Comparable {
this.color = color2;
this.categorys = categorys2;
this.sessionExpireTimeMs = this.lastToggleTimeMs + 171000000L;
this.setLoadFromConfig(this.categorys != Categorys.RENDER);
this.setLoadFromConfig(true);
Augustus.getInstance().getModuleRegistry().getModules().add(this);
this.alwaysEnabled = false;
this.registerInCategory();
@@ -190,7 +190,7 @@ public abstract class Module extends AbstractFeature implements MC, Comparable {
Consumer<Boolean> consumer2 = bool2 -> this.setLoadFromConfig(bool2);
this.loadFromConfigProperty = (BooleanProperty)booleanProperty2.withOnValueChanged(consumer2);
booleanProperty2 = new BooleanProperty(this, "M_A", true);
Consumer<Boolean> consumer3 = bool3 -> this.onTogglePropertyChanged(bool3);
Consumer<Boolean> consumer3 = bool3 -> this.setShowInArrayList(bool3);
this.showInArrayListProperty = (BooleanProperty)booleanProperty2.withOnValueChanged(consumer3);
BooleanProperty booleanProperty3 = new BooleanProperty(this, "M_S", true);
Consumer<Boolean> consumer4 = bool4 -> this.setToggleSoundEnabled(bool4);
@@ -228,7 +228,7 @@ public abstract class Module extends AbstractFeature implements MC, Comparable {
this.displayName = str;
this.color = color2;
this.categorys = categorys2;
this.setLoadFromConfig(this.categorys != Categorys.RENDER);
this.setLoadFromConfig(true);
this.setShowInArrayList(false);
Augustus.getInstance().getModuleRegistry().getModules().add(this);
this.alwaysEnabled = true;
@@ -72,6 +72,7 @@ public class MoveHelper extends Module implements LoadWorldListener, MoveInputLi
@Override
public void updateEventSubscriptions() {
this.toggleEventSubscription(1);
this.toggleEventSubscription(21, 1000);
this.toggleEventSubscription(40);
this.toggleEventSubscription(35);
@@ -26,12 +26,12 @@ public class MovementRecorder extends Module {
@Override
public void onEnable() {
((net.minecraft.util.Timer)null).timerSpeed = 1.0F;
mc.getTimer().timerSpeed = 1.0F;
}
@Override
public void onDisable() {
((net.minecraft.util.Timer)null).timerSpeed = 1.0F;
mc.getTimer().timerSpeed = 1.0F;
}
@Override
@@ -33,7 +33,7 @@ public class FullBright extends Module implements NightVisionListener {
@Override
public void onDisable() {
((GameSettings)null).gammaSetting = Math.min(this.savedGamma, 1.0F);
mc.gameSettings.gammaSetting = Math.min(this.savedGamma, 1.0F);
}
@Override
@@ -89,6 +89,7 @@ public class ItemESP extends Module implements RenderListener, TickListener {
@Override
public void updateEventSubscriptions() {
this.toggleEventSubscription(40);
}
public static boolean isItemWhitelisted(Item item) {
@@ -100,6 +100,7 @@ public class MiniMap extends Module implements TickListener, RenderListener, Pac
@Override
public void updateEventSubscriptions() {
this.toggleEventSubscription(17);
this.toggleEventSubscription(32);
this.toggleEventSubscription(26);
this.toggleEventSubscription(55);
@@ -67,13 +67,13 @@ public class Tracers extends Module implements OrientCameraListener, RenderListe
@Override
public void onEnable() {
this.savedViewBobbing = ((GameSettings)null).viewBobbing;
((GameSettings)null).viewBobbing = false;
this.savedViewBobbing = mc.gameSettings.viewBobbing;
mc.gameSettings.viewBobbing = false;
}
@Override
public void onDisable() {
((GameSettings)null).viewBobbing = this.savedViewBobbing;
mc.gameSettings.viewBobbing = this.savedViewBobbing;
this.targetEntities.clear();
}
@@ -60,14 +60,18 @@ public class XRay extends Module implements NightVisionListener, TickListener {
@Override
public void onEnable() {
enabled = true;
mc.renderGlobal.loadRenderers();
if (mc.renderGlobal != null) {
mc.renderGlobal.loadRenderers();
}
this.snapshotAntiXraySettings();
}
@Override
public void onDisable() {
enabled = false;
((RenderGlobal)null).loadRenderers();
if (mc.renderGlobal != null) {
mc.renderGlobal.loadRenderers();
}
}
@Override
@@ -435,7 +435,7 @@ public class FailedScaffold extends Module implements TickListener, MoveInputLis
}
private double getPitchDeltaScore(ScaffoldRaycastResult scaffoldRaycastResult) {
return (double)Math.abs(scaffoldRaycastResult.pitch - ((Rotation)null).pitch);
return (double)Math.abs(scaffoldRaycastResult.pitch - ClientManagers.rotationController.getPreviousRotation().pitch);
}
private double getHitCenterOffset(ScaffoldRaycastResult scaffoldRaycastResult, float f, Vec3 vec) {
@@ -3241,7 +3241,7 @@ if (!this.isTellyBridgeEnabled() || this.shouldRotateBackwardInTelly()) {
}
private double getPitchDeltaFromNull(float[] floats) {
return (double)Math.abs(floats[0] - ((Rotation)null).pitch);
return (double)Math.abs(floats[0] - ClientManagers.rotationController.getPreviousRotation().pitch);
}
private double getPitchDeltaScore(ScaffoldRaycastResult scaffoldRaycastResult) {
@@ -158,13 +158,13 @@ public class ColorSetting extends Setting {
}
private void onFadeAlphaPropertyChanged(int n) {
Color color = new Color((Integer)this.fc.getValue());
this.setFadeColor(new Color(color.getRed(), color.getGreen(), color.getBlue(), n));
Color color = this.fadeColor != null ? this.fadeColor : new Color((Integer)this.fc.getValue());
this.setFadeColor(new Color(color.getRed(), color.getGreen(), color.getBlue(), MathHelper.clamp_int(n, 0, 255)));
}
private void onPrimaryRgbPropertyChanged(Integer num) {
Color color = new Color(num);
this.setPrimaryColor(new Color(color.getRed(), color.getGreen(), color.getBlue(), this.getPrimaryAlpha()));
this.setPrimaryColor(new Color(color.getRed(), color.getGreen(), color.getBlue(), MathHelper.clamp_int(this.getPrimaryAlpha(), 0, 255)));
}
public void setRainbowDistance(double rainbowDistance) {
@@ -329,9 +329,8 @@ public class ColorSetting extends Setting {
public ColorSetting withDefaultPrimaryColor(Color color) {
this.setPrimaryColor(new Color(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha()));
IntegerProperty integerProperty = this.c;
Integer rgb = color.getRGB();
integerProperty.setDefaultValue(rgb);
this.c.setDefaultValue(this.toOpaqueRgb(color));
this.a.setDefaultValue(color.getAlpha());
return this;
}
@@ -409,7 +408,8 @@ public class ColorSetting extends Setting {
this.setPrimaryAlpha(n13);
this.renderYOffset += 27;
Color color = new Color(Color.HSBtoRGB(this.primaryHsb[0], this.primaryHsb[1], this.primaryHsb[2]));
this.primaryColor = new Color(color.getRed(), color.getGreen(), color.getBlue(), this.getPrimaryAlpha());
this.primaryColor = new Color(color.getRed(), color.getGreen(), color.getBlue(), MathHelper.clamp_int(this.getPrimaryAlpha(), 0, 255));
this.c.setValue(this.toOpaqueRgb(this.primaryColor));
int n16 = s + 40;
int n17 = 25;
n14 = n3 + n16;
@@ -510,7 +510,8 @@ public class ColorSetting extends Setting {
n17 = 0;
n16 += s + 50;
Color color2 = new Color(Color.HSBtoRGB(this.fadeHsb[0], this.fadeHsb[1], this.fadeHsb[2]));
this.fadeColor = new Color(color2.getRed(), color2.getGreen(), color2.getBlue(), this.getFadeAlpha());
this.fadeColor = new Color(color2.getRed(), color2.getGreen(), color2.getBlue(), MathHelper.clamp_int(this.getFadeAlpha(), 0, 255));
this.fc.setValue(this.toOpaqueRgb(this.fadeColor));
}
}
@@ -587,8 +588,8 @@ public class ColorSetting extends Setting {
super(module, doubleValue, str);
IntegerProperty integerProperty = new IntegerProperty(this, "A", 0);
Consumer consumer = obj -> {
Color color2 = new Color((Integer)this.c.getValue());
this.setPrimaryColor(new Color(color2.getRed(), color2.getGreen(), color2.getBlue(), (Integer)obj));
Color color2 = this.primaryColor != null ? this.primaryColor : new Color((Integer)this.c.getValue());
this.setPrimaryColor(new Color(color2.getRed(), color2.getGreen(), color2.getBlue(), MathHelper.clamp_int((Integer)obj, 0, 255)));
};
this.a = (IntegerProperty)integerProperty.withOnValueChanged(consumer);
this.fa = (IntegerProperty)new IntegerProperty(this, "FA", 0).withOnValueChanged(obj2 -> this.onFadeAlphaPropertyChanged((int)obj2));
@@ -688,9 +689,8 @@ public class ColorSetting extends Setting {
public ColorSetting withDefaultFadeColor(Color color) {
this.setFadeColor(new Color(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha()));
IntegerProperty fc2 = this.fc;
Integer rgb = color.getRGB();
fc2.setDefaultValue(rgb);
this.fc.setDefaultValue(this.toOpaqueRgb(color));
this.fa.setDefaultValue(color.getAlpha());
return this;
}
@@ -846,7 +846,7 @@ public class ColorSetting extends Setting {
private void onFadeRgbPropertyChanged(Integer num) {
Color color = new Color(num);
this.setFadeColor(new Color(color.getRed(), color.getGreen(), color.getBlue(), this.getFadeAlpha()));
this.setFadeColor(new Color(color.getRed(), color.getGreen(), color.getBlue(), MathHelper.clamp_int(this.getFadeAlpha(), 0, 255)));
}
public ColorSetting withDefaultRainbowSpeed(int defaultRainbowSpeed) {
@@ -868,6 +868,9 @@ public class ColorSetting extends Setting {
public void setPrimaryColor(Color color) {
this.primaryColor = color;
this.setPrimaryAlpha(this.primaryColor.getAlpha());
if (this.c != null) {
this.c.setValue(this.toOpaqueRgb(this.primaryColor));
}
Color.RGBtoHSB(this.primaryColor.getRed(), this.primaryColor.getGreen(), this.primaryColor.getBlue(), this.primaryHsb);
}
@@ -965,6 +968,9 @@ public class ColorSetting extends Setting {
public void setFadeColor(Color color) {
this.fadeColor = color;
this.setFadeAlpha(this.fadeColor.getAlpha());
if (this.fc != null) {
this.fc.setValue(this.toOpaqueRgb(this.fadeColor));
}
Color.RGBtoHSB(this.fadeColor.getRed(), this.fadeColor.getGreen(), this.fadeColor.getBlue(), this.fadeHsb);
}
@@ -84,7 +84,7 @@ public abstract class AbstractConfigProperty implements ConfigProperty {
}
public void applyValue(Object obj) {
if (this.onValueChanged != null && obj != this.getValue()) {
if (this.onValueChanged != null && !java.util.Objects.equals(obj, this.getValue())) {
this.invokeConsumerSafely(this.onValueChanged, obj);
}
@@ -29,11 +29,24 @@ import net.minecraft.client.Minecraft;
import org.apache.commons.io.FileUtils;
public class ClientFileUtil {
public static final String WORKING_DIR = System.getProperty("user.dir").endsWith(File.separator)
? System.getProperty("user.dir")
: System.getProperty("user.dir") + File.separator;
public static final String WORKING_DIR = resolveWorkingDir();
public static final Gson GSON = new GsonBuilder().setPrettyPrinting().create();
private static String resolveWorkingDir() {
String base = System.getProperty("user.dir");
try {
Minecraft mc = Minecraft.getMinecraft();
if (mc != null && mc.mcDataDir != null) {
base = mc.mcDataDir.getAbsolutePath();
}
} catch (Throwable ignored) {
}
if (base == null || base.isEmpty()) {
base = ".";
}
return base.endsWith(File.separator) ? base : base + File.separator;
}
public static void writeJsonArray(String str, String str2, JsonArray array) {
writeJsonArray(str, str2, array, GsonConstants.PRETTY_GSON);
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loaded 100 of 274 files, more files were not shown because too many files have changed in this diff. Show more