From 70552b60c4998de6d82ff2e537eefd5e58c9c27f Mon Sep 17 00:00:00 2001 From: Andbeav Date: Sat, 8 Jan 2022 12:32:16 +0200 Subject: [PATCH] Feature toggle session persistence and cleaning up config --- README.md | 7 ++++--- gradle.properties | 2 +- src/main/java/net/fabricmc/safetweaks/InitializerMod.java | 8 +++++++- .../fabricmc/safetweaks/config/FeatureFlagManager.java | 2 +- .../fabricmc/safetweaks/modmenu/ClothConfigModMenu.java | 8 ++------ src/main/resources/fabric.mod.json | 4 ++-- 6 files changed, 17 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index cdb483c..3801d06 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,11 @@ # SafeTweaks -QOL tweaks that should be safe for any normal servers to allow +QOL tweaks that should be safe for servers. Think [Tweakeroo](https://github.com/maruohon/tweakeroo) without the 'hacky' features. ## Requirements -I believe it's only ModMenu/ClothConfig +* [ModMenu](https://github.com/TerraformersMC/ModMenu) +* [ClothConfig](https://github.com/shedaniel/cloth-config) ## Current tweaks @@ -13,4 +14,4 @@ I believe it's only ModMenu/ClothConfig ## Usage -Accessing the SafeTweaks menu in the mod menu should give you the options. \ No newline at end of file +Assuming you have the required mods, the Mod menu button on the main/pause screen should list SafeTweaks and the given options. \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 3e4f015..f66a3a6 100644 --- a/gradle.properties +++ b/gradle.properties @@ -11,7 +11,7 @@ org.gradle.jvmargs=-Xmx1G loader_version=0.12.12 # Mod Properties - mod_version = 1.0.0 + mod_version = 1.0.1 maven_group = com.safetweaks archives_base_name = safetweaks diff --git a/src/main/java/net/fabricmc/safetweaks/InitializerMod.java b/src/main/java/net/fabricmc/safetweaks/InitializerMod.java index 16078e5..411df05 100644 --- a/src/main/java/net/fabricmc/safetweaks/InitializerMod.java +++ b/src/main/java/net/fabricmc/safetweaks/InitializerMod.java @@ -19,7 +19,13 @@ public void onInitialize() { // However, some things (like resources) may still be uninitialized. // Proceed with mild caution. - FeatureFlagManager.getInstance().set("renderDistanceFogToggle", false); + initializeFeatureFlags(); + LOGGER.info("SafeTweaks init!"); } + + private void initializeFeatureFlags() { + FeatureFlagManager featureFlags = FeatureFlagManager.getInstance(); + featureFlags.set("renderDistanceFogToggle", false); + } } diff --git a/src/main/java/net/fabricmc/safetweaks/config/FeatureFlagManager.java b/src/main/java/net/fabricmc/safetweaks/config/FeatureFlagManager.java index e41ea0e..13313ef 100644 --- a/src/main/java/net/fabricmc/safetweaks/config/FeatureFlagManager.java +++ b/src/main/java/net/fabricmc/safetweaks/config/FeatureFlagManager.java @@ -28,7 +28,7 @@ public Boolean get(String key) throws FeatureMissingException { if(FeatureFlags.keySet().contains(key)) { return FeatureFlags.get(key); } else { - throw new FeatureMissingException("Key does not found in features: " + key); + throw new FeatureMissingException("Key not found in features: " + key); } } } diff --git a/src/main/java/net/fabricmc/safetweaks/modmenu/ClothConfigModMenu.java b/src/main/java/net/fabricmc/safetweaks/modmenu/ClothConfigModMenu.java index 7e4d5cc..eb33ed8 100644 --- a/src/main/java/net/fabricmc/safetweaks/modmenu/ClothConfigModMenu.java +++ b/src/main/java/net/fabricmc/safetweaks/modmenu/ClothConfigModMenu.java @@ -29,14 +29,10 @@ public static ConfigBuilder getConfigBuilderWithOptions() { // Gamma tweak Double gamma = client.options.gamma; - tweaks.addEntry(entryBuilder.startDoubleField(new TranslatableText("config.safetweaks.gamma"), gamma).setDefaultValue(gamma).setSaveConsumer(newVal -> client.options.gamma = newVal).build()); + tweaks.addEntry(entryBuilder.startDoubleField(new TranslatableText("config.safetweaks.gamma"), gamma).setDefaultValue(0.0).setSaveConsumer(newVal -> client.options.gamma = newVal).build()); // Render distance fog override tweak - tweaks.addEntry(entryBuilder.startBooleanToggle(new TranslatableText("config.safetweaks.render-distance-fog"), false).setDefaultValue(false).setSaveConsumer((newVal) -> { featureFlags.set("renderDistanceFogToggle", newVal); }).build()); - - // On save - // builder.setSavingRunnable(() -> { - // }); + tweaks.addEntry(entryBuilder.startBooleanToggle(new TranslatableText("config.safetweaks.render-distance-fog"), featureFlags.get("renderDistanceFogToggle")).setDefaultValue(false).setSaveConsumer((newVal) -> { featureFlags.set("renderDistanceFogToggle", newVal); }).build()); // Returning the builder builder.transparentBackground(); diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 666c43f..06d5b27 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -9,8 +9,8 @@ "Andbeav" ], "contact": { - "homepage": "https://fabricmc.net/", - "sources": "https://github.com/FabricMC/fabric-example-mod" + "homepage": "https://github.com/Andbeav/SafeTweaks", + "sources": "https://github.com/Andbeav/SafeTweaks" }, "license": "CC0-1.0",