Class InventoryFoodQueries

java.lang.Object
privbot.hooks.InventoryFoodQueries

public final class InventoryFoodQueries extends Object
Modular inventory food resolution: Inventory query plus Eat (Warden-style), optional name-pattern tier when composition actions are wrong, then item-id fallback.
  • Field Details

    • EAT_ACTION

      public static final String EAT_ACTION
      The menu action that marks an item as food.
      See Also:
    • DEFAULT_COOKED_FOOD_NAME_PATTERNS

      public static final String[] DEFAULT_COOKED_FOOD_NAME_PATTERNS
      Default cooked-food name substrings (contains, case-insensitive). Single place to extend.
  • Method Details

    • firstWithEatAction

      public static PrivItem firstWithEatAction(Inventory inventory)
      The first carried item (no placeholders) whose actions include EAT_ACTION.
      Parameters:
      inventory - ctx.inventory
      Returns:
      the item, or null when none (or no inventory)
    • firstByNamePatternsPreferEat

      public static PrivItem firstByNamePatternsPreferEat(Inventory inventory, String... namePatterns)
      The first carried item whose name contains one of namePatterns, preferring items that list EAT_ACTION (for servers whose item definitions report wrong actions); lowest potion dose, then lowest slot, first.
      Parameters:
      inventory - ctx.inventory
      namePatterns - case-insensitive name substrings
      Returns:
      the item, or null
    • tryInteractEat

      public static boolean tryInteractEat(PrivItem food)
      Dispatches "Eat" on food.
      Parameters:
      food - the item, may be null
      Returns:
      dispatch acceptance (false for null); verify HP rose or the item was consumed