コード例 #1
0
 @Override
 public void unbind(String cmd) {
   for (Binding binding : bindings) {
     if (binding.getCommand().equalsIgnoreCase(cmd)) {
       bindings.remove(binding);
       return;
     }
   }
 }
コード例 #2
0
 @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;
 }
コード例 #3
0
 @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;
 }
コード例 #4
0
 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);
     }
   }
 }