blob: bbce1b3f65eeb5f86333442140842a708bb7c354 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
package me.shedaniel.library;
import net.minecraft.client.settings.KeyBinding;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
/**
* Created by James on 8/7/2018.
*/
public class KeyBindManager {
private static Map<KeyBinding, Sink> bindingFunctions = new HashMap<>();
public static KeyBinding createKeybinding(String bindingName, int key, String categoryName, Sink function) {
KeyBinding newBinding = new KeyBinding(bindingName, key, categoryName);
bindingFunctions.put(newBinding, function);
return newBinding;
}
public static boolean processGuiKeybinds(int typedChar) {
Optional<KeyBinding> binding = bindingFunctions.keySet().stream().filter(f -> f.getDefaultKeyCode().getKeyCode() == typedChar).findFirst();
if (binding.isPresent()) {
bindingFunctions.get(binding.get()).Sink();
return true;
}
return false;
}
}
|