Class ItemSet


  • public class ItemSet
    extends java.lang.Object
    Model class maintaining the CfItems known to the player.
    • Constructor Detail

      • ItemSet

        public ItemSet()
    • Method Detail

      • addItemSetListener

        public void addItemSetListener​(@NotNull
                                       @NotNull ItemSetListener listener)
        Adds an ItemSetListener to be notified about changes.
        Parameters:
        listener - the listener to add
      • removeItemSetListener

        public void removeItemSetListener​(@NotNull
                                          @NotNull ItemSetListener listener)
        Removes an ItemSetListener to be notified about changes.
        Parameters:
        listener - the listener to remove
      • addInventoryListener

        public void addInventoryListener​(int tag,
                                         @NotNull
                                         @NotNull ItemListener listener)
        Adds an ItemListener to be notified about changes.
        Parameters:
        tag - the item tag to watch
        listener - the listener to add
      • removeInventoryListener

        public void removeInventoryListener​(int tag,
                                            @NotNull
                                            @NotNull ItemListener listener)
        Removes an ItemListener to be notified about changes.
        Parameters:
        tag - the item tag to watch
        listener - 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 return 0.
        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 null if 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 values
        tag - the item's tag
        valLocation - the item's location
        valFlags - the item's flags
        valWeight - the item's weight
        valFace - the item's face
        valName - the item's singular name
        valNamePl - the item's plural name
        valAnim - the item's animation ID
        valAnimSpeed - the item's animation speed
        valNrof - 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

        @Nullable
        public @Nullable CfItem getInventoryItem​(int tag,
                                                 int index)
        Returns a CfItem from the inventory of an item.
        Parameters:
        tag - the item's tag
        index - the index of the inventory item to return
        Returns:
        the inventory item or null if the index does not exist