aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/cc/polyfrost/oneconfig/internal/hud
diff options
context:
space:
mode:
authorDeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com>2022-08-10 10:15:01 +0200
committerGitHub <noreply@github.com>2022-08-10 17:15:01 +0900
commit091ce4c72c123f43f317c097818ace15f3a085fa (patch)
tree9a151e29494ef2683b2bff59fec19b56d4a05fb0 /src/main/java/cc/polyfrost/oneconfig/internal/hud
parent799c389fdb993e363d71d268e0df9ae9f0a0c8a1 (diff)
downloadOneConfig-091ce4c72c123f43f317c097818ace15f3a085fa.tar.gz
OneConfig-091ce4c72c123f43f317c097818ace15f3a085fa.tar.bz2
OneConfig-091ce4c72c123f43f317c097818ace15f3a085fa.zip
Profile command (#88)
* e * omg finish profile shit * api and fix 1.12.2 preprocess * fix class names
Diffstat (limited to 'src/main/java/cc/polyfrost/oneconfig/internal/hud')
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/internal/hud/HudCore.java27
1 files changed, 24 insertions, 3 deletions
diff --git a/src/main/java/cc/polyfrost/oneconfig/internal/hud/HudCore.java b/src/main/java/cc/polyfrost/oneconfig/internal/hud/HudCore.java
index 5a392e4..d78df55 100644
--- a/src/main/java/cc/polyfrost/oneconfig/internal/hud/HudCore.java
+++ b/src/main/java/cc/polyfrost/oneconfig/internal/hud/HudCore.java
@@ -26,23 +26,44 @@
package cc.polyfrost.oneconfig.internal.hud;
+import cc.polyfrost.oneconfig.config.elements.BasicOption;
import cc.polyfrost.oneconfig.events.event.HudRenderEvent;
import cc.polyfrost.oneconfig.hud.Hud;
import cc.polyfrost.oneconfig.libs.eventbus.Subscribe;
-import cc.polyfrost.oneconfig.libs.universal.UResolution;
+import java.lang.reflect.Field;
import java.util.ArrayList;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
public class HudCore {
- public static ArrayList<Hud> huds = new ArrayList<>();
+ public static final ConcurrentHashMap<Map.Entry<Field, Object>, Hud> huds = new ConcurrentHashMap<>();
+ public static final ArrayList<BasicOption> hudOptions = new ArrayList<>();
public static boolean editing = false;
@Subscribe
public void onRender(HudRenderEvent event) {
if (editing) return;
- for (Hud hud : huds) {
+ for (Hud hud : huds.values()) {
if (!hud.isEnabled()) continue;
hud.drawAll(event.matrices, false);
}
}
+
+ public static void reInitHuds() {
+ for (Map.Entry<Field, Object> field : huds.keySet()) {
+ try {
+ field.getKey().setAccessible(true);
+ Hud oldHud = huds.get(field);
+ Hud newHud = (Hud) field.getKey().get(field.getValue());
+ for (BasicOption option : hudOptions) {
+ if (option.getParent().equals(oldHud)) {
+ option.setParent(newHud);
+ }
+ }
+ huds.put(field, newHud);
+ } catch (IllegalAccessException ignored) {
+ }
+ }
+ }
}