コード例 #1
0
 public boolean unregisterCommands() {
   CommandMap commandMap = getCommandMap();
   List<String> toRemove = new ArrayList<String>();
   Map<String, org.bukkit.command.Command> knownCommands =
       ReflectionUtil.getField(commandMap, "knownCommands");
   Set<String> aliases = ReflectionUtil.getField(commandMap, "aliases");
   if (knownCommands == null || aliases == null) {
     return false;
   }
   for (Iterator<org.bukkit.command.Command> i = knownCommands.values().iterator();
       i.hasNext(); ) {
     org.bukkit.command.Command cmd = i.next();
     if (cmd instanceof DynamicPluginCommand
         && ((DynamicPluginCommand) cmd).getOwner().equals(executor)) {
       i.remove();
       for (String alias : cmd.getAliases()) {
         org.bukkit.command.Command aliasCmd = knownCommands.get(alias);
         if (cmd.equals(aliasCmd)) {
           aliases.remove(alias);
           toRemove.add(alias);
         }
       }
     }
   }
   for (String string : toRemove) {
     knownCommands.remove(string);
   }
   return true;
 }
コード例 #2
0
  public Event getEvent(CommandSender sender, Command command, String label, String[] args) {
    CommandEvent event = null;

    if (command.equals("ccBalance")) {
      event = new BalanceEvent();
      event.setSender(sender);
      event.setLabel(label);
      event.setArgs(args);
      event.setCommand(command);
    }

    return event;
  }