aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com>2022-08-10 12:47:30 +0200
committerGitHub <noreply@github.com>2022-08-10 12:47:30 +0200
commit97a75485fa125b37c27ffd53ac1c4fbc875a7b40 (patch)
tree1a5ed16cbf80ac2d2ca21ad713883d4b2e185347
parent091ce4c72c123f43f317c097818ace15f3a085fa (diff)
downloadOneConfig-97a75485fa125b37c27ffd53ac1c4fbc875a7b40.tar.gz
OneConfig-97a75485fa125b37c27ffd53ac1c4fbc875a7b40.tar.bz2
OneConfig-97a75485fa125b37c27ffd53ac1c4fbc875a7b40.zip
Profile fix (#89)
* e * omg finish profile shit * api and fix 1.12.2 preprocess * fix class names * fix compat mode profile stuff * api
-rw-r--r--api/OneConfig.api3
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/config/Config.java17
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/internal/config/compatibility/forge/ForgeCompat.java7
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/internal/config/compatibility/vigilance/VigilanceConfig.java5
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/internal/config/core/ConfigCore.java4
5 files changed, 27 insertions, 9 deletions
diff --git a/api/OneConfig.api b/api/OneConfig.api
index c904fe9..51fc6fd 100644
--- a/api/OneConfig.api
+++ b/api/OneConfig.api
@@ -3,7 +3,6 @@ public class cc/polyfrost/oneconfig/config/Config {
protected final field defaults Ljava/util/HashMap;
public field enabled Z
protected final field gson Lcom/google/gson/Gson;
- public field hasBeenInitialized Z
public field mod Lcc/polyfrost/oneconfig/config/data/Mod;
protected final field nonProfileSpecificGson Lcom/google/gson/Gson;
public final field optionNames Ljava/util/HashMap;
@@ -23,9 +22,11 @@ public class cc/polyfrost/oneconfig/config/Config {
public fun initialize ()V
public fun load ()V
public fun openGui ()V
+ public fun reInitialize ()V
protected fun registerKeyBind (Lcc/polyfrost/oneconfig/config/core/OneKeyBind;Ljava/lang/Runnable;)V
public fun reset ()V
public fun save ()V
+ public fun supportsProfiles ()Z
}
public abstract interface annotation class cc/polyfrost/oneconfig/config/annotations/Button : java/lang/annotation/Annotation {
diff --git a/src/main/java/cc/polyfrost/oneconfig/config/Config.java b/src/main/java/cc/polyfrost/oneconfig/config/Config.java
index 0f74b31..7c3b7ed 100644
--- a/src/main/java/cc/polyfrost/oneconfig/config/Config.java
+++ b/src/main/java/cc/polyfrost/oneconfig/config/Config.java
@@ -68,7 +68,6 @@ public class Config {
transient protected final Gson nonProfileSpecificGson = new GsonBuilder().setExclusionStrategies(new NonProfileSpecificExclusionStrategy()).excludeFieldsWithModifiers(Modifier.TRANSIENT).setPrettyPrinting().create();
transient protected final HashMap<Field, Object> defaults = new HashMap<>();
transient public Mod mod;
- public transient boolean hasBeenInitialized = false;
public boolean enabled;
/**
@@ -93,14 +92,17 @@ public class Config {
public void initialize() {
boolean migrate = false;
if (Profiles.getProfileFile(configFile).exists()) load();
- else if (!hasBeenInitialized && mod.migrator != null) migrate = true;
+ else if (mod.migrator != null) migrate = true;
else save();
- if (hasBeenInitialized) return;
mod.config = this;
generateOptionList(this, mod.defaultPage, mod, migrate);
if (migrate) save();
ConfigCore.mods.add(mod);
- hasBeenInitialized = true;
+ }
+
+ public void reInitialize() {
+ if (Profiles.getProfileFile(configFile).exists()) load();
+ else save();
}
/**
@@ -382,4 +384,11 @@ public class Config {
option.reset(this);
}
}
+
+ /**
+ * @return If this mod supports profiles, false for compatibility mode
+ */
+ public boolean supportsProfiles() {
+ return true;
+ }
}
diff --git a/src/main/java/cc/polyfrost/oneconfig/internal/config/compatibility/forge/ForgeCompat.java b/src/main/java/cc/polyfrost/oneconfig/internal/config/compatibility/forge/ForgeCompat.java
index afa5436..238355e 100644
--- a/src/main/java/cc/polyfrost/oneconfig/internal/config/compatibility/forge/ForgeCompat.java
+++ b/src/main/java/cc/polyfrost/oneconfig/internal/config/compatibility/forge/ForgeCompat.java
@@ -19,17 +19,14 @@ public class ForgeCompat {
config = new Config(this, "") {
@Override
public void initialize() {
-
}
@Override
public void save() {
-
}
@Override
public void load() {
-
}
@Override
@@ -44,7 +41,11 @@ public class ForgeCompat {
@Override
public void reset() {
+ }
+ @Override
+ public boolean supportsProfiles() {
+ return false;
}
};
}
diff --git a/src/main/java/cc/polyfrost/oneconfig/internal/config/compatibility/vigilance/VigilanceConfig.java b/src/main/java/cc/polyfrost/oneconfig/internal/config/compatibility/vigilance/VigilanceConfig.java
index 654001e..66375cc 100644
--- a/src/main/java/cc/polyfrost/oneconfig/internal/config/compatibility/vigilance/VigilanceConfig.java
+++ b/src/main/java/cc/polyfrost/oneconfig/internal/config/compatibility/vigilance/VigilanceConfig.java
@@ -217,4 +217,9 @@ public class VigilanceConfig extends Config {
}
}
}
+
+ @Override
+ public boolean supportsProfiles() {
+ return false;
+ }
}
diff --git a/src/main/java/cc/polyfrost/oneconfig/internal/config/core/ConfigCore.java b/src/main/java/cc/polyfrost/oneconfig/internal/config/core/ConfigCore.java
index ae58760..7925063 100644
--- a/src/main/java/cc/polyfrost/oneconfig/internal/config/core/ConfigCore.java
+++ b/src/main/java/cc/polyfrost/oneconfig/internal/config/core/ConfigCore.java
@@ -46,6 +46,7 @@ public class ConfigCore {
}
}, 30000, 30000);
}
+
public static List<Mod> mods = new ArrayList<>();
public static void saveAll() {
@@ -56,7 +57,8 @@ public class ConfigCore {
public static void reInitAll() {
for (Mod modData : mods) {
- modData.config.initialize();
+ if (!modData.config.supportsProfiles()) continue;
+ modData.config.reInitialize();
}
HudCore.reInitHuds();
KeyBindHandler.INSTANCE.reInitKeyBinds();