Exemplo n.º 1
0
  @Override
  public void parseArgs(ScriptEntry scriptEntry) throws InvalidArgumentsException {

    // Parse Arguments
    for (Argument arg : aH.interpret(scriptEntry.getArguments())) {

      if (!scriptEntry.hasObject("action") && arg.matchesEnum(Action.values()))
        scriptEntry.addObject("action", Action.valueOf(arg.getValue().toUpperCase()));
      else if (!scriptEntry.hasObject("range")
          && arg.matchesPrimitive(aH.PrimitiveType.Double)
          && arg.matchesPrefix("range, r")) scriptEntry.addObject("range", arg.asElement());
      else if (!scriptEntry.hasObject("id") && arg.matchesPrefix("id, i"))
        scriptEntry.addObject("id", arg.asElement());
      else if (!scriptEntry.hasObject("location") && arg.matchesArgumentType(dLocation.class))
        scriptEntry.addObject("location", arg.asType(dLocation.class));
      else arg.reportUnhandled();
    }

    // Check required arguments
    if (!scriptEntry.hasNPC())
      throw new InvalidArgumentsException("NPC linked was missing or invalid.");

    if (!scriptEntry.hasObject("action"))
      throw new InvalidArgumentsException(
          "Must specify an 'Anchor Action'. Valid: " + Action.values());
  }