aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/cc/polyfrost/oneconfig/config/Config.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/cc/polyfrost/oneconfig/config/Config.java')
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/config/Config.java13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/main/java/cc/polyfrost/oneconfig/config/Config.java b/src/main/java/cc/polyfrost/oneconfig/config/Config.java
index 62609d4..d4b6022 100644
--- a/src/main/java/cc/polyfrost/oneconfig/config/Config.java
+++ b/src/main/java/cc/polyfrost/oneconfig/config/Config.java
@@ -4,6 +4,7 @@ import cc.polyfrost.oneconfig.config.annotations.CustomOption;
import cc.polyfrost.oneconfig.config.annotations.HUD;
import cc.polyfrost.oneconfig.config.annotations.Page;
import cc.polyfrost.oneconfig.config.core.ConfigUtils;
+import cc.polyfrost.oneconfig.config.core.OneKeyBind;
import cc.polyfrost.oneconfig.config.data.Mod;
import cc.polyfrost.oneconfig.config.data.PageLocation;
import cc.polyfrost.oneconfig.config.elements.BasicOption;
@@ -16,6 +17,7 @@ import cc.polyfrost.oneconfig.gui.pages.ModConfigPage;
import cc.polyfrost.oneconfig.hud.HUDUtils;
import cc.polyfrost.oneconfig.internal.config.annotations.Option;
import cc.polyfrost.oneconfig.internal.config.core.ConfigCore;
+import cc.polyfrost.oneconfig.internal.config.core.KeyBindHandler;
import cc.polyfrost.oneconfig.utils.gui.GuiUtils;
import com.google.gson.*;
@@ -215,4 +217,15 @@ public class Config {
if (!optionNames.containsKey(option)) return;
optionNames.get(option).addListener(runnable);
}
+
+ /**
+ * Register an action to a keybind
+ *
+ * @param keyBind The keybind
+ * @param runnable The code to be executed
+ */
+ protected void registerKeyBind(OneKeyBind keyBind, Runnable runnable) {
+ keyBind.setRunnable(runnable);
+ KeyBindHandler.INSTANCE.addKeyBind(keyBind);
+ }
}