Package net.eternalclient.api.containers
Class LootingBag
- java.lang.Object
-
- net.eternalclient.api.containers.LootingBag
-
public class LootingBag extends java.lang.Object
A class representing a looting bag with methods to interact with its cache and contents.
-
-
Constructor Summary
Constructors Constructor Description LootingBag()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.util.List<Item>
all()
Retrieves a list of all non-null items in the cache with valid IDs.static void
clear()
Clears the looting bag cache by filling it with null values.static boolean
closeContainer()
Closes the container.static boolean
contains(int... ids)
Checks if any of the given IDs are present in the list of items.static boolean
contains(java.lang.String... names)
Returns true if any of the specified names is found in the list of all Items.static boolean
contains(java.util.function.Predicate<Item> predicate)
Returns true if any item in the collection satisfies the specified predicate, false otherwise.static boolean
contains(Item... items)
Returns true if any of the given items is present in the inventory.static boolean
containsAll(int... ids)
Checks if the given list of item IDs are all present in the list of items.static boolean
containsAll(java.lang.String... names)
Checks if all given names are present in the list of items.static boolean
containsAll(Item... checkItems)
Checks if all the given items are present in the list of items, returning true if all items are present and false otherwise.static int
count(int... ids)
Counts the total number of items with the inputted IDs.static int
count(java.lang.String... names)
Returns the total count of items with the given names, taking into account stackable items.static int
count(java.util.function.Predicate<Item> predicate)
Counts the number of items that satisfy the given Predicate.static boolean
depositLoot()
Deposits the loot from a widget event.static int
emptySlotCount()
Returns the count of empty slots by subtracting the size of all elements from the total size.static java.util.List<Item>
except(java.util.function.Predicate<Item> predicate)
Returns a list of items that do not satisfy the given predicate.static int
fullSlotCount()
Returns the total number of full slots.static Item
get(int id)
Retrieves the item with the specified ID.static Item
get(java.lang.String name)
Retrieves an Item object by its name.static Item
get(java.util.function.Predicate<Item> predicate)
Returns the first Item from the collection that matches the given predicate, or null if no match is found.static int
getValue()
Retrieves the value from the specified WidgetChild as an integer.static boolean
isBagOpen()
Checks if the bag is open.static boolean
isCached()
static boolean
isContainerOpen()
Checks if the container is open.static boolean
isEmpty()
Checks if the result of the 'all' method is empty.static boolean
isFull()
Checks if the list is full.static boolean
onlyContains(int... ids)
Checks if all the items in the "all" collection have the same ID as any of the given IDs.static boolean
onlyContains(java.lang.String... names)
Checks if all items' names are equal to the given names.static boolean
onlyContains(java.util.function.Predicate<Item> predicate)
Checks if all items from the all() method satisfy the given predicate.static void
setCache(int index, int id, int count)
Sets the cache at the specified index with the given id and count.
-
-
-
Method Detail
-
isCached
public static boolean isCached()
-
setCache
public static void setCache(int index, int id, int count)
Sets the cache at the specified index with the given id and count. If the cache already exists at the index, it updates the item with the new id and count; otherwise, creates a new cache entry with the given id, count, and widgetIDs array.- Parameters:
index
- the index of the cache entryid
- the ID of the itemcount
- the count of the item
-
clear
public static void clear()
Clears the looting bag cache by filling it with null values.
-
all
public static java.util.List<Item> all()
Retrieves a list of all non-null items in the cache with valid IDs.- Returns:
- A list of items.
-
isBagOpen
public static boolean isBagOpen()
Checks if the bag is open.- Returns:
- true if the bag is open, false otherwise
-
isContainerOpen
public static boolean isContainerOpen()
Checks if the container is open.- Returns:
- true if the container is open and visible, false otherwise.
-
getValue
public static int getValue()
Retrieves the value from the specified WidgetChild as an integer.- Returns:
- the value as an integer, or 0 if the WidgetChild is null or if parsing fails.
-
depositLoot
public static boolean depositLoot()
Deposits the loot from a widget event.- Returns:
- true if the loot was successfully deposited, otherwise false.
-
closeContainer
public static boolean closeContainer()
Closes the container.- Returns:
- true if the container is successfully closed, false otherwise.
-
isFull
public static boolean isFull()
Checks if the list is full.- Returns:
- true if the list is full, false otherwise.
-
isEmpty
public static boolean isEmpty()
Checks if the result of the 'all' method is empty.- Returns:
- true if the result is empty, false otherwise.
-
get
public static Item get(int id)
Retrieves the item with the specified ID.- Parameters:
id
- the ID of the item to retrieve- Returns:
- the item with the specified ID, or null if not found
-
get
public static Item get(java.lang.String name)
Retrieves an Item object by its name.- Parameters:
name
- the name of the Item to be retrieved- Returns:
- the Item object with the specified name, or null if not found
-
get
public static Item get(java.util.function.Predicate<Item> predicate)
Returns the first Item from the collection that matches the given predicate, or null if no match is found.- Parameters:
predicate
- the condition to match against the Item elements- Returns:
- the first Item that satisfies the predicate, or null if no match is found
-
count
public static int count(int... ids)
Counts the total number of items with the inputted IDs.- Parameters:
ids
- an array of item IDs- Returns:
- the total count of items with the inputted IDs
-
count
public static int count(java.lang.String... names)
Returns the total count of items with the given names, taking into account stackable items.- Parameters:
names
- an array of names to search for- Returns:
- the count of items found
-
count
public static int count(java.util.function.Predicate<Item> predicate)
Counts the number of items that satisfy the given Predicate.- Parameters:
predicate
- the Predicate to be applied to each Item- Returns:
- the count of items that meet the Predicate's condition
-
contains
public static boolean contains(Item... items)
Returns true if any of the given items is present in the inventory.- Parameters:
items
- the items to check if are present in the inventory- Returns:
- true if any of the items is present in the inventory, false otherwise
-
contains
public static boolean contains(int... ids)
Checks if any of the given IDs are present in the list of items.- Parameters:
ids
- The IDs to check.- Returns:
- true if any ID is found, false otherwise.
-
contains
public static boolean contains(java.lang.String... names)
Returns true if any of the specified names is found in the list of all Items.- Parameters:
names
- an array of strings representing the names to search for- Returns:
- true if at least one of the names is found, false otherwise
-
contains
public static boolean contains(java.util.function.Predicate<Item> predicate)
Returns true if any item in the collection satisfies the specified predicate, false otherwise.- Parameters:
predicate
- the predicate function to apply to each item- Returns:
- true if any item satisfies the predicate, false otherwise
-
containsAll
public static boolean containsAll(Item... checkItems)
Checks if all the given items are present in the list of items, returning true if all items are present and false otherwise.- Parameters:
checkItems
- the items to check if they are present in the list- Returns:
- true if all items are present, false otherwise
-
containsAll
public static boolean containsAll(int... ids)
Checks if the given list of item IDs are all present in the list of items.- Parameters:
ids
- the list of item IDs to check- Returns:
- true if all item IDs are present, false otherwise
-
containsAll
public static boolean containsAll(java.lang.String... names)
Checks if all given names are present in the list of items.- Parameters:
names
- the names to check- Returns:
- true if all names are present, false otherwise
-
onlyContains
public static boolean onlyContains(int... ids)
Checks if all the items in the "all" collection have the same ID as any of the given IDs.- Parameters:
ids
- The IDs to compare against the items in the "all" collection.- Returns:
- true if all the items have the same ID as any of the given IDs, false otherwise.
-
onlyContains
public static boolean onlyContains(java.lang.String... names)
Checks if all items' names are equal to the given names.- Parameters:
names
- the names to compare against- Returns:
- true if all item names equal the given names, false otherwise
-
onlyContains
public static boolean onlyContains(java.util.function.Predicate<Item> predicate)
Checks if all items from the all() method satisfy the given predicate.- Parameters:
predicate
- the predicate used to test the items- Returns:
- true if all items satisfy the predicate, false otherwise
-
fullSlotCount
public static int fullSlotCount()
Returns the total number of full slots.- Returns:
- the number of full slots.
-
emptySlotCount
public static int emptySlotCount()
Returns the count of empty slots by subtracting the size of all elements from the total size.- Returns:
- the count of empty slots.
-
except
public static java.util.List<Item> except(java.util.function.Predicate<Item> predicate)
Returns a list of items that do not satisfy the given predicate.- Parameters:
predicate
- the condition that determines whether an item should be excluded- Returns:
- a list of items that do not satisfy the predicate
-
-