Exemplo n.º 1
0
  @Override
  public void onRegistered() {
    List<RecipeBook> books = RecipeBooks.getInstance().getBooksPartialMatch(getBookID());

    if (books.isEmpty()) {
      ErrorReporter.getInstance()
          .warning(
              "Flag "
                  + getFlagType()
                  + " could not find book ID containing '"
                  + bookID
                  + "', flag ignored.");
      remove();
      return;
    }

    RecipeBook book = books.get(0);

    if (books.size() > 1) {
      ErrorReporter.getInstance()
          .warning(
              "Flag "
                  + getFlagType()
                  + " found "
                  + books.size()
                  + " books matching ID '"
                  + bookID
                  + "', using first: "
                  + book.getTitle());
    }
  }
Exemplo n.º 2
0
  @Override
  public void onPrepare(Args a) {
    if (getBookID() == null) {
      a.addCustomReason("Book ID not set!");
      return;
    }

    if (!a.hasResult()) {
      a.addCustomReason("Need result!");
      return;
    }

    List<RecipeBook> books = RecipeBooks.getInstance().getBooksPartialMatch(getBookID());

    if (books.isEmpty()) {
      return;
    }

    RecipeBook book = books.get(0);

    a.result().setItemMeta(book.getBookItem(volume).getItemMeta());
  }