From 2ea888ecaa423819b84b5a0f604362a253dff71f Mon Sep 17 00:00:00 2001 From: Jane Petrovna Date: Tue, 22 Dec 2020 19:51:20 -0500 Subject: [PATCH] 0.1.6!!! --- gradle.properties | 2 +- src/main/java/pm/j4/kerosene/KeroseneMod.java | 28 +++++-- .../j4/kerosene/gui/PModuleConfigEntry.java | 39 ++++++---- .../pm/j4/kerosene/gui/POptionsScreen.java | 10 ++- .../j4/kerosene/mixin/OptionsMenuMixin.java | 5 +- .../pm/j4/kerosene/modules/ExampleModule.java | 27 +++++++ .../modules/bindings/BindingInfo.java | 2 + .../modules/bindings/BindingManager.java | 78 +++++++++---------- .../j4/kerosene/util/config/ConfigHolder.java | 5 +- .../kerosene/util/config/ConfigManager.java | 39 ++++++---- .../kerosene/util/config/DefaultConfig.java | 12 --- .../j4/kerosene/util/config/GlobalConfig.java | 25 +++--- .../j4/kerosene/util/module/ModuleBase.java | 28 ++++++- .../kerosene/util/module/ModuleFunction.java | 24 ++++++ .../util/module/option/KeybindOption.java | 7 +- .../resources/assets/kerosene/lang/en_us.json | 3 +- 16 files changed, 222 insertions(+), 112 deletions(-) delete mode 100644 src/main/java/pm/j4/kerosene/util/config/DefaultConfig.java create mode 100644 src/main/java/pm/j4/kerosene/util/module/ModuleFunction.java diff --git a/gradle.properties b/gradle.properties index 9830438..174653c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -8,7 +8,7 @@ org.gradle.jvmargs=-Xmx1G loader_version=0.10.8 # Mod Properties - mod_version = 0.1.6-SNAPSHOT + mod_version = 0.1.6 maven_group = pm.j4 archives_base_name = kerosene diff --git a/src/main/java/pm/j4/kerosene/KeroseneMod.java b/src/main/java/pm/j4/kerosene/KeroseneMod.java index c3eb1a0..f56a45b 100644 --- a/src/main/java/pm/j4/kerosene/KeroseneMod.java +++ b/src/main/java/pm/j4/kerosene/KeroseneMod.java @@ -1,5 +1,6 @@ package pm.j4.kerosene; +import java.util.Map; import java.util.Optional; import net.fabricmc.api.ModInitializer; import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents; @@ -11,6 +12,7 @@ import pm.j4.kerosene.util.config.ConfigManager; import pm.j4.kerosene.util.config.Module; import pm.j4.kerosene.util.data.ModInfoProvider; import pm.j4.kerosene.util.module.ModuleBase; +import pm.j4.kerosene.util.module.ModuleFunction; /** @@ -32,15 +34,29 @@ public class KeroseneMod implements ModInitializer { ModInfoProvider.getRegisteredMods().forEach(ModuleBase::init); //initialize keybind handler - conf.ifPresent(configHolder -> ClientTickEvents.END_CLIENT_TICK.register(client -> { + ClientTickEvents.END_CLIENT_TICK.register(client -> { if (ModInfoProvider.client != client) { ModInfoProvider.client = client; } - for (KeyBinding b : BindingManager.getActiveKeybinds()) { - while (b.wasPressed()) { - configHolder.globalConfig.bindings.get(b).activate(client); + Map binds = BindingManager.getActiveKeybinds(); + binds.forEach((bind, func) -> { + while (bind.wasPressed()) { + Optional config = ConfigManager.getConfig(func.getParent().getParent()); + config.ifPresent(configHolder -> { + Map bindings = configHolder.globalConfig.bindings; + if (bindings.containsKey(bind)) { + bindings.get(bind).activate(client); + } + else { + System.out.println("binding function no longer present"); + BindingManager.removeBind(bind); + } + }); } - } - })); + }); + }); + + //save any defaults that have been set + ConfigManager.saveEverything(); } } diff --git a/src/main/java/pm/j4/kerosene/gui/PModuleConfigEntry.java b/src/main/java/pm/j4/kerosene/gui/PModuleConfigEntry.java index e18de7d..632ca8d 100644 --- a/src/main/java/pm/j4/kerosene/gui/PModuleConfigEntry.java +++ b/src/main/java/pm/j4/kerosene/gui/PModuleConfigEntry.java @@ -14,6 +14,7 @@ import net.minecraft.text.LiteralText; import net.minecraft.text.Text; import pm.j4.kerosene.util.config.ConfigHolder; import pm.j4.kerosene.util.config.ConfigManager; +import pm.j4.kerosene.util.module.ModuleFunction; import pm.j4.kerosene.util.module.option.BooleanOption; import pm.j4.kerosene.util.module.option.ConfigurationOption; import pm.j4.kerosene.util.module.option.KeybindOption; @@ -136,7 +137,6 @@ public class PModuleConfigEntry extends ElementListWidget.Entry config = ConfigManager.getConfig(option.getParent().getParent()); - assert config.isPresent(); - config.get().globalConfig.setBinding(bind, option.getParent()); - option = newValue; - this.setMessage(new LiteralText(option.getStringValue().toUpperCase())); - selected = null; - return false; + System.out.println("looking for binds in " + + option.getParent().getModuleName() + + " that match the name " + + ((KeybindOption)option).getBindingInfo().attachedFunctionName); + List foundBinds = option.getParent().matchBinding(((KeybindOption)option).getBindingInfo().attachedFunctionName); + if (foundBinds.size() > 0) { + newValue.fromKeybind(bind, foundBinds.get(0)); + Optional config = ConfigManager.getConfig(option.getParent().getParent()); + if (config.isPresent()) { + config.get().globalConfig.setBinding(bind, foundBinds.get(0)); + option = newValue; + this.setMessage(new LiteralText(option.getStringValue().toUpperCase())); + } + selected = null; + return false; + } + else { + System.out.println("no binds found to set!"); + selected = null; + return true; + } } else { this.playDownSound(MinecraftClient.getInstance().getSoundManager()); this.onPress(); @@ -201,7 +210,7 @@ public class PModuleConfigEntry extends ElementListWidget.Entry this.modules.addEntry(new POptionEntry(module, this.modules))); this.addButton(new ButtonWidget(this.width / 2 - 75, this.height - 30, 150, 20, ScreenTexts.DONE, (buttonWidget) -> { ConfigManager.saveEverything(); - assert this.client != null; - this.client.openScreen(this.previousScreen); + if (this.client != null) { + this.client.openScreen(this.previousScreen); + } })); } diff --git a/src/main/java/pm/j4/kerosene/mixin/OptionsMenuMixin.java b/src/main/java/pm/j4/kerosene/mixin/OptionsMenuMixin.java index 3791680..21b8db6 100644 --- a/src/main/java/pm/j4/kerosene/mixin/OptionsMenuMixin.java +++ b/src/main/java/pm/j4/kerosene/mixin/OptionsMenuMixin.java @@ -35,8 +35,9 @@ public class OptionsMenuMixin extends Screen { method = "init()V") protected void init(CallbackInfo ci) { this.addButton(new ButtonWidget(this.width / 2 - 75, this.height / 6 + 140, 150, 20, new TranslatableText("kerosene.options"), (buttonWidget) -> { - assert this.client != null; - this.client.openScreen(new POptionsScreen(this)); + if (this.client != null) { + this.client.openScreen(new POptionsScreen(this)); + } })); } } diff --git a/src/main/java/pm/j4/kerosene/modules/ExampleModule.java b/src/main/java/pm/j4/kerosene/modules/ExampleModule.java index 21d4cb9..3cf3fdc 100644 --- a/src/main/java/pm/j4/kerosene/modules/ExampleModule.java +++ b/src/main/java/pm/j4/kerosene/modules/ExampleModule.java @@ -1,9 +1,15 @@ package pm.j4.kerosene.modules; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; import net.minecraft.client.MinecraftClient; +import net.minecraft.client.options.KeyBinding; +import net.minecraft.client.util.InputUtil; +import org.lwjgl.glfw.GLFW; import pm.j4.kerosene.util.module.ModuleBase; +import pm.j4.kerosene.util.module.ModuleFunction; import pm.j4.kerosene.util.module.option.BooleanOption; import pm.j4.kerosene.util.module.option.ConfigurationOption; @@ -31,6 +37,27 @@ public class ExampleModule extends ModuleBase { return options; } + @Override + public Map getDefaultBindings() { + Map binds = new HashMap<>(); + + KeyBinding openMenu = new KeyBinding( + "key.kerosene.example", + InputUtil.Type.KEYSYM, + GLFW.GLFW_KEY_P, + "category.kerosene" + ); + ModuleFunction exampleFunc = new ModuleFunction("kerosene.example.test", this) { + @Override + public void activate(MinecraftClient client) { + System.out.println("example function activated"); + } + }; + binds.put(openMenu, exampleFunc); + + return binds; + } + @Override public void activate(MinecraftClient client) { System.out.println("Example Mod Keybind Activate"); diff --git a/src/main/java/pm/j4/kerosene/modules/bindings/BindingInfo.java b/src/main/java/pm/j4/kerosene/modules/bindings/BindingInfo.java index 9d0e9f6..bdc3fab 100644 --- a/src/main/java/pm/j4/kerosene/modules/bindings/BindingInfo.java +++ b/src/main/java/pm/j4/kerosene/modules/bindings/BindingInfo.java @@ -27,4 +27,6 @@ public class BindingInfo { * The Attached function id. */ public String attachedModuleName; + + public String attachedFunctionName; } diff --git a/src/main/java/pm/j4/kerosene/modules/bindings/BindingManager.java b/src/main/java/pm/j4/kerosene/modules/bindings/BindingManager.java index bab431f..3c8ae3b 100644 --- a/src/main/java/pm/j4/kerosene/modules/bindings/BindingManager.java +++ b/src/main/java/pm/j4/kerosene/modules/bindings/BindingManager.java @@ -2,16 +2,13 @@ package pm.j4.kerosene.modules.bindings; import java.util.*; import net.minecraft.client.options.KeyBinding; -import net.minecraft.client.util.InputUtil; import net.minecraft.text.TranslatableText; -import org.lwjgl.glfw.GLFW; import pm.j4.kerosene.gui.PModuleConfigEntry; import pm.j4.kerosene.gui.PModuleConfigPane; import pm.j4.kerosene.util.config.ConfigHolder; import pm.j4.kerosene.util.config.ConfigManager; -import pm.j4.kerosene.util.config.GlobalConfig; -import pm.j4.kerosene.util.data.ModInfoProvider; import pm.j4.kerosene.util.module.ModuleBase; +import pm.j4.kerosene.util.module.ModuleFunction; import pm.j4.kerosene.util.module.option.KeybindOption; /** @@ -33,7 +30,6 @@ public class BindingManager extends ModuleBase { @Override public void init() { - registerBindings(); super.init(); } @@ -45,18 +41,21 @@ public class BindingManager extends ModuleBase { // which replace the ModuleBase in bindings? List entries = new ArrayList<>(); - Map mapped = new HashMap<>(); - Optional config = ConfigManager.getConfig(this.getParent()); - if (config.isPresent()) { - Map binds = config.get().globalConfig.bindings; - - binds.forEach((key, func) -> { - KeybindOption option = new KeybindOption(func.getModuleName() + " " + func.getCategory(), func.getModuleName() + " " + func.getCategory(), func); - option.fromKeybind(key, func); - mapped.put(option, func); - }); - } - mapped.forEach((configEntry, module) -> { + Map mapped = new HashMap<>(); + Map configs = ConfigManager.getAllConfigs(); + configs.forEach((modName, config) -> { + if (config.globalConfig != null) { + Map binds = config.globalConfig.bindings; + binds.forEach((key, func) -> { + ModuleBase parent = func.getParent(); + KeybindOption option = new KeybindOption(parent.getModuleName() + " " + parent.getCategory(), parent.getModuleName() + " " + parent.getCategory(), parent); + option.fromKeybind(key, func); + mapped.put(option, func); + }); + } + }); + mapped.forEach((configEntry, func) -> { + ModuleBase module = func.getParent(); PModuleConfigEntry entry = new PModuleConfigEntry(configEntry, new TranslatableText(module.getModuleName()), sourcePane); entries.add(entry); }); @@ -66,40 +65,35 @@ public class BindingManager extends ModuleBase { /** * Register bindings. */ - private void registerBindings() { - Optional config = ConfigManager.getConfig(this.getParent()); - if (!config.isPresent()) { - return; - } - GlobalConfig c = config.get().globalConfig; - Optional mod = ModInfoProvider.getMod("petroleum.modmenu"); - if (mod.isPresent() && !c.isBound(mod.get())) { - //TODO - // the only explicit keybinding (for now.) - // once the binding manager has been completed, - // this should be migrated there, as a default binding - KeyBinding binding = new KeyBinding( - "key.petroleum.togglemodmenu", - InputUtil.Type.KEYSYM, - GLFW.GLFW_KEY_RIGHT_CONTROL, - "category.petroleum" - ); - config.get().globalConfig.setBinding(binding, mod.get()); - } + public static void registerBindings(ModuleBase module) { + System.out.println("registering bindings for " + module.getModuleName()); + Optional config = ConfigManager.getConfig(module.getParent()); + Map defaults = module.getDefaultBindings(); + config.ifPresent((holder) -> { + System.out.println("config present"); + defaults.forEach((bind, func) -> { + System.out.println("default value:" + bind.getTranslationKey() + " bound to " + func.getFunctionName()); + if(!holder.globalConfig.isBound(func)) { + System.out.println("no value set, using default"); + holder.globalConfig.setBinding(bind, func); + } + }); + }); } /** * The constant registeredBinds. */ - private static final List registeredBinds = new ArrayList<>(); + private static final Map registeredBinds = new HashMap<>(); /** * Add bind. * - * @param b the b + * @param bind the bind + * @param function the function */ - public static void addBind(KeyBinding b) { - registeredBinds.add(b); + public static void addBind(KeyBinding bind, ModuleFunction function) { + registeredBinds.put(bind, function); } /** @@ -116,7 +110,7 @@ public class BindingManager extends ModuleBase { * * @return the active keybinds */ - public static List getActiveKeybinds() { + public static Map getActiveKeybinds() { return registeredBinds; } } diff --git a/src/main/java/pm/j4/kerosene/util/config/ConfigHolder.java b/src/main/java/pm/j4/kerosene/util/config/ConfigHolder.java index 0244ac6..aa4db48 100644 --- a/src/main/java/pm/j4/kerosene/util/config/ConfigHolder.java +++ b/src/main/java/pm/j4/kerosene/util/config/ConfigHolder.java @@ -1,5 +1,6 @@ package pm.j4.kerosene.util.config; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.stream.Collectors; @@ -13,11 +14,11 @@ public class ConfigHolder { /** * The Global config. */ - public GlobalConfig globalConfig; + public GlobalConfig globalConfig = new GlobalConfig(); /** * The Server configs. */ - public Map serverConfigs; + public Map serverConfigs = new HashMap<>(); /** * Is module enabled boolean. diff --git a/src/main/java/pm/j4/kerosene/util/config/ConfigManager.java b/src/main/java/pm/j4/kerosene/util/config/ConfigManager.java index b668035..703f229 100644 --- a/src/main/java/pm/j4/kerosene/util/config/ConfigManager.java +++ b/src/main/java/pm/j4/kerosene/util/config/ConfigManager.java @@ -4,14 +4,10 @@ import com.google.common.reflect.TypeToken; import com.google.gson.*; import java.io.*; import java.lang.annotation.Annotation; -import java.lang.reflect.AnnotatedElement; import java.lang.reflect.Type; import java.util.*; -import net.fabricmc.api.ModInitializer; import net.fabricmc.loader.api.FabricLoader; -import pm.j4.kerosene.modules.ExampleModule; import pm.j4.kerosene.modules.bindings.BindingInfo; -import pm.j4.kerosene.modules.bindings.BindingManager; import pm.j4.kerosene.util.data.ModInfoProvider; import pm.j4.kerosene.util.data.ModuleConfig; import pm.j4.kerosene.util.data.OptionSerializiable; @@ -57,12 +53,13 @@ public class ConfigManager { public static void initConfig(String moduleName, Class parent) { try { Annotation moduleAnnotation = parent.getAnnotation(Modules.class); - assert moduleAnnotation != null; - Module[] modules = ((Modules)moduleAnnotation).value(); - System.out.println(modules); - for (int i = 0; i < modules.length; i++) { - System.out.println(modules[i].value()); - ModInfoProvider.registerMod(modules[i].value()); + if (moduleAnnotation != null) { + Module[] modules = ((Modules)moduleAnnotation).value(); + System.out.println(modules); + for (int i = 0; i < modules.length; i++) { + System.out.println(modules[i].value()); + ModInfoProvider.registerMod(modules[i].value()); + } } } catch (Exception e) { @@ -75,7 +72,7 @@ public class ConfigManager { } ConfigHolder config = new ConfigHolder(); - config.globalConfig = new DefaultConfig(); + config.globalConfig = new GlobalConfig(); config.serverConfigs = new HashMap<>(); System.out.println("load cfg"); @@ -97,10 +94,12 @@ public class ConfigManager { System.out.println("initialize " + module.getModuleName()); if (options != null && options.options != null) { options.options.forEach((key, option) -> { - if (module.hasOption(option.key)) { - System.out.println("setting " + option.key + " to " + option.value.getAsString()); + if (module.hasOption(option.key) && option.value != null) { module.setConfigOption(option.key, option.value); } + else { + System.out.println("ignoring unknown option " + option.key); + } }); } module.initialized = true; @@ -149,11 +148,15 @@ public class ConfigManager { * * @param the type parameter * @param element the element - * @param tClass the t class + * @param valueClass the t class * @return the t */ - public static T deserializeElement(JsonElement element, Class tClass) { - return GSON.fromJson(element, tClass); + public static T deserializeElement(JsonElement element, Class valueClass) { + return GSON.fromJson(element, valueClass); + } + + public static JsonElement serializeElement(T value) { + return GSON.toJsonTree(value); } /** @@ -226,6 +229,10 @@ public class ConfigManager { } return Optional.empty(); } + + public static Map getAllConfigs() { + return configs; + } } /** diff --git a/src/main/java/pm/j4/kerosene/util/config/DefaultConfig.java b/src/main/java/pm/j4/kerosene/util/config/DefaultConfig.java deleted file mode 100644 index c7a2568..0000000 --- a/src/main/java/pm/j4/kerosene/util/config/DefaultConfig.java +++ /dev/null @@ -1,12 +0,0 @@ -package pm.j4.kerosene.util.config; - -/** - * The type Default config. - */ -public class DefaultConfig extends GlobalConfig { - /** - * Instantiates a new Default config. - */ - public DefaultConfig() { - } -} diff --git a/src/main/java/pm/j4/kerosene/util/config/GlobalConfig.java b/src/main/java/pm/j4/kerosene/util/config/GlobalConfig.java index c6af9ae..9fc1728 100644 --- a/src/main/java/pm/j4/kerosene/util/config/GlobalConfig.java +++ b/src/main/java/pm/j4/kerosene/util/config/GlobalConfig.java @@ -10,6 +10,7 @@ import pm.j4.kerosene.modules.bindings.BindingManager; import pm.j4.kerosene.util.data.ModInfoProvider; import pm.j4.kerosene.util.data.OptionSerializiable; import pm.j4.kerosene.util.module.ModuleBase; +import pm.j4.kerosene.util.module.ModuleFunction; import pm.j4.kerosene.util.module.option.ConfigurationOption; /** @@ -19,7 +20,7 @@ public class GlobalConfig extends Config { /** * The Bindings. */ - public final Map bindings = new HashMap<>(); + public final Map bindings = new HashMap<>(); /** * Is bound boolean. @@ -27,7 +28,7 @@ public class GlobalConfig extends Config { * @param func the func * @return the boolean */ - public boolean isBound(ModuleBase func) { + public boolean isBound(ModuleFunction func) { AtomicBoolean found = new AtomicBoolean(false); bindings.forEach((key, binding) -> { if (binding.equals(func)) { @@ -43,7 +44,7 @@ public class GlobalConfig extends Config { * @param bind the bind * @param func the func */ - public void setBinding(KeyBinding bind, ModuleBase func) { + public void setBinding(KeyBinding bind, ModuleFunction func) { AtomicReference match = new AtomicReference<>(); if (bindings.containsValue(func)) { bindings.forEach((key, binding) -> { @@ -58,8 +59,9 @@ public class GlobalConfig extends Config { bindings.remove(match.get()); } - if (ModInfoProvider.isActive(func.getModuleName())) { - BindingManager.addBind(bind); + if (ModInfoProvider.isActive(func.getParent().getModuleName())) { + BindingManager.addBind(bind, func); + func.getParent().setBinding(bind, func); bindings.put(bind, func); } } @@ -71,8 +73,12 @@ public class GlobalConfig extends Config { */ private void convertBinding(BindingInfo info) { Optional match = ModInfoProvider.getMod(info.attachedModuleName); - match.ifPresent(moduleBase -> setBinding(reconstructBinding(info), - moduleBase)); + match.ifPresent(moduleBase -> { + List foundBinds = moduleBase.matchBinding(info.attachedFunctionName); + if (foundBinds.size() > 0) { + setBinding(reconstructBinding(info), foundBinds.get(0)); + } + }); } /** @@ -97,9 +103,10 @@ public class GlobalConfig extends Config { * @param f the f * @return the binding info */ - public static BindingInfo extractBinding(KeyBinding b, ModuleBase f) { + public static BindingInfo extractBinding(KeyBinding b, ModuleFunction f) { BindingInfo res = new BindingInfo(); - res.attachedModuleName = f.getModuleName(); + res.attachedModuleName = f.getParent().getModuleName(); + res.attachedFunctionName = f.getFunctionName(); res.translationKey = b.getTranslationKey(); InputUtil.Key k = b.getDefaultKey(); diff --git a/src/main/java/pm/j4/kerosene/util/module/ModuleBase.java b/src/main/java/pm/j4/kerosene/util/module/ModuleBase.java index b779d5b..63cd829 100644 --- a/src/main/java/pm/j4/kerosene/util/module/ModuleBase.java +++ b/src/main/java/pm/j4/kerosene/util/module/ModuleBase.java @@ -2,10 +2,13 @@ package pm.j4.kerosene.util.module; import com.google.gson.JsonElement; import java.util.*; +import java.util.stream.Collectors; import net.minecraft.client.MinecraftClient; +import net.minecraft.client.options.KeyBinding; import net.minecraft.text.TranslatableText; import pm.j4.kerosene.gui.PModuleConfigEntry; import pm.j4.kerosene.gui.PModuleConfigPane; +import pm.j4.kerosene.modules.bindings.BindingManager; import pm.j4.kerosene.util.config.ConfigHolder; import pm.j4.kerosene.util.config.ConfigManager; import pm.j4.kerosene.util.module.option.ConfigurationOption; @@ -41,7 +44,7 @@ public abstract class ModuleBase { * Init. */ public void init() { - + BindingManager.registerBindings(this); } /** @@ -250,6 +253,29 @@ public abstract class ModuleBase { return Optional.empty(); } + private Map attachedBinds = new HashMap<>(); + + public Map getDefaultBindings() { + return new HashMap<>(); + } + + public List matchBinding(String name) { + List result = attachedBinds.entrySet().stream() + .filter(entry -> entry.getValue().getFunctionName().equals(name)) + .map(entry -> entry.getValue()) + .collect(Collectors.toList()); + return result; + } + + public void setBinding(KeyBinding bind, ModuleFunction function) { + if (attachedBinds.containsKey(bind)) { + attachedBinds.replace(bind, function); + } + else { + attachedBinds.put(bind, function); + } + } + /** * Gets config entries. * diff --git a/src/main/java/pm/j4/kerosene/util/module/ModuleFunction.java b/src/main/java/pm/j4/kerosene/util/module/ModuleFunction.java new file mode 100644 index 0000000..9bfb362 --- /dev/null +++ b/src/main/java/pm/j4/kerosene/util/module/ModuleFunction.java @@ -0,0 +1,24 @@ +package pm.j4.kerosene.util.module; + +import net.minecraft.client.MinecraftClient; + +public class ModuleFunction { + public ModuleFunction(String name, ModuleBase parent) { + this.name = name; + this.parent = parent; + } + private final ModuleBase parent; + private final String name; + + public ModuleBase getParent() { + return parent; + } + + public String getFunctionName() { + return name; + } + + public void activate(MinecraftClient client) { + this.parent.activate(client); + } +} diff --git a/src/main/java/pm/j4/kerosene/util/module/option/KeybindOption.java b/src/main/java/pm/j4/kerosene/util/module/option/KeybindOption.java index 43705b2..a3a8f53 100644 --- a/src/main/java/pm/j4/kerosene/util/module/option/KeybindOption.java +++ b/src/main/java/pm/j4/kerosene/util/module/option/KeybindOption.java @@ -6,6 +6,7 @@ import pm.j4.kerosene.modules.bindings.BindingInfo; import pm.j4.kerosene.util.config.ConfigManager; import pm.j4.kerosene.util.config.GlobalConfig; import pm.j4.kerosene.util.module.ModuleBase; +import pm.j4.kerosene.util.module.ModuleFunction; /** * The type Keybind value. @@ -46,6 +47,10 @@ public class KeybindOption extends ConfigurationOption { return value.getDefaultKey().getLocalizedText().getString(); } + public BindingInfo getBindingInfo() { + return convertedValue; + } + @Override public void fromJson(JsonElement e) { BindingInfo bindingInfo = ConfigManager.deserializeElement(e, BindingInfo.class); @@ -64,7 +69,7 @@ public class KeybindOption extends ConfigurationOption { * @param bind the bind * @param base the base */ - public void fromKeybind(KeyBinding bind, ModuleBase base) { + public void fromKeybind(KeyBinding bind, ModuleFunction base) { this.value = bind; this.convertedValue = GlobalConfig.extractBinding(bind, base); } diff --git a/src/main/resources/assets/kerosene/lang/en_us.json b/src/main/resources/assets/kerosene/lang/en_us.json index 07f67a8..a7422a6 100644 --- a/src/main/resources/assets/kerosene/lang/en_us.json +++ b/src/main/resources/assets/kerosene/lang/en_us.json @@ -1,4 +1,5 @@ { "kerosene.bindings": "Binding Manager", - "kerosene.options": "Kerosene Options" + "kerosene.options": "Kerosene Options", + "kerosene.example": "Example Module" } \ No newline at end of file