Class ItemSet
- java.lang.Object
-
- com.realtime.crossfire.jxclient.items.ItemSet
-
public class ItemSet extends java.lang.ObjectModel class maintaining theCfItemsknown to the player.
-
-
Constructor Summary
Constructors Constructor Description ItemSet()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddInventoryListener(int tag, @NotNull ItemListener listener)Adds anItemListenerto be notified about changes.voidaddItem(@NotNull CfItem item)Adds 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.@NotNull java.util.List<CfItem>getItemsByLocation(int location)Returns a list of items in a given location.intgetNumberOfItemsByLocation(int location)Returns the number of items in a given location.intgetOpenContainer()Returns the currently opened container.@Nullable CfItemgetPlayer()Returns the player object this client controls.@NotNull java.lang.Iterable<CfItem>getPlayerInventory()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.voidsetPlayer(@Nullable CfItem player)Sets the player object this client controls.voidupdateItem(int flags, int tag, int valLocation, int valFlags, int valWeight, @NotNull Face valFace, @NotNull java.lang.String valName, @NotNull java.lang.String valNamePl, int valAnim, int valAnimSpeed, int valNrof)Processes an "upditem" command.
-
-
-
Method Detail
-
addItemSetListener
public void addItemSetListener(@NotNull @NotNull ItemSetListener listener)Adds anItemSetListenerto be notified about changes.- Parameters:
listener- the listener to add
-
removeItemSetListener
public void removeItemSetListener(@NotNull @NotNull ItemSetListener listener)Removes anItemSetListenerto be notified about changes.- Parameters:
listener- the listener to remove
-
addInventoryListener
public void addInventoryListener(int tag, @NotNull @NotNull ItemListener listener)Adds anItemListenerto be notified about changes.- Parameters:
tag- the item tag to watchlistener- the listener to add
-
removeInventoryListener
public void removeInventoryListener(int tag, @NotNull @NotNull ItemListener listener)Removes anItemListenerto be notified about changes.- Parameters:
tag- the item tag to watchlistener- the listener to add
-
getItemsByLocation
@NotNull public @NotNull java.util.List<CfItem> getItemsByLocation(int location)
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
public void addItem(@NotNull @NotNull CfItem item)Adds an item.- Parameters:
item- the item to add
-
getItemByTag
@Nullable public @Nullable CfItem getItemByTag(int tag)
Returns an item by tag.- Parameters:
tag- the tag- Returns:
- the item or
nullif no such items exists
-
getPlayer
@Nullable public @Nullable CfItem getPlayer()
Returns the player object this client controls.- Returns:
- the player object
-
setPlayer
public void setPlayer(@Nullable @Nullable CfItem player)Sets the player object this client controls.- Parameters:
player- the new player object
-
getPlayerInventory
@NotNull public @NotNull java.lang.Iterable<CfItem> 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 java.lang.String valName, @NotNull @NotNull java.lang.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
-
-