Allow setting config options via JVM properties

This commit is contained in:
embeddedt 2023-08-10 20:31:39 -04:00
parent 34179fb313
commit e9ff7d7ba1
No known key found for this signature in database
GPG Key ID: A69433EC199B5613
2 changed files with 21 additions and 0 deletions

View File

@ -11,6 +11,7 @@ import org.embeddedt.modernfix.ModernFix;
import org.embeddedt.modernfix.annotation.ClientOnlyMixin;
import org.embeddedt.modernfix.annotation.IgnoreOutsideDev;
import org.embeddedt.modernfix.annotation.RequiresMod;
import org.embeddedt.modernfix.core.ModernFixMixinPlugin;
import org.embeddedt.modernfix.platform.ModernFixPlatformHooks;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.Type;
@ -253,6 +254,17 @@ public class ModernFixEarlyConfig {
}
}
private void readJVMProperties() {
for(String optionKey : this.options.keySet()) {
String value = System.getProperty("modernfix.config." + optionKey);
if(value == null || value.length() == 0)
continue;
boolean isEnabled = Boolean.valueOf(value);
ModernFixMixinPlugin.instance.logger.info("Configured {} to '{}' via JVM property.", optionKey, isEnabled);
this.options.get(optionKey).setEnabled(isEnabled, true);
}
}
private void readProperties(Properties props) {
if(ALLOW_OVERRIDE_OVERRIDES)
LOGGER.fatal("JVM argument given to override mod overrides. Issues opened with this option present will be ignored unless they can be reproduced without.");
@ -341,6 +353,8 @@ public class ModernFixEarlyConfig {
} catch (IOException e) {
LOGGER.warn("Could not write configuration file", e);
}
config.readJVMProperties();
}
return config;

View File

@ -2,6 +2,13 @@ apply plugin: "dev.architectury.loom"
loom {
accessWidenerPath = project(":common").loom.accessWidenerPath
runs {
client {
property("modernfix.config.mixin.perf.blast_search_trees", "true")
property("modernfix.config.mixin.perf.dynamic_resources", "true")
property("modernfix.config.mixin.perf.dynamic_block_codecs", "true")
}
}
}
dependencies {