Skip to content

Commit

Permalink
Updated NotEnoughKeys API
Browse files Browse the repository at this point in the history
  • Loading branch information
TGNThump committed Sep 10, 2015
1 parent 097748e commit 459e3d6
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
7 changes: 4 additions & 3 deletions src/api/java/modwarriors/notenoughkeys/api/Api.java
Expand Up @@ -25,13 +25,14 @@ public static boolean isLoaded() {
* Registers a mod's keys with NEK
*
* @param modname The NAME of the mod registering the key
* @param keyDecriptions A String[] (Array[String]) of the key descriptions. i.e. new String[]{"key.hotbar1"}
* @param keyDescriptions A String[] (Array[String]) of the key descriptions
* as an inherit array. i.e. ("modName", "key.hotbar1", "key.hotbar2")
*/
public static void registerMod(String modname, String[] keyDecriptions) {
public static void registerMod(String modname, String... keyDescriptions) {
try {
Class.forName("modwarriors.notenoughkeys.keys.KeyHelper").getMethod(
"registerMod", String.class, String[].class
).invoke(null, modname, keyDecriptions);
).invoke(null, modname, keyDescriptions);
} catch (Exception e) {
e.printStackTrace();
}
Expand Down
Expand Up @@ -23,6 +23,12 @@ public class KeyBindingPressedEvent extends Event {
* Tells whether a modifier was required AND was down when triggered
*/
public boolean shiftRequired = false, ctrlRequired = false, altRequired = false;
/**
* Use this variable to check if your key is pressed. DO NOT check KeyBinding.getIsKeyPressed().
* That value will return only if the main key is pressed or not.
* @see modwarriors.notenoughkeys.keys.KeyEvents refreshBindings
*/
public boolean isKeyBindingPressed;

/**
* Called with the passed keyBinding and modifiers.
Expand All @@ -31,13 +37,13 @@ public class KeyBindingPressedEvent extends Event {
* @param keyBinding The KeyBinding being triggered. Stores the key's description and keycode
* @param modifiers The modifiers (SHIFT, CTRL, ALT) that determine when a compatible key is pressed
*/
public KeyBindingPressedEvent(KeyBinding keyBinding, boolean[] modifiers) {
public KeyBindingPressedEvent(KeyBinding keyBinding, boolean[] modifiers, boolean isPressed) {
super();
this.keyBinding = keyBinding;
this.shiftRequired = modifiers[0];
this.ctrlRequired = modifiers[1];
this.altRequired = modifiers[2];

this.isKeyBindingPressed = isPressed;
}

}
@@ -1,5 +1,5 @@

@API(owner = "Not Enough Keys", provides = "API_NEK",
apiVersion = "1.0.0") package modwarriors.notenoughkeys.api;
apiVersion = "1.1.0") package modwarriors.notenoughkeys.api;

import cpw.mods.fml.common.API;
2 changes: 1 addition & 1 deletion src/main/java/tconstruct/client/ArmorControls.java
Expand Up @@ -98,7 +98,7 @@ public void keyEvent(KeyInputEvent event) {
@Optional.Method(modid = "notenoughkeys")
@SubscribeEvent
public void keyEventSpecial(KeyBindingPressedEvent event) {
this.sendPress(event.keyBinding, event.keyBinding.isPressed());
this.sendPress(event.keyBinding, event.isKeyBindingPressed);
}

private void checkKeys(int keycode) {
Expand Down

0 comments on commit 459e3d6

Please sign in to comment.