public class InventoryView extends AbstractItemView
If no player object is known an empty inventory view is generated.
Modifier and Type | Field and Description |
---|---|
private java.util.Comparator<CfItem> |
comparator
The
Comparator for sorting. |
private int |
currentPlayerTag
The tag of the current player object or
-1 . |
private java.util.List<CfItem> |
items
The items in the inventory ordered by
comparator . |
private ItemSet |
itemSet
The
ItemSet to monitor. |
private ItemSetListener |
itemSetListener
The
ItemSetListener attached to itemSet to track the
current player object. |
private DoubleMapping |
mapping
Maps external index to original index.
|
private ItemListener |
playerInventoryListener
The
ItemListener attached to the current player object. |
Constructor and Description |
---|
InventoryView(ItemSet itemSet,
java.util.Comparator<CfItem> comparator)
Creates a new instance.
|
Modifier and Type | Method and Description |
---|---|
private int |
findInsertionIndex(CfItem item)
Returns the insertion index of a
CfItem . |
CfItem |
getItem(int index)
Returns the
CfItem in a given slot. |
int |
getSize()
Returns the number of items.
|
private void |
setCurrentPlayerTag(int currentPlayerTag)
Updates the current player object.
|
addLocationListener, addLocationsListener, addModified, addModifiedRange, removeLocationListener, removeLocationsListener
@NotNull private final java.util.Comparator<CfItem> comparator
Comparator
for sorting.private int currentPlayerTag
-1
.@NotNull private final java.util.List<CfItem> items
comparator
.@NotNull private final ItemSetListener itemSetListener
ItemSetListener
attached to itemSet
to track the
current player object.@NotNull private final DoubleMapping mapping
@NotNull private final ItemListener playerInventoryListener
ItemListener
attached to the current player object.private int findInsertionIndex(@NotNull CfItem item)
CfItem
.item
- the item to insert into the inventory@Nullable public CfItem getItem(int index)
CfItem
in a given slot.index
- the slot indexnull
if the slot is emptypublic int getSize()
private void setCurrentPlayerTag(int currentPlayerTag)
currentPlayerTag
- the tag of the player object or -1