Skip to content

Commit

Permalink
change config system
Browse files Browse the repository at this point in the history
  • Loading branch information
flustix committed Jul 16, 2022
1 parent 8e911c3 commit 396a578
Show file tree
Hide file tree
Showing 19 changed files with 130 additions and 335 deletions.
8 changes: 7 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ version = project.mod_version
group = project.maven_group

repositories {
maven { url 'https://jitpack.io' }
maven {
url 'https://jitpack.io'
}
maven {
url 'https://maven.foxes4life.net'
}
}

configurations {
Expand All @@ -30,6 +35,7 @@ dependencies {
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"

implementation 'com.github.Vatuu:discord-rpc:1.6.2'
implementation 'net.foxes4life:konfig:1.1'
extraLibs files('discord-rpc-jna-removed.jar')

//configurations.compile.extendsFrom(configurations.extraLibs)
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ org.gradle.jvmargs=-Xmx2G
loader_version=0.14.6

# Mod Properties
mod_version = 0.1.4-1.19
mod_version = 0.1.5-1.19
maven_group = net.foxes4life
archives_base_name = foxclient

Expand Down
43 changes: 35 additions & 8 deletions src/main/java/net/foxes4life/foxclient/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,19 @@

import net.fabricmc.api.ModInitializer;
import net.fabricmc.loader.api.FabricLoader;
import net.foxes4life.foxclient.config.Config;
import net.foxes4life.foxclient.config.ConfigData;
import net.foxes4life.konfig.Konfig;
import net.foxes4life.konfig.data.KonfigCategory;

public class Main implements ModInitializer {
public static final String FOXCLIENT_MOD_ID = "foxclient";
public static String VERSION = "";
public static String JAVA_VERSION = "unknown";

public static Config config_instance;
public static ConfigData config;
public static Konfig konfig;

@Override
public void onInitialize() {
Config.load("config.json");
config_instance = Config.getInstance();
config = Config.getData();
config_instance.toFile("config.json");
initConfig();

if(FabricLoader.getInstance().getModContainer(Main.FOXCLIENT_MOD_ID).isPresent()) {
VERSION = FabricLoader.getInstance().getModContainer(Main.FOXCLIENT_MOD_ID).get().getMetadata().getVersion().getFriendlyString();
Expand All @@ -31,4 +27,35 @@ public void onInitialize() {
System.out.println("FoxClient (recode) by Rooot and Flustix");
System.out.println(Main.VERSION);
}

void initConfig () {
konfig = new Konfig("foxclient");

KonfigCategory client = new KonfigCategory("client");
client.addEntry("hud-enabled", true);

KonfigCategory menus = new KonfigCategory("menus");
menus.addEntry("mainmenu", true);
menus.addEntry("pause", false);

KonfigCategory misc = new KonfigCategory("misc");
misc.addEntry("discord-rpc", true);
misc.addEntry("discord-rpc-show-ip", true);

KonfigCategory eastereggs = new KonfigCategory("eastereggs");
eastereggs.addEntry("owo", false);

KonfigCategory ingameHUD = new KonfigCategory("ingame-hud");
ingameHUD.addEntry("version", true);
ingameHUD.addEntry("coords", true);
ingameHUD.addEntry("fps", true);
ingameHUD.addEntry("ping", true);
ingameHUD.addEntry("tps", true);

konfig.addCategory(client);
konfig.addCategory(menus);
konfig.addCategory(ingameHUD);
konfig.addCategory(misc);
konfig.addCategory(eastereggs);
}
}
8 changes: 6 additions & 2 deletions src/main/java/net/foxes4life/foxclient/MainClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import net.minecraft.client.option.KeyBinding;
import org.lwjgl.glfw.GLFW;

import java.io.IOException;

public class MainClient implements ClientModInitializer {
private static final KeyBinding toggleHud = new KeyBinding("key.foxclient.toggle_hud", GLFW.GLFW_KEY_F6, "category.foxclient.main");
private static final KeyBinding clientConfig = new KeyBinding("key.foxclient.configKey", GLFW.GLFW_KEY_RIGHT_CONTROL, "category.foxclient.main");
Expand All @@ -33,8 +35,10 @@ public void onInitializeClient() {

ClientTickEvents.END_CLIENT_TICK.register(client -> {
while (toggleHud.wasPressed()) {
Main.config_instance.set("client", "hud-enabled",
Main.config_instance.getEntry("client", "hud-enabled").setValue(!Main.config_instance.getBoolean("client", "hud-enabled")));
Main.konfig.set("client", "hud-enabled", !(boolean) Main.konfig.get("client", "hud-enabled"));
try {
Main.konfig.save();
} catch (IOException ignored) {}
}
});

Expand Down
31 changes: 0 additions & 31 deletions src/main/java/net/foxes4life/foxclient/config/Category.java

This file was deleted.

31 changes: 0 additions & 31 deletions src/main/java/net/foxes4life/foxclient/config/CategoryEntry.java

This file was deleted.

149 changes: 0 additions & 149 deletions src/main/java/net/foxes4life/foxclient/config/Config.java

This file was deleted.

56 changes: 0 additions & 56 deletions src/main/java/net/foxes4life/foxclient/config/ConfigData.java

This file was deleted.

Loading

0 comments on commit 396a578

Please sign in to comment.