Interface SlotIterator

All Known Implementing Classes:
SlotIterator.Impl

public interface SlotIterator

The SlotIterator system allows you to iterate through the slots of an inventory either horizontally or vertically.

  • Method Details

    • get

      Gets the item at the current position in the inventory.
      Returns:
      the item at the current position
    • set

      Replaces the item at the current position in the inventory by the given item.
      Parameters:
      item - the new item
      Returns:
      this, for chained calls
    • previous

      SlotIterator previous()
      Moves the cursor to the previous position inside the inventory.
      This has no effect if the cursor is already at the first position of the inventory.
      Returns:
      this, for chained calls
    • next

      SlotIterator next()
      Moves the cursor to the next position inside the inventory.
      This has no effect if the cursor is already at the last position of the inventory.
      Returns:
      this, for chained calls
    • blacklist

      SlotIterator blacklist(int index)
      Blacklists the given slot index.
      Blacklisting a slot will make the iterator skip the given slot and directly go to the next unblacklisted slot.
      Parameters:
      index - the index to blacklist
      Returns:
      this, for chained calls
    • blacklist

      SlotIterator blacklist(int row, int column)
      Blacklists the given slot position.
      Blacklisting a slot will make the iterator skip the given slot and directly go to the next unblacklisted slot.
      Parameters:
      row - the row of the slot to blacklist
      column - the column of the slot to blacklist
      Returns:
      this, for chained calls
    • blacklist

      SlotIterator blacklist(SlotPos slotPos)
      Blacklists the given slot position.
      Blacklisting a slot will make the iterator skip the given slot and directly go to the next unblacklisted slot.
      Parameters:
      slotPos - the slot to blacklist
      Returns:
      this, for chained calls
    • row

      int row()
      Gets the current row of the iterator.
      Returns:
      the current row
    • row

      SlotIterator row(int row)
      Sets the current row of the iterator.
      Parameters:
      row - the new row
      Returns:
      this, for chained calls
    • column

      int column()
      Gets the current column of the iterator.
      Returns:
      the current column
    • column

      SlotIterator column(int column)
      Sets the current column of the iterator.
      Parameters:
      column - the new column
      Returns:
      this, for chained calls
    • reset

      SlotIterator reset()
      Resets iterator to its original position specified while creation.
      When the iterator gets reset to its original position, started gets set back to false
      Returns:
      this, for chained calls
    • started

      boolean started()
      Checks if this iterator has been started.
      An iterator is not started until any of the previous() or the next() methods have been called.
      Returns:
      true if this iterator has been started
    • ended

      boolean ended()
      Checks if this iterator has been ended.
      An iterator is not ended until it has reached the last slot of the inventory.
      Returns:
      true if this iterator has been ended
    • endPosition

      SlotIterator endPosition(int row, int column)
      Sets the slot where the iterator should end.

      If row is a negative value, it is set to the maximum row count.
      If column is a negative value, it is set to maximum column count.
      Parameters:
      row - The row where the iterator should end
      column - The column where the iterator should end
      Returns:
      this, for chained calls
    • endPosition

      SlotIterator endPosition(SlotPos endPosition)
      Sets the slot where the iterator should end.

      If the row of the SlotPos is a negative value, it is set to the maximum row count.
      If the column of the SlotPos is a negative value, it is set to maximum column count.
      Parameters:
      endPosition - The slot where the iterator should end
      Returns:
      this, for chained calls
    • doesAllowOverride

      boolean doesAllowOverride()
      Gets the value of the allow override option.
      - If this is true, the iterator will override any existing item it founds on its way.
      - If this is false, the iterator will skip the slots which are not empty.
      Returns:
      true if this iterator allows to override
    • allowOverride

      SlotIterator allowOverride(boolean override)
      Sets the value of the allow override option.
      - If this is true, the iterator will override any existing item it founds on its way.
      - If this is false, the iterator will skip the slots which are not empty.
      Parameters:
      override - the value of the allow override option
      Returns:
      this, for chained calls
    • withPattern

      SlotIterator withPattern(Pattern<Boolean> pattern)
      Setting a pattern using this method will use it as a guideline where the slot iterator can set items or not. If the pattern doesn't fill the whole inventory, the slot iterator is limited to the space the pattern provides. If the pattern has the wrapAround flag set, then the iterator can iterate over the entire inventory, even if the pattern would not fill it by itself

      If the provided pattern has no default value set, this method will set it to false

      If you pass null into the pattern parameter, this functionality will be disabled and the iterator will continue to work as normal.
      Parameters:
      pattern - The pattern to use as a guideline
      Returns:
      this, for chained calls
    • withPattern

      SlotIterator withPattern(Pattern<Boolean> pattern, int rowOffset, int columnOffset)
      Setting a pattern using this method will use it as a guideline where the slot iterator can set items or not. If the pattern doesn't fill the whole inventory, the slot iterator is limited to the space the pattern provides. If the pattern has the wrapAround flag set, then the iterator can iterate over the entire inventory, even if the pattern would not fill it by itself

      The offset defines the top-left corner of the pattern. If the wrapAround flag is set, then the entire pattern will be just shifted by the given amount.

      If the provided pattern has no default value set, this method will set it to false

      If you pass null into the pattern parameter, this functionality will be disabled and the iterator will continue to work as normal.
      Parameters:
      pattern - The pattern to use as a guideline
      rowOffset - The row offset from the top left corner
      columnOffset - The column offset from the top left corner
      Returns:
      this, for chained calls
    • blacklistPattern

      SlotIterator blacklistPattern(Pattern<Boolean> pattern)
      This method has the inverse effect of withPattern(Pattern), where the other method would only allow the iterator to go, this method prohibits this slots to iterate over
      Parameters:
      pattern - The pattern where the slot iterator cannot iterate
      Returns:
      this, for chained calls
    • blacklistPattern

      SlotIterator blacklistPattern(Pattern<Boolean> pattern, int rowOffset, int columnOffset)
      This method has the inverse effect of withPattern(Pattern, int, int), where the other method would only allow the iterator to go, this method prohibits this slots to iterate over
      Parameters:
      pattern - The pattern where the slot iterator cannot iterate
      rowOffset - The row offset from the top left corner
      columnOffset - The column offset from the top left corner
      Returns:
      this, for chained calls