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 TypeMethodDescriptionintcheckIsSelected(RSWidgetItem[] comps) Uses a callback to get the last drawn image and then performs the method getSelected to update the isSelectedValuebooleanLeft-clicks on the selected item.booleanclickSelectedItem(boolean leftClick) Clicks selected inventory item, if it's selected.booleancontains(int itemID) Checks whether your inventory contains the provided item ID.booleanChecks whether your inventory contains the provided item name.booleancontainsAll(int... itemID) Checks whether your inventory contains all of the provided item IDs.booleancontainsAll(String... names) Checks whether your inventory contains all of the provided item IDs.booleancontainsOneOf(int... itemID) Checks whether your inventory contains at least one of the provided item IDs.booleancontainsOneOf(String... names) Checks whether your inventory contains at least one of the provided item names.booleandestroyItem(int itemID) Destroys any inventory items with the given ID.booleandestroyItem(String name) Destroys any inventory items with the given name.voiddropAllExcept(boolean leftToRight, int... items) Drops all items with the same specified id.voiddropAllExcept(boolean leftToRight, String... names) Drops all items with the specified names.booleandropAllExcept(int... items) Drops all items with the same specified id.booleandropAllExcept(String... names) Drops all items with the specified names.booleandropItem(int col, int row) Drops the item in the specified column and row.RSItem[]RSItem[]Gets all the items in the inventory.intgetCount()Gets the count of all items in your inventory ignoring stack sizes.intgetCount(boolean includeStacks) Gets the count of all items in your inventory.intgetCount(boolean includeStacks, int... itemIDs) Gets the count of all the items in the inventory with the any of the specified IDs.intGets the count of all the items in the inventory with the any of the specified names.intgetCount(int... itemIDs) Gets the count of all the items in the inventory with the any of the specified IDs.intGets the count of all the items in the inventory with the any of the specified names.intgetCountExcept(boolean includeStacks, int... ids) Gets the count of all the items in the inventory without any of the provided IDs.intgetCountExcept(boolean includeStacks, String... names) Gets the count of all the items in the inventory without any of the provided names.intgetCountExcept(int... ids) Gets the count of all the items in the inventory without any of the provided IDs.intgetCountExcept(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.intGets 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.intgetSelected(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.intGets the selected item index.Gets the selected item name.booleanisFull()Checks whether your inventory is full.booleanChecks whether an inventory item is selected.booleanitemHasAction(RSItem item, String action) Determines if the item contains the desired action.randomizeItemPoint(Point inventoryPoint) Randomizes a point.booleanselectItem(int itemID) Selects the first item in the inventory with the provided ID.booleanselectItem(String name) Selects the first item in the inventory with the provided name.booleanselectItem(RSItem item) Selects the specified item in the inventorybooleanuseItem(int itemID, int targetID) Uses two items together.booleanUses an item on an object.booleanUses two items together.booleanUses an item on an object.booleanUses two items together.booleanUses 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:
trueif the items were destroyed; otherwisefalse.
-
destroyItem
Destroys any inventory items with the given name.- Parameters:
name- The name of items to destroy.- Returns:
trueif the items were destroyed; otherwisefalse.
-
dropAllExcept
public void dropAllExcept(boolean leftToRight, int... items) Drops all items with the same specified id.- Parameters:
leftToRight-trueto drop items from left to right.items- The item IDs to drop
-
dropAllExcept
Drops all items with the specified names.- Parameters:
leftToRight-trueto 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:
trueif 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:
trueat 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:
trueat 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:
trueif we tried to drop the item,falseif 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:
trueif 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:
trueif 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:
trueif 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:
trueif 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:
trueif 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:
trueif inventory contains one of the specified items; otherwisefalse.- See Also:
-
isFull
public boolean isFull()Checks whether your inventory is full.- Returns:
trueif your inventory contains 28 items; otherwisefalse.
-
isItemSelected
public boolean isItemSelected()Checks whether an inventory item is selected.- Returns:
trueif 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:
trueif 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:
trueif the item was selected; otherwisefalse.
-
selectItem
Selects the specified item in the inventory- Parameters:
item- The item to select.- Returns:
trueif 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:
trueif 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:
trueif 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:
trueif 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:
trueif 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:
trueif 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:
trueif 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
Pointfrom 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
nullif none is selected.
-
clickSelectedItem
public boolean clickSelectedItem(boolean leftClick) Clicks selected inventory item, if it's selected.- Parameters:
leftClick-truefor left button click,falsefor right button.- Returns:
trueif item was selected,falseif not.
-
clickSelectedItem
public boolean clickSelectedItem()Left-clicks on the selected item.- Returns:
trueif item was selected,falseif not.- See Also:
-
getItemAt
Gets inventory item at specified index.- Parameters:
index- The index of inventory item.- Returns:
- The item, or
nullif not found.
-
getItems
Gets all the items in the inventory.- Returns:
RSItemarray 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:
RSItemarray of the matching inventory items.
-
getItems
Gets all the items in the inventory matching any of the provided names.- Parameters:
names- Valid IDs.- Returns:
RSItemarray 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:
RSItemarray 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
RSItemfor 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
RSItemfor 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-trueto count the stack sizes of each item;falseto 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-trueto count the stack sizes of each item;falseto 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-trueto count the stack sizes of each item;falseto 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-trueto count the stack sizes of each item;falseto 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-falseif stacked items should be counted as a single item; otherwisetrue.- Returns:
- The count.
-