Package dev.aurelium.slate.inv.content
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.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classstatic enumThe iterate type of the inventory. -
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 ofwithPattern(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 ofwithPattern(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.
-
Method Details
-
get
Optional<ClickableItem> 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
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
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 blacklistcolumn- the column of the slot to blacklist- Returns:
this, for chained calls
-
blacklist
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
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
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,startedgets set back tofalse- Returns:
this, for chained calls
-
started
boolean started()Checks if this iterator has been started.
An iterator is not started until any of theprevious()or thenext()methods have been called.- Returns:
trueif 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:
trueif this iterator has been ended
-
endPosition
Sets 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.- Parameters:
row- The row where the iterator should endcolumn- The column where the iterator should end- Returns:
this, for chained calls
-
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 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.- Returns:
trueif this iterator allows to override
-
allowOverride
Sets 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.- Parameters:
override- the value of the allow override option- Returns:
this, for chained calls
-
withPattern
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 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.- Parameters:
pattern- The pattern to use as a guideline- Returns:
this, for chained calls
-
withPattern
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 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.- 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
This method has the inverse effect ofwithPattern(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
This method has the inverse effect ofwithPattern(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 iteraterowOffset- The row offset from the top left cornercolumnOffset- The column offset from the top left corner- Returns:
this, for chained calls
-