Package dev.aurelium.slate.inv.content
Class SlotIterator.Impl
java.lang.Object
dev.aurelium.slate.inv.content.SlotIterator.Impl
- All Implemented Interfaces:
SlotIterator
- Enclosing interface:
- SlotIterator
-
Nested Class Summary
Nested classes/interfaces inherited from interface dev.aurelium.slate.inv.content.SlotIterator
SlotIterator.Impl, SlotIterator.Type -
Constructor Summary
ConstructorsConstructorDescriptionImpl(InventoryContents contents, SmartInventory inv, SlotIterator.Type type) Impl(InventoryContents contents, SmartInventory inv, SlotIterator.Type type, int startRow, int startColumn) -
Method Summary
Modifier and TypeMethodDescriptionallowOverride(boolean override) Sets the value of the allow override option.blacklist(int index) Blacklists the given slot index.blacklist(int row, int column) Blacklists the given slot position.Blacklists the given slot position.blacklistPattern(Pattern<Boolean> pattern) This method has the inverse effect ofSlotIterator.withPattern(Pattern), where the other method would only allow the iterator to go, this method prohibits this slots to iterate overblacklistPattern(Pattern<Boolean> pattern, int rowOffset, int columnOffset) This method has the inverse effect ofSlotIterator.withPattern(Pattern, int, int), where the other method would only allow the iterator to go, this method prohibits this slots to iterate overintcolumn()Gets the current column of the iterator.column(int column) Sets the current column of the iterator.booleanGets the value of the allow override option.booleanended()Checks if this iterator has been ended.endPosition(int row, int column) Sets the slot where the iterator should end.endPosition(SlotPos endPosition) Sets the slot where the iterator should end.get()Gets the item at the current position in the inventory.next()Moves the cursor to the next position inside the inventory.previous()Moves the cursor to the previous position inside the inventory.reset()Resets iterator to its original position specified while creation.introw()Gets the current row of the iterator.row(int row) Sets the current row of the iterator.set(ClickableItem item) Replaces the item at the current position in the inventory by the given item.booleanstarted()Checks if this iterator has been started.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.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.
-
Constructor Details
-
Impl
public Impl(InventoryContents contents, SmartInventory inv, SlotIterator.Type type, int startRow, int startColumn) -
Impl
-
-
Method Details
-
get
Description copied from interface:SlotIteratorGets the item at the current position in the inventory.- Specified by:
getin interfaceSlotIterator- Returns:
- the item at the current position
-
set
Description copied from interface:SlotIteratorReplaces the item at the current position in the inventory by the given item.- Specified by:
setin interfaceSlotIterator- Parameters:
item- the new item- Returns:
this, for chained calls
-
previous
Description copied from interface:SlotIteratorMoves 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.- Specified by:
previousin interfaceSlotIterator- Returns:
this, for chained calls
-
next
Description copied from interface:SlotIteratorMoves 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.- Specified by:
nextin interfaceSlotIterator- Returns:
this, for chained calls
-
blacklist
Description copied from interface:SlotIteratorBlacklists the given slot index.
Blacklisting a slot will make the iterator skip the given slot and directly go to the next unblacklisted slot.- Specified by:
blacklistin interfaceSlotIterator- Parameters:
index- the index to blacklist- Returns:
this, for chained calls
-
blacklist
Description copied from interface:SlotIteratorBlacklists the given slot position.
Blacklisting a slot will make the iterator skip the given slot and directly go to the next unblacklisted slot.- Specified by:
blacklistin interfaceSlotIterator- Parameters:
row- the row of the slot to blacklistcolumn- the column of the slot to blacklist- Returns:
this, for chained calls
-
blacklist
Description copied from interface:SlotIteratorBlacklists the given slot position.
Blacklisting a slot will make the iterator skip the given slot and directly go to the next unblacklisted slot.- Specified by:
blacklistin interfaceSlotIterator- Parameters:
slotPos- the slot to blacklist- Returns:
this, for chained calls
-
row
public int row()Description copied from interface:SlotIteratorGets the current row of the iterator.- Specified by:
rowin interfaceSlotIterator- Returns:
- the current row
-
row
Description copied from interface:SlotIteratorSets the current row of the iterator.- Specified by:
rowin interfaceSlotIterator- Parameters:
row- the new row- Returns:
this, for chained calls
-
column
public int column()Description copied from interface:SlotIteratorGets the current column of the iterator.- Specified by:
columnin interfaceSlotIterator- Returns:
- the current column
-
column
Description copied from interface:SlotIteratorSets the current column of the iterator.- Specified by:
columnin interfaceSlotIterator- Parameters:
column- the new column- Returns:
this, for chained calls
-
reset
Description copied from interface:SlotIteratorResets iterator to its original position specified while creation.
When the iterator gets reset to its original position,startedgets set back tofalse- Specified by:
resetin interfaceSlotIterator- Returns:
this, for chained calls
-
started
public boolean started()Description copied from interface:SlotIteratorChecks if this iterator has been started.
An iterator is not started until any of theSlotIterator.previous()or theSlotIterator.next()methods have been called.- Specified by:
startedin interfaceSlotIterator- Returns:
trueif this iterator has been started
-
ended
public boolean ended()Description copied from interface:SlotIteratorChecks if this iterator has been ended.
An iterator is not ended until it has reached the last slot of the inventory.- Specified by:
endedin interfaceSlotIterator- Returns:
trueif this iterator has been ended
-
endPosition
Description copied from interface:SlotIteratorSets the slot where the iterator should end.
Ifrowis a negative value, it is set to the maximum row count.
Ifcolumnis a negative value, it is set to maximum column count.- Specified by:
endPositionin interfaceSlotIterator- Parameters:
row- The row where the iterator should endcolumn- The column where the iterator should end- Returns:
this, for chained calls
-
endPosition
Description copied from interface:SlotIteratorSets 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.- Specified by:
endPositionin interfaceSlotIterator- Parameters:
endPosition- The slot where the iterator should end- Returns:
this, for chained calls
-
doesAllowOverride
public boolean doesAllowOverride()Description copied from interface:SlotIteratorGets the value of the allow override option.
- If this istrue, the iterator will override any existing item it founds on its way.
- If this isfalse, the iterator will skip the slots which are not empty.- Specified by:
doesAllowOverridein interfaceSlotIterator- Returns:
trueif this iterator allows to override
-
allowOverride
Description copied from interface:SlotIteratorSets the value of the allow override option.
- If this istrue, the iterator will override any existing item it founds on its way.
- If this isfalse, the iterator will skip the slots which are not empty.- Specified by:
allowOverridein interfaceSlotIterator- Parameters:
override- the value of the allow override option- Returns:
this, for chained calls
-
withPattern
Description copied from interface:SlotIteratorSetting 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 thewrapAroundflag 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 tofalse
If you passnullinto thepatternparameter, this functionality will be disabled and the iterator will continue to work as normal.- Specified by:
withPatternin interfaceSlotIterator- Parameters:
pattern- The pattern to use as a guideline- Returns:
this, for chained calls
-
withPattern
Description copied from interface:SlotIteratorSetting 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 thewrapAroundflag 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 thewrapAroundflag 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 tofalse
If you passnullinto thepatternparameter, this functionality will be disabled and the iterator will continue to work as normal.- Specified by:
withPatternin interfaceSlotIterator- Parameters:
pattern- The pattern to use as a guidelinerowOffset- The row offset from the top left cornercolumnOffset- The column offset from the top left corner- Returns:
this, for chained calls
-
blacklistPattern
Description copied from interface:SlotIteratorThis method has the inverse effect ofSlotIterator.withPattern(Pattern), where the other method would only allow the iterator to go, this method prohibits this slots to iterate over- Specified by:
blacklistPatternin interfaceSlotIterator- Parameters:
pattern- The pattern where the slot iterator cannot iterate- Returns:
this, for chained calls
-
blacklistPattern
Description copied from interface:SlotIteratorThis method has the inverse effect ofSlotIterator.withPattern(Pattern, int, int), where the other method would only allow the iterator to go, this method prohibits this slots to iterate over- Specified by:
blacklistPatternin interfaceSlotIterator- Parameters:
pattern- The pattern where the slot iterator cannot iteraterowOffset- The row offset from the top left cornercolumnOffset- The column offset from the top left corner- Returns:
this, for chained calls
-