Skip to content

Commit

Permalink
✨ New Basic Config File
Browse files Browse the repository at this point in the history
  • Loading branch information
ItsMaddieNow committed Nov 16, 2023
1 parent 0037040 commit ef75382
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 0 deletions.
3 changes: 3 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ dependencies {
modApi(libs.statement){ exclude group: "net.fabricmc.fabric-api" }
include libs.statement

modImplementation libs.spruceui
include libs.spruceui

// QSL is not a complete API; You will need Quilted Fabric API to fill in the gaps.
// Quilted Fabric API will automatically pull in the correct QSL version.
modImplementation libs.quilted.fabric.api
Expand Down
2 changes: 2 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ qsl = "6.1.2+1.20.1"
quilted_fabric_api = "7.0.3+0.83.1-1.20.1"

statement = "4.2.5"
spruceui = "5.0.2+1.20"

quilt_loom = "1.0.+"
loom_vineflower = "1.11.0"
Expand All @@ -26,6 +27,7 @@ quilted_fabric_api = { module = "org.quiltmc.quilted-fabric-api:quilted-fabric-a
quilted_fabric_api_deprecated = { module = "org.quiltmc.quilted-fabric-api:quilted-fabric-api-deprecated", version.ref = "quilted_fabric_api" }

statement = { module = "com.github.Virtuoel:Statement", version.ref = "statement" }
spruceui = { module = "dev.lambdaurora:spruceui", version.ref = "spruceui" }

# If you have multiple similar dependencies, you can declare a dependency bundle and reference it on the build script with "libs.bundles.example".
[bundles]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
package io.github.ItsMaddieNow.building_tweaks;

import io.github.ItsMaddieNow.building_tweaks.config.AbstractConfig;
import io.github.ItsMaddieNow.building_tweaks.config.BTQuiltConfig;
import io.github.ItsMaddieNow.building_tweaks.flowers.FlowerTweaks;
import org.quiltmc.loader.api.ModContainer;
import org.quiltmc.qsl.base.api.entrypoint.ModInitializer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


public class BuildingTweaks implements ModInitializer {
// This logger is used to write text to the console and the log file.
// It is considered best practice to use your mod name as the logger's name.
// That way, it's clear which mod wrote info, warnings, and errors.
public static final String IDHuman = "Maddies Building Tweaks" ;
public static final String ID = "maddies_building_tweaks" ;
public static final Logger LOGGER = LoggerFactory.getLogger(IDHuman);
public static final AbstractConfig CONFIG = new BTQuiltConfig();

@Override
public void onInitialize(ModContainer mod) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package io.github.ItsMaddieNow.building_tweaks.config;

public abstract class AbstractConfig {
public boolean flowersEnabled = true;
public boolean bonemealEnabled = true;
public boolean potsEnabled = true;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package io.github.ItsMaddieNow.building_tweaks.config;

import io.github.ItsMaddieNow.building_tweaks.BuildingTweaks;
import org.quiltmc.config.api.ReflectiveConfig;
import org.quiltmc.config.api.annotations.Comment;
import org.quiltmc.config.api.values.TrackedValue;
import org.quiltmc.loader.api.config.v2.QuiltConfig;

public class BTQuiltConfig extends AbstractConfig {
public static final BTReflectiveConfig CONFIG = QuiltConfig.create(BuildingTweaks.ID, "config", BTReflectiveConfig.class);
public BTQuiltConfig(){
update();
CONFIG.registerCallback(config -> this.update());
}

public void update(){
flowersEnabled = CONFIG.flowerConfig.enabled.value();
bonemealEnabled = CONFIG.flowerConfig.enable_bonemeal.value();
potsEnabled = CONFIG.enable_pots.value();
}

public static class BTReflectiveConfig extends ReflectiveConfig{
@Comment("Settings Related To Flowers")
public final FlowerConfig flowerConfig = new FlowerConfig();
public final TrackedValue<Boolean> enable_pots = this.value(true);

public static class FlowerConfig extends Section{
public final TrackedValue<Boolean> enabled = this.value(true);
public final TrackedValue<Boolean> enable_bonemeal = this.value(true);
}

}
}

0 comments on commit ef75382

Please sign in to comment.