示例#1
0
  public BaseSWGCommand getCommandByCRC(int commandCRC) {
    Vector<BaseSWGCommand> commands = new Vector<BaseSWGCommand>(commandLookup);

    for (BaseSWGCommand command : commands) {
      if (command.getCommandCRC() == commandCRC) {
        return command;
      }
    }

    try {
      String[] tableArray =
          new String[] {
            "client_command_table",
            "command_table",
            "client_command_table_ground",
            "command_table_ground",
            "client_command_table_space",
            "command_table_space"
          };

      for (int n = 0; n < tableArray.length; n++) {
        DatatableVisitor visitor =
            ClientFileManager.loadFile(
                "datatables/command/" + tableArray[n] + ".iff", DatatableVisitor.class);

        for (int i = 0; i < visitor.getRowCount(); i++) {
          if (visitor.getObject(i, 0) != null) {
            String name = ((String) visitor.getObject(i, 0)).toLowerCase();

            if (CRC.StringtoCRC(name) == commandCRC) {
              if (isCombatCommand(name)) {
                CombatCommand command = new CombatCommand(name.toLowerCase());
                commandLookup.add(command);
                return command;
              } else {
                BaseSWGCommand command = new BaseSWGCommand(name.toLowerCase());
                commandLookup.add(command);
                return command;
              }
            }
          }
        }
      }
    } catch (InstantiationException | IllegalAccessException e) {
      e.printStackTrace();
    }

    return null;
  }