java.lang.Objectcom.realtime.crossfire.jxclient.items.ItemSet
public class ItemSet
Model class maintaining the CfItems known to the player.
| Field Summary | |
|---|---|
private java.util.Map<java.lang.Integer,CfItem> |
allItems
Maps item tags to items. |
private HashedEventListenerList |
itemListeners
The registered ItemListeners to be notified about changes. |
private java.util.Map<java.lang.Integer,java.util.List<CfItem>> |
items
Maps location (=tag) to list of items in that location. |
private javax.swing.event.EventListenerList |
itemSetListeners
The list of ItemSetListeners to be notified about changes. |
private int |
openContainerFloor
The currently opened container or 0. |
private CfItem |
player
The current player object this client controls. |
private java.lang.Object |
sync
The synchronization object for XXX. |
| Constructor Summary | |
|---|---|
ItemSet()
|
|
| Method Summary | |
|---|---|
void |
addInventoryListener(int tag,
ItemListener listener)
Adds an ItemListener to be notified about changes. |
void |
addItem(CfItem item)
Adds an item. |
private int |
addItem(CfItem item,
boolean notifyListeners)
Adds a CfItem. |
void |
addItemSetListener(ItemSetListener listener)
Adds an ItemSetListener to be notified about changes. |
void |
cleanInventory(int tag)
Clears the inventory of an item. |
private java.util.List<CfItem> |
getInventoryByTag(int tag)
Returns the inventory of an item. |
CfItem |
getInventoryItem(int tag,
int index)
Returns a CfItem from the inventory of an item. |
CfItem |
getItemByTag(int tag)
Returns an item by tag. |
private CfItem |
getItemOrPlayer(int tag)
Returns an item by tag. |
java.util.List<CfItem> |
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 |
getOpenContainer()
Returns the currently opened container. |
CfItem |
getPlayer()
Returns the player object this client controls. |
java.lang.Iterable<CfItem> |
getPlayerInventory()
Returns the player's inventory. |
void |
removeInventoryListener(int tag,
ItemListener listener)
Removes an ItemListener to be notified about changes. |
private int |
removeItemByTag(int tag,
boolean notifyListeners)
Removes a CfItem. |
void |
removeItems(int[] tags)
Deletes items by tag. |
void |
removeItemSetListener(ItemSetListener listener)
Removes an ItemSetListener to be notified about changes. |
void |
reset()
Resets the manager's state. |
private void |
setOpenContainer(int openContainerFloor)
Sets the currently opened container. |
void |
setPlayer(CfItem player)
Sets the player object this client controls. |
void |
updateItem(int flags,
int tag,
int valLocation,
int valFlags,
int valWeight,
Face valFace,
java.lang.String valName,
java.lang.String valNamePl,
int valAnim,
int valAnimSpeed,
int valNrof)
Processes an "upditem" command. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
@NotNull private final java.util.Map<java.lang.Integer,CfItem> allItems
@NotNull private final HashedEventListenerList itemListeners
ItemListeners to be notified about changes.
@NotNull private final java.util.Map<java.lang.Integer,java.util.List<CfItem>> items
@NotNull private final javax.swing.event.EventListenerList itemSetListeners
ItemSetListeners to be notified about changes.
private int openContainerFloor
0.
@Nullable private CfItem player
@NotNull private final java.lang.Object sync
| Constructor Detail |
|---|
public ItemSet()
| Method Detail |
|---|
public void addInventoryListener(int tag,
@NotNull
ItemListener listener)
ItemListener to be notified about changes.
tag - the item tag to watchlistener - the listener to add
public void addItem(@NotNull
CfItem item)
item - the item to add
private int addItem(@NotNull
CfItem item,
boolean notifyListeners)
CfItem.
item - the item to addnotifyListeners - whether listeners should be notified about the
addition
public void addItemSetListener(@NotNull
ItemSetListener listener)
ItemSetListener to be notified about changes.
listener - the listener to addpublic void cleanInventory(int tag)
tag - the item tag@NotNull private java.util.List<CfItem> getInventoryByTag(int tag)
tag - the item's tag
@Nullable
public CfItem getInventoryItem(int tag,
int index)
CfItem from the inventory of an item.
tag - the item's tagindex - the index of the inventory item to return
null if the index does not
exist@Nullable public CfItem getItemByTag(int tag)
tag - the tag
null if no such items exists@Nullable private CfItem getItemOrPlayer(int tag)
tag - The tag.
null if no such item exists@NotNull public java.util.List<CfItem> getItemsByLocation(int location)
location - the location
public int getNumberOfItemsByLocation(int location)
0.
location - the location to check
public int getOpenContainer()
@Nullable public CfItem getPlayer()
@NotNull public java.lang.Iterable<CfItem> getPlayerInventory()
public void removeInventoryListener(int tag,
@NotNull
ItemListener listener)
ItemListener to be notified about changes.
tag - the item tag to watchlistener - the listener to add
private int removeItemByTag(int tag,
boolean notifyListeners)
CfItem.
tag - the item's tag to removenotifyListeners - whether listeners should be notified about the
removal
-1
public void removeItems(@NotNull
int[] tags)
tags - the tags to delete
public void removeItemSetListener(@NotNull
ItemSetListener listener)
ItemSetListener to be notified about changes.
listener - the listener to removepublic void reset()
private void setOpenContainer(int openContainerFloor)
openContainerFloor - the opened container's tag or 0
public void setPlayer(@Nullable
CfItem player)
player - the new player object
public void updateItem(int flags,
int tag,
int valLocation,
int valFlags,
int valWeight,
Face valFace,
@NotNull
java.lang.String valName,
@NotNull
java.lang.String valNamePl,
int valAnim,
int valAnimSpeed,
int valNrof)
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