Package rsb.methods
Class Inventory
java.lang.Object
rsb.methods.MethodProvider
rsb.methods.Inventory
Inventory related operations.
- Author:
- GigiaJ
-
Field Summary
Fields inherited from class rsb.methods.MethodProvider
methods
-
Method Summary
Modifier and TypeMethodDescriptionint
checkIsSelected
(RSWidgetItem[] comps) Uses a callback to get the last drawn image and then performs the method getSelected to update the isSelectedValueboolean
Left-clicks on the selected item.boolean
clickSelectedItem
(boolean leftClick) Clicks selected inventory item, if it's selected.boolean
contains
(int itemID) Checks whether your inventory contains the provided item ID.boolean
Checks whether your inventory contains the provided item name.boolean
containsAll
(int... itemID) Checks whether your inventory contains all of the provided item IDs.boolean
containsAll
(String... names) Checks whether your inventory contains all of the provided item IDs.boolean
containsOneOf
(int... itemID) Checks whether your inventory contains at least one of the provided item IDs.boolean
containsOneOf
(String... names) Checks whether your inventory contains at least one of the provided item names.boolean
destroyItem
(int itemID) Destroys any inventory items with the given ID.boolean
destroyItem
(String name) Destroys any inventory items with the given name.void
dropAllExcept
(boolean leftToRight, int... items) Drops all items with the same specified id.void
dropAllExcept
(boolean leftToRight, String... names) Drops all items with the specified names.boolean
dropAllExcept
(int... items) Drops all items with the same specified id.boolean
dropAllExcept
(String... names) Drops all items with the specified names.boolean
dropItem
(int col, int row) Drops the item in the specified column and row.RSItem[]
RSItem[]
Gets all the items in the inventory.int
getCount()
Gets the count of all items in your inventory ignoring stack sizes.int
getCount
(boolean includeStacks) Gets the count of all items in your inventory.int
getCount
(boolean includeStacks, int... itemIDs) Gets the count of all the items in the inventory with the any of the specified IDs.int
Gets the count of all the items in the inventory with the any of the specified names.int
getCount
(int... itemIDs) Gets the count of all the items in the inventory with the any of the specified IDs.int
Gets the count of all the items in the inventory with the any of the specified names.int
getCountExcept
(boolean includeStacks, int... ids) Gets the count of all the items in the inventory without any of the provided IDs.int
getCountExcept
(boolean includeStacks, String... names) Gets the count of all the items in the inventory without any of the provided names.int
getCountExcept
(int... ids) Gets the count of all the items in the inventory without any of the provided IDs.int
getCountExcept
(String... names) Gets the count of all the items in the inventory without any of the provided names.Gets the inventory interface.getItem
(int... ids) Gets the first item in the inventory with any of the provided IDs.Gets the first item in the inventory with any of the provided names.getItemAt
(int index) Gets inventory item at specified index.int
Gets the ID of an item in the inventory with a given name.int[]
getItemIDs
(String[] names) Gets the IDs of items in the inventory with given names.RSItem[]
getItems()
Gets all the items in the inventory.RSItem[]
getItems
(int... ids) Gets all the items in the inventory matching any of the provided IDs.RSItem[]
Gets all the items in the inventory matching any of the provided names.int
getSelected
(Image img, RSWidgetItem[] comps) Checks the image for the item position and then checks that set of bounds for any pure white pixels which would indicate that the item is selected (No items use 255, 255, 255) If it finds any the isSelected value is updated to trueGets the selected inventory item.int
Gets the selected item index.Gets the selected item name.boolean
isFull()
Checks whether your inventory is full.boolean
Checks whether an inventory item is selected.boolean
itemHasAction
(RSItem item, String action) Determines if the item contains the desired action.randomizeItemPoint
(Point inventoryPoint) Randomizes a point.boolean
selectItem
(int itemID) Selects the first item in the inventory with the provided ID.boolean
selectItem
(String name) Selects the first item in the inventory with the provided name.boolean
selectItem
(RSItem item) Selects the specified item in the inventoryboolean
useItem
(int itemID, int targetID) Uses two items together.boolean
Uses an item on an object.boolean
Uses two items together.boolean
Uses an item on an object.boolean
Uses two items together.boolean
Uses an item on an object.
-
Method Details
-
getInterface
Gets the inventory interface.- Returns:
- the inventory interface
-
destroyItem
public boolean destroyItem(int itemID) Destroys any inventory items with the given ID.- Parameters:
itemID
- The ID of items to destroy.- Returns:
true
if the items were destroyed; otherwisefalse
.
-
destroyItem
Destroys any inventory items with the given name.- Parameters:
name
- The name of items to destroy.- Returns:
true
if the items were destroyed; otherwisefalse
.
-
dropAllExcept
public void dropAllExcept(boolean leftToRight, int... items) Drops all items with the same specified id.- Parameters:
leftToRight
-true
to drop items from left to right.items
- The item IDs to drop
-
dropAllExcept
Drops all items with the specified names.- Parameters:
leftToRight
-true
to drop items from left to right.names
- The item names to drop
-
itemHasAction
Determines if the item contains the desired action.- Parameters:
item
- The item to check.action
- The item menu action to check.- Returns:
true
if the item has the action; otherwisefalse
.
-
dropAllExcept
public boolean dropAllExcept(int... items) Drops all items with the same specified id. This method drops items vertically going down the inventory.- Parameters:
items
- The item IDs to drop.- Returns:
true
at all times.- See Also:
-
dropAllExcept
Drops all items with the specified names. This method drops items vertically going down the inventory.- Parameters:
names
- The item names to drop.- Returns:
true
at all times.- See Also:
-
dropItem
public boolean dropItem(int col, int row) Drops the item in the specified column and row.- Parameters:
col
- The column the item is in.row
- The row the item is in.- Returns:
true
if we tried to drop the item,false
if not (e.g., if item is undroppable)
-
contains
public boolean contains(int itemID) Checks whether your inventory contains the provided item ID.- Parameters:
itemID
- The item(s) you wish to evaluate.- Returns:
true
if your inventory contains an item with the ID provided; otherwisefalse
.- See Also:
-
contains
Checks whether your inventory contains the provided item name.- Parameters:
name
- The name you wish to evaluate.- Returns:
true
if your inventory contains an item with the name provided; otherwisefalse
.- See Also:
-
containsAll
public boolean containsAll(int... itemID) Checks whether your inventory contains all of the provided item IDs.- Parameters:
itemID
- The item(s) you wish to evaluate.- Returns:
true
if your inventory contains at least one of all of the item IDs provided; otherwisefalse
.- See Also:
-
containsAll
Checks whether your inventory contains all of the provided item IDs.- Parameters:
names
- The item(s) you wish to evaluate.- Returns:
true
if your inventory contains at least one of all of the item IDs provided; otherwisefalse
.- See Also:
-
containsOneOf
public boolean containsOneOf(int... itemID) Checks whether your inventory contains at least one of the provided item IDs.- Parameters:
itemID
- The item ID to check for.- Returns:
true
if inventory contains one of the specified items; otherwisefalse
.- See Also:
-
containsOneOf
Checks whether your inventory contains at least one of the provided item names.- Parameters:
names
- The item names to check for.- Returns:
true
if inventory contains one of the specified items; otherwisefalse
.- See Also:
-
isFull
public boolean isFull()Checks whether your inventory is full.- Returns:
true
if your inventory contains 28 items; otherwisefalse
.
-
isItemSelected
public boolean isItemSelected()Checks whether an inventory item is selected.- Returns:
true
if an item in your inventory is selected; otherwisefalse
.
-
selectItem
public boolean selectItem(int itemID) Selects the first item in the inventory with the provided ID.- Parameters:
itemID
- The ID of the item to select.- Returns:
true
if the item was selected; otherwisefalse
.
-
selectItem
Selects the first item in the inventory with the provided name.- Parameters:
name
- The name of the item to select.- Returns:
true
if the item was selected; otherwisefalse
.
-
selectItem
Selects the specified item in the inventory- Parameters:
item
- The item to select.- Returns:
true
if the item was selected; otherwisefalse
.
-
useItem
Uses two items together.- Parameters:
item
- The item to use on another item.targetItem
- The item you want the first parameter to be used on.- Returns:
true
if the "use" action had been used on both items; otherwisefalse
.
-
useItem
public boolean useItem(int itemID, int targetID) Uses two items together.- Parameters:
itemID
- The first item ID to use.targetID
- The item ID you want the first parameter to be used on.- Returns:
true
if the first item has been "used" on the other; otherwisefalse
.
-
useItem
Uses two items together.- Parameters:
name
- The first item to use.targetName
- The item name you want the first parameter to be used on.- Returns:
true
if the first item has been "used" on the other; otherwisefalse
.
-
useItem
Uses an item on an object.- Parameters:
item
- The item to use on another item.targetObject
- The RSObject you want the first parameter to be used on.- Returns:
true
if the "use" action had been used on both the RSItem and RSObject; otherwisefalse
.
-
useItem
Uses an item on an object.- Parameters:
itemID
- The item ID to use on the object.object
- The RSObject you want the item to be used on.- Returns:
true
if the "use" action had been used on both the RSItem and RSObject; otherwisefalse
.
-
useItem
Uses an item on an object.- Parameters:
name
- The item name to use on the object.object
- The RSObject you want the item to be used on.- Returns:
true
if the "use" action had been used on both the RSItem and RSObject; otherwisefalse
.
-
randomizeItemPoint
Randomizes a point.- Parameters:
inventoryPoint
- The inventory point to be randomized.- Returns:
- A randomized
Point
from the center of the givenPoint
.
-
getSelectedItemName
Gets the selected item name.- Returns:
- The name of the current selected item, or null if none is selected.
-
getSelectedItemIndex
public int getSelectedItemIndex()Gets the selected item index.- Returns:
- The index of current selected item, or -1 if none is selected.
-
checkIsSelected
Uses a callback to get the last drawn image and then performs the method getSelected to update the isSelectedValue- Parameters:
comps
- the item to check if is selected- Returns:
- the index of the item selected; otherwise -1
-
getSelected
Checks the image for the item position and then checks that set of bounds for any pure white pixels which would indicate that the item is selected (No items use 255, 255, 255) If it finds any the isSelected value is updated to true- Parameters:
img
- the client imagecomps
- the item to check for if it is selected- Returns:
- the index of the item selected; otherwise -1
-
getSelectedItem
Gets the selected inventory item.- Returns:
- The current selected item, or
null
if none is selected.
-
clickSelectedItem
public boolean clickSelectedItem(boolean leftClick) Clicks selected inventory item, if it's selected.- Parameters:
leftClick
-true
for left button click,false
for right button.- Returns:
true
if item was selected,false
if not.
-
clickSelectedItem
public boolean clickSelectedItem()Left-clicks on the selected item.- Returns:
true
if item was selected,false
if not.- See Also:
-
getItemAt
Gets inventory item at specified index.- Parameters:
index
- The index of inventory item.- Returns:
- The item, or
null
if not found.
-
getItems
Gets all the items in the inventory.- Returns:
RSItem
array of the current inventory items or newRSItem[0]
.
-
getItems
Gets all the items in the inventory matching any of the provided IDs.- Parameters:
ids
- Valid IDs.- Returns:
RSItem
array of the matching inventory items.
-
getItems
Gets all the items in the inventory matching any of the provided names.- Parameters:
names
- Valid IDs.- Returns:
RSItem
array of the matching inventory items.
-
getCachedItems
Gets all the items in the inventory. If the tab is not currently open, it does not open it and returns the last known array of items in the tab.- Returns:
RSItem
array of the cached inventory items or newRSItem[0]
.
-
getItemID
Gets the ID of an item in the inventory with a given name.- Parameters:
name
- The name of the item you wish to find.- Returns:
- The ID of the item or -1 if not in inventory.
-
getItemIDs
Gets the IDs of items in the inventory with given names.- Parameters:
names
- The names of the item IDs you wish to find.- Returns:
- The IDs of the items or null if not in inventory.
-
getItem
Gets the first item in the inventory with any of the provided IDs.- Parameters:
ids
- The IDs of the item to find.- Returns:
- The first
RSItem
for the given IDs; otherwise null.
-
getItem
Gets the first item in the inventory with any of the provided names.- Parameters:
names
- The names of the item to find.- Returns:
- The first
RSItem
for the given names; otherwise null.
-
find
-
getCountExcept
public int getCountExcept(int... ids) Gets the count of all the items in the inventory without any of the provided IDs. This ignores stack sizes.- Parameters:
ids
- The item IDs to exclude.- Returns:
- The count.
-
getCountExcept
Gets the count of all the items in the inventory without any of the provided names. This ignores stack sizes.- Parameters:
names
- The item names to exclude.- Returns:
- The count.
-
getCountExcept
public int getCountExcept(boolean includeStacks, int... ids) Gets the count of all the items in the inventory without any of the provided IDs.- Parameters:
includeStacks
-true
to count the stack sizes of each item;false
to count a stack as a single item.ids
- The item IDs to exclude.- Returns:
- The count.
-
getCountExcept
Gets the count of all the items in the inventory without any of the provided names.- Parameters:
includeStacks
-true
to count the stack sizes of each item;false
to count a stack as a single item.names
- The item names to exclude.- Returns:
- The count.
-
getCount
public int getCount(int... itemIDs) Gets the count of all the items in the inventory with the any of the specified IDs. This ignores stack sizes.- Parameters:
itemIDs
- the item IDs to include- Returns:
- The count.
-
getCount
Gets the count of all the items in the inventory with the any of the specified names. This ignores stack sizes.- Parameters:
names
- the item names to include- Returns:
- The count.
-
getCount
public int getCount(boolean includeStacks, int... itemIDs) Gets the count of all the items in the inventory with the any of the specified IDs.- Parameters:
includeStacks
-true
to count the stack sizes of each item;false
to count a stack as a single item.itemIDs
- the item IDs to include- Returns:
- The count.
-
getCount
Gets the count of all the items in the inventory with the any of the specified names.- Parameters:
includeStacks
-true
to count the stack sizes of each item;false
to count a stack as a single item.names
- the item names to include- Returns:
- The count.
-
getCount
public int getCount()Gets the count of all items in your inventory ignoring stack sizes.- Returns:
- The count.
-
getCount
public int getCount(boolean includeStacks) Gets the count of all items in your inventory.- Parameters:
includeStacks
-false
if stacked items should be counted as a single item; otherwisetrue
.- Returns:
- The count.
-