@Override public void unbind(String cmd) { for (Binding binding : bindings) { if (binding.getCommand().equalsIgnoreCase(cmd)) { bindings.remove(binding); return; } } }
@Override public Set<Binding> getMouseBindingsFor(Mouse mouse) { Set<Binding> bound = new HashSet<Binding>(); for (Binding binding : bindings) { for (Mouse button : binding.getMouseBindings()) { if (button == mouse) { bound.add(binding); break; } } } return bound; }
@Override public Set<Binding> getKeyBindingsFor(Keyboard key) { Set<Binding> bound = new HashSet<Binding>(); for (Binding binding : bindings) { for (Keyboard k : binding.getKeyBindings()) { if (k == key) { bound.add(binding); break; } } } return bound; }
private void executeBindings(Set<Binding> bindings, Player player, boolean pressed) { ChatArguments args = new ChatArguments(pressed ? "+" : "-"); // Queue up sync bindings first for (Binding binding : bindings) { if (!binding.isAsync()) { player .getEngine() .getScheduler() .scheduleSyncDelayedTask(null, new BindingTask(player, binding.getCommand(), args)); } } // Execute async bindings for (Binding binding : bindings) { if (binding.isAsync()) { player.processCommand(binding.getCommand(), args); } } }