Class ItemCollectorData

java.lang.Object
games.stendhal.server.maps.quests.logic.ItemCollectorData
All Implemented Interfaces:
ItemCollectorSetters

public class ItemCollectorData extends Object implements ItemCollectorSetters
Container for a collectible item. Holds information about the initial required amount, as well as the current still needed amount, and a message describing the need of the item. The recommended way of building an instance of this type if by using ItemCollector.require().
  • Constructor Details

    • ItemCollectorData

      public ItemCollectorData()
  • Method Details

    • item

      public ItemCollectorSetters item(String itemName)
      Description copied from interface: ItemCollectorSetters
      Sets the name of an item to collect.
      Specified by:
      item in interface ItemCollectorSetters
      Parameters:
      itemName - an item name
      Returns:
      this object to allow method call chaining
    • pieces

      public ItemCollectorSetters pieces(int count)
      Description copied from interface: ItemCollectorSetters
      Sets the number of required instances for an item to collect.
      Specified by:
      pieces in interface ItemCollectorSetters
      Parameters:
      count - the number of items of the same kind
      Returns:
      this object to allow method call chaining
    • bySaying

      public ItemCollectorSetters bySaying(String message)
      Description copied from interface: ItemCollectorSetters
      Sets the message to describe an item to collect. Should contain a "%s" where the count and name of the item are to be replaced. For example, the message "I still need %s." may appear as "I still need 6 pieces of iron."
      Specified by:
      bySaying in interface ItemCollectorSetters
      Parameters:
      message - a message to be said by the NPC when talking about the item to collect
      Returns:
      this object to allow method call chaining
    • subtractAmount

      public void subtractAmount(int amount)
      Subtract the specified amount from the still needed amount.
      Parameters:
      amount - how much to subtract from the still needed amount
    • subtractAmount

      public void subtractAmount(String amount)
      Subtract the specified amount from the still needed amount.
      Parameters:
      amount - a number indicating how much to subtract from the still needed amount
    • resetAmount

      public void resetAmount()
      Makes the still needed amount equal to the initial required amount.
    • getAlreadyBrought

      public int getAlreadyBrought()
      Gets the number of already collected items.
      Returns:
      the difference between the initial required amount and the still needed amount
    • getStillNeeded

      public int getStillNeeded()
      Gets the number of items that are still needed.
      Returns:
      the difference between the initial required amount and the amount already brought
    • getRequiredAmount

      public int getRequiredAmount()
      Gets the number of initially required items.
      Returns:
      the number of initially required items
    • getName

      public String getName()
      Gets the name of the item to collect.
      Returns:
      the name of the item to collect
    • getAnswer

      public String getAnswer()
      Uses the configured message to describe the need of this item.
      Returns:
      a message describing the need of this item.
      See Also:
      bySaying(String)