diff options
Diffstat (limited to 'src/main/java/cc')
-rw-r--r-- | src/main/java/cc/polyfrost/oneconfig/config/core/OneKeyBind.java | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/main/java/cc/polyfrost/oneconfig/config/core/OneKeyBind.java b/src/main/java/cc/polyfrost/oneconfig/config/core/OneKeyBind.java index 3d3bd4b..64e95e8 100644 --- a/src/main/java/cc/polyfrost/oneconfig/config/core/OneKeyBind.java +++ b/src/main/java/cc/polyfrost/oneconfig/config/core/OneKeyBind.java @@ -35,11 +35,18 @@ public class OneKeyBind { protected transient Runnable runnable; protected transient boolean hasRun; + /** + * @param keys The bound keys + */ public OneKeyBind(int... keys) { for (int key : keys) { keyBinds.add(key); } } + + /** + * @return If the keys are pressed + */ public boolean isActive() { if (keyBinds.size() == 0) return false; for (int keyBind : keyBinds) { @@ -51,12 +58,18 @@ public class OneKeyBind { return true; } + /** + * Run the set Runnable + */ public void run() { if (runnable == null || hasRun) return; runnable.run(); hasRun = true; } + /** + * @return The set keys as the name of the keys + */ public String getDisplay() { StringBuilder sb = new StringBuilder(); for (int keyBind : keyBinds) { @@ -66,19 +79,39 @@ public class OneKeyBind { return sb.toString().trim(); } + /** + * @param key Add a Key to keys + */ public void addKey(int key) { if (!keyBinds.contains(key)) keyBinds.add(key); } + /** + * Clear the keys List + */ public void clearKeys() { keyBinds.clear(); } + /** + * @return The amount of key in the keys List + */ public int getSize() { return keyBinds.size(); } + /** + * Set the Runnable that gets ran when OneKeyBind#run() is called + * @param runnable The Runnable to run + */ public void setRunnable(Runnable runnable) { this.runnable = runnable; } + + /** + * @return The key in the keys List + */ + public ArrayList<Integer> getKeyBinds() { + return keyBinds; + } } |