diff --git a/src/main/java/noppes/npcs/client/key/KeyPreset.java b/src/main/java/noppes/npcs/client/key/KeyPreset.java index 8c21d86c5..6f433c9aa 100644 --- a/src/main/java/noppes/npcs/client/key/KeyPreset.java +++ b/src/main/java/noppes/npcs/client/key/KeyPreset.java @@ -8,7 +8,7 @@ import org.lwjgl.input.Mouse; import java.util.function.Consumer; -public class KeyPreset implements Comparable { +public class KeyPreset { /** * @field SINGLE_PRESS => on releasing before 5 ticks press time * @field PRESS_RELEASE => on pressing and releasing @@ -58,8 +58,7 @@ public class KeyPreset implements Comparable { return; boolean isDown = isMouseKey() ? Mouse.isButtonDown(keyCode + 100) : Keyboard.isKeyDown(keyCode); - isDown = isDown && (hasCtrl() ? isCtrlKeyDown() : true) && (hasAlt() ? isAltKeyDown() : true) && (hasShift() ? isShiftKeyDown() : true); - + isDown = isDown && (isCtrlKeyDown() == hasCtrl()) && (isAltKeyDown() == hasAlt()) && (isShiftKeyDown() == hasShift()); setDown(isDown); } @@ -148,27 +147,6 @@ public class KeyPreset implements Comparable { return false; } - @Override - public int compareTo(KeyPreset o) { - int mySpecialCount = getSpecialKeyCount(this); - int otherSpecialCount = getSpecialKeyCount(o); - - return otherSpecialCount - mySpecialCount; - } - - private static int getSpecialKeyCount(KeyPreset preset) { - int res = 0; - if (preset.hasAlt()) - res += 1; - if (preset.hasCtrl()) - res += 1; - if (preset.hasShift()) - res += 1; - - return res; - } - - public static class KeyState { public int keyCode = -1; public boolean hasCtrl, hasAlt, hasShift; diff --git a/src/main/java/noppes/npcs/client/key/KeyPresetManager.java b/src/main/java/noppes/npcs/client/key/KeyPresetManager.java index 8d25c43ac..6f973e2b5 100644 --- a/src/main/java/noppes/npcs/client/key/KeyPresetManager.java +++ b/src/main/java/noppes/npcs/client/key/KeyPresetManager.java @@ -11,10 +11,8 @@ import java.util.List; public class KeyPresetManager { public List keys = new ArrayList<>(); - public List keysSorted = new ArrayList<>(); public String fileName; - private boolean wasSorted = false; public KeyPresetManager(String fileName) { this.fileName = fileName; @@ -23,22 +21,12 @@ public class KeyPresetManager { public KeyPreset add(String name) { KeyPreset preset = new KeyPreset(name); keys.add(preset); - keysSorted.add(preset); - wasSorted = false; return preset; } public void tick() { - if (!wasSorted) { - keysSorted.sort(KeyPreset::compareTo); - wasSorted = true; - } - - for (KeyPreset key : keysSorted) { + for (KeyPreset key : keys) key.tick(); - if (key.isDown && key.shouldConflict) - return; - } }