Class ItemSet
java.lang.Object
com.realtime.crossfire.jxclient.items.ItemSet
Model class maintaining the
CfItems
known to the player.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addInventoryListener
(int tag, @NotNull ItemListener listener) Adds anItemListener
to be notified about changes.void
Adds an item.void
addItemSetListener
(@NotNull ItemSetListener listener) Adds anItemSetListener
to be notified about changes.void
cleanInventory
(int tag) Clears the inventory of an item.@Nullable CfItem
getInventoryItem
(int tag, int index) Returns aCfItem
from the inventory of an item.@Nullable CfItem
getItemByTag
(int tag) Returns an item by tag.getItemsByLocation
(int location) Returns a list of items in a given location.int
getNumberOfItemsByLocation
(int location) Returns the number of items in a given location.int
Returns the currently opened container.@Nullable CfItem
Returns the player object this client controls.Returns the player's inventory.void
removeInventoryListener
(int tag, @NotNull ItemListener listener) Removes anItemListener
to be notified about changes.void
removeItems
(int @NotNull [] tags) Deletes items by tag.void
removeItemSetListener
(@NotNull ItemSetListener listener) Removes anItemSetListener
to be notified about changes.void
reset()
Resets the manager's state.void
setMarkedItemTag
(int markedItemTag) Sets the marked item.void
Sets the player object this client controls.void
updateItem
(int flags, int tag, int valLocation, int valFlags, int valWeight, @NotNull Face valFace, @NotNull String valName, @NotNull String valNamePl, int valAnim, int valAnimSpeed, int valNrof) Processes an "upditem" command.
-
Constructor Details
-
ItemSet
public ItemSet()
-
-
Method Details
-
addItemSetListener
Adds anItemSetListener
to be notified about changes.- Parameters:
listener
- the listener to add
-
removeItemSetListener
Removes anItemSetListener
to be notified about changes.- Parameters:
listener
- the listener to remove
-
addInventoryListener
Adds anItemListener
to be notified about changes.- Parameters:
tag
- the item tag to watchlistener
- the listener to add
-
removeInventoryListener
Removes anItemListener
to be notified about changes.- Parameters:
tag
- the item tag to watchlistener
- the listener to add
-
getItemsByLocation
Returns a list of items in a given location. The returned list may not be modified by the caller.- Parameters:
location
- the location- Returns:
- the list of items
-
getNumberOfItemsByLocation
public int getNumberOfItemsByLocation(int location) Returns the number of items in a given location. Undefined locations return0
.- Parameters:
location
- the location to check- Returns:
- the number of items
-
removeItems
public void removeItems(int @NotNull [] tags) Deletes items by tag.- Parameters:
tags
- the tags to delete
-
addItem
Adds an item.- Parameters:
item
- the item to add
-
getItemByTag
Returns an item by tag.- Parameters:
tag
- the tag- Returns:
- the item or
null
if no such items exists
-
getPlayer
Returns the player object this client controls.- Returns:
- the player object
-
setPlayer
Sets the player object this client controls.- Parameters:
player
- the new player object
-
getPlayerInventory
Returns the player's inventory.- Returns:
- the inventory items; the list cannot be modified
-
cleanInventory
public void cleanInventory(int tag) Clears the inventory of an item.- Parameters:
tag
- the item tag
-
updateItem
public void updateItem(int flags, int tag, int valLocation, int valFlags, int valWeight, @NotNull @NotNull Face valFace, @NotNull @NotNull String valName, @NotNull @NotNull String valNamePl, int valAnim, int valAnimSpeed, int valNrof) Processes an "upditem" command.- Parameters:
flags
- the changed valuestag
- the item's tagvalLocation
- the item's locationvalFlags
- the item's flagsvalWeight
- the item's weightvalFace
- the item's facevalName
- the item's singular namevalNamePl
- the item's plural namevalAnim
- the item's animation IDvalAnimSpeed
- the item's animation speedvalNrof
- the number of items
-
reset
public void reset()Resets the manager's state. -
getOpenContainer
public int getOpenContainer()Returns the currently opened container.- Returns:
- the opened container's tag
-
getInventoryItem
Returns aCfItem
from the inventory of an item.- Parameters:
tag
- the item's tagindex
- the index of the inventory item to return- Returns:
- the inventory item or
null
if the index does not exist
-
setMarkedItemTag
public void setMarkedItemTag(int markedItemTag) Sets the marked item. Ignores the request if the item is not in the inventory.- Parameters:
markedItemTag
- the tag of the marked item or-1
to unset the marked item
-