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 TypeMethodDescriptionvoidaddInventoryListener(int tag, @NotNull ItemListener listener) Adds anItemListenerto be notified about changes.voidAdds an item.voidaddItemSetListener(@NotNull ItemSetListener listener) Adds anItemSetListenerto be notified about changes.voidcleanInventory(int tag) Clears the inventory of an item.@Nullable CfItemgetInventoryItem(int tag, int index) Returns aCfItemfrom the inventory of an item.@Nullable CfItemgetItemByTag(int tag) Returns an item by tag.getItemsByLocation(int location) Returns a list of items in a given location.intgetNumberOfItemsByLocation(int location) Returns the number of items in a given location.intReturns the currently opened container.@Nullable CfItemReturns the player object this client controls.Returns the player's inventory.voidremoveInventoryListener(int tag, @NotNull ItemListener listener) Removes anItemListenerto be notified about changes.voidremoveItems(int @NotNull [] tags) Deletes items by tag.voidremoveItemSetListener(@NotNull ItemSetListener listener) Removes anItemSetListenerto be notified about changes.voidreset()Resets the manager's state.voidsetMarkedItemTag(int markedItemTag) Sets the marked item.voidSets the player object this client controls.voidupdateItem(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 anItemSetListenerto be notified about changes.- Parameters:
listener- the listener to add
-
removeItemSetListener
Removes anItemSetListenerto be notified about changes.- Parameters:
listener- the listener to remove
-
addInventoryListener
Adds anItemListenerto be notified about changes.- Parameters:
tag- the item tag to watchlistener- the listener to add
-
removeInventoryListener
Removes anItemListenerto 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
nullif 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 aCfItemfrom the inventory of an item.- Parameters:
tag- the item's tagindex- the index of the inventory item to return- Returns:
- the inventory item or
nullif 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-1to unset the marked item
-