mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-20 08:49:41 +00:00
Give priority of keybinds with special keys
Stop searching if found match.
This commit is contained in:
1 parent
00eefb0887
commit
3568fb8a86
2 files changed
+33
-2
No files matched your search
@@ -13,6 +13,8 @@ public class KeyPresetManager {
|
||||
public List<KeyPreset> keys = new ArrayList<>();
|
||||
public String fileName;
|
||||
|
||||
private boolean wasSorted = false;
|
||||
|
||||
public KeyPresetManager(String fileName) {
|
||||
this.fileName = fileName;
|
||||
}
|
||||
@@ -20,12 +22,21 @@ public class KeyPresetManager {
|
||||
public KeyPreset add(String name) {
|
||||
KeyPreset preset = new KeyPreset(name);
|
||||
keys.add(preset);
|
||||
wasSorted = false;
|
||||
return preset;
|
||||
}
|
||||
|
||||
public void tick() {
|
||||
for (KeyPreset key : keys)
|
||||
if (!wasSorted) {
|
||||
keys.sort(KeyPreset::compareTo);
|
||||
wasSorted = true;
|
||||
}
|
||||
|
||||
for (KeyPreset key : keys) {
|
||||
key.tick();
|
||||
if (key.isDown)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user