Class Trade
- java.lang.Object
-
- net.eternalclient.api.wrappers.trade.Trade
-
public class Trade extends java.lang.Object
This class provides methods to interact with the trading system.
-
-
Constructor Summary
Constructors Constructor Description Trade()
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static boolean
acceptTrade()
Accepts a trade by checking if the trade screen is open and executing the "Accept" widget event.static boolean
acceptTrade(Screen screen)
Checks if the trade is accepted by clicking on the accept button in the trade screen.static boolean
addItem(int itemId, int amount)
Adds an item to the trade interface.static boolean
addItem(java.lang.String itemName, int amount)
Adds a specified item with a specified amount to the trade window.static boolean
addItem(java.util.function.Predicate<Item> predicate, int amount)
Adds an item to the trade with the specified condition and amount.static boolean
addItem(Item item, int amount)
Adds an item to the trade window with the given amount.static java.util.List<Item>
all(boolean mine)
static java.util.List<Item>
all(boolean mine, int... ids)
static java.util.List<Item>
all(boolean mine, java.lang.String... names)
static java.util.List<Item>
all(boolean mine, java.util.function.Predicate<Item> predicate)
static java.util.List<Item>
all(boolean mine, Item... items)
static java.util.List<Item>
all(boolean mine, ItemVariant itemVariant)
static java.util.List<Item>
allExcept(boolean mine, int... ids)
static java.util.List<Item>
allExcept(boolean mine, java.lang.String... names)
static java.util.List<Item>
allExcept(boolean mine, java.util.function.Predicate<Item> predicate)
static java.util.List<Item>
allExcept(boolean mine, Item... items)
static java.util.List<Item>
allExcept(boolean mine, ItemVariant itemVariant)
static boolean
close()
Closes the currently opened screen widget if one exists.static boolean
close(Screen screen)
Closes the given screen by executing a "Close" event on the close widget.static boolean
contains(boolean mine, int id)
static boolean
contains(boolean mine, int... ids)
static boolean
contains(boolean mine, java.lang.String name)
static boolean
contains(boolean mine, java.lang.String... names)
static boolean
contains(boolean mine, java.util.function.Predicate<Item> predicate)
static boolean
contains(boolean mine, Item item)
static boolean
contains(boolean mine, Item... items)
static boolean
contains(boolean mine, ItemVariant itemVariant)
static boolean
containsAll(boolean mine, int id)
static boolean
containsAll(boolean mine, int... ids)
static boolean
containsAll(boolean mine, java.lang.String name)
static boolean
containsAll(boolean mine, java.lang.String... names)
static boolean
containsAll(boolean mine, java.util.function.Predicate<Item> predicate)
static boolean
containsAll(boolean mine, Item item)
static boolean
containsAll(boolean mine, Item... items)
static boolean
containsAll(boolean mine, ItemVariant itemVariant)
static int
count(boolean mine, int id)
static int
count(boolean mine, int... ids)
static int
count(boolean mine, java.lang.String name)
static int
count(boolean mine, java.lang.String... names)
static int
count(boolean mine, java.util.function.Predicate<Item> predicate)
static int
count(boolean mine, Item item)
static int
count(boolean mine, Item... items)
static int
count(boolean mine, ItemVariant itemVariant)
static boolean
declineTrade()
Declines the trade request.static boolean
declineTrade(Screen screen)
Declines a trade window by clicking the decline button.static int
find(boolean mine, int... ids)
static int
find(boolean mine, int[] ids, int defaultValue)
static int
find(boolean mine, java.lang.String... names)
static int
find(boolean mine, java.lang.String[] names, int defaultValue)
static int
find(boolean mine, java.util.function.Predicate<Item> predicate)
static int
find(boolean mine, java.util.function.Predicate<Item> predicate, int defaultValue)
static int
find(boolean mine, ItemVariant variant)
static int
find(boolean mine, ItemVariant variant, int defaultValue)
static Item
get(boolean mine, int id)
static Item
get(boolean mine, java.lang.String name)
static Item
get(boolean mine, java.util.function.Predicate<Item> predicate)
static Item
get(boolean mine, ItemVariant itemVariant)
static Item
getItem(boolean myScreen, int itemId)
Deprecated.static Item
getItem(boolean myScreen, java.lang.String itemName)
Deprecated.static Item
getItem(boolean myScreen, java.util.function.Predicate<Item> predicate)
Deprecated.static Item
getItem(boolean myScreen, Item item)
Deprecated.static java.util.List<Item>
getItems(boolean mine)
Deprecated.static java.util.List<Item>
getMyItems()
Returns a list of the current player's items.static java.util.List<Item>
getTheirItems()
Retrieves the list of items offered by the other player in a trade.static java.lang.String
getTradingWith()
Returns the name of the player the user is currently trading with, if any.static boolean
hasAccepted()
Checks if the trade has been accepted.static boolean
isOpen()
Checks if the Trade screen is currently open.static boolean
isOpen(Screen screen)
Checks if the given screen is open.static boolean
isWaiting()
Checks if the bot is currently waiting for a specific trade status.static boolean
onlyContains(boolean mine, int id)
static boolean
onlyContains(boolean mine, int... ids)
static boolean
onlyContains(boolean mine, java.lang.String name)
static boolean
onlyContains(boolean mine, java.lang.String... names)
static boolean
onlyContains(boolean mine, java.util.function.Predicate<Item> predicate)
static boolean
onlyContains(boolean mine, Item item)
static boolean
onlyContains(boolean mine, Item... items)
static boolean
onlyContains(boolean mine, ItemVariant itemVariant)
static boolean
removeItem(int itemId, int amount)
Removes a specified item from the trade with the given item ID and amount.static boolean
removeItem(java.lang.String itemName, int amount)
Removes a specified amount of an item from the trade.static boolean
removeItem(java.util.function.Predicate<Item> predicate, int amount)
Removes a specified amount of items from the trade based on a given predicate.static boolean
removeItem(Item item, int amount)
Removes the specified amount of the given item from the trade.static boolean
tradeWithPlayer(java.lang.String playerName)
Finds the closest player with the given name and initiates a trade with them.static boolean
verifyTrade(boolean myScreen, java.util.List<Item> expected)
Deprecated.
-
-
-
Method Detail
-
acceptTrade
public static boolean acceptTrade()
Accepts a trade by checking if the trade screen is open and executing the "Accept" widget event.- Returns:
- true if the trade is successfully accepted, false otherwise.
-
acceptTrade
public static boolean acceptTrade(Screen screen)
Checks if the trade is accepted by clicking on the accept button in the trade screen.- Parameters:
screen
- the current screen- Returns:
- true if the accept button is successfully clicked, false otherwise
-
addItem
public static boolean addItem(int itemId, int amount)
Adds an item to the trade interface.- Parameters:
itemId
- the id of the item to be addedamount
- the amount of the item to be added- Returns:
- true if the item was successfully added, false otherwise
-
addItem
public static boolean addItem(Item item, int amount)
Adds an item to the trade window with the given amount.- Parameters:
item
- the item to be added to the trade windowamount
- the amount of the item to be added- Returns:
- true if the item is successfully added to the trade window, otherwise false
-
addItem
public static boolean addItem(java.lang.String itemName, int amount)
Adds a specified item with a specified amount to the trade window.- Parameters:
itemName
- the name of the item to be addedamount
- the amount of the item to be added- Returns:
- true if the item was successfully added, false otherwise
-
addItem
public static boolean addItem(java.util.function.Predicate<Item> predicate, int amount)
Adds an item to the trade with the specified condition and amount.- Parameters:
predicate
- the condition to match the itemamount
- the amount of the item to add- Returns:
- true if the item was added successfully, false otherwise
-
close
public static boolean close()
Closes the currently opened screen widget if one exists.- Returns:
- true if the close action was executed successfully, false otherwise.
-
close
public static boolean close(Screen screen)
Closes the given screen by executing a "Close" event on the close widget.- Parameters:
screen
- the screen to be closed- Returns:
true
if the screen was successfully closed,false
otherwise
-
declineTrade
public static boolean declineTrade()
Declines the trade request.- Returns:
true
if the trade request was declined successfully,false
otherwise.
-
declineTrade
public static boolean declineTrade(Screen screen)
Declines a trade window by clicking the decline button.- Parameters:
screen
- the current screen to execute the action on- Returns:
- true if the trade was successfully declined, false otherwise
-
getItem
@Deprecated public static Item getItem(boolean myScreen, int itemId)
Deprecated.Retrieves an Item by its ID from a list of items.- Parameters:
myScreen
- a boolean value indicating whether the item is on the player's screenitemId
- the ID of the item to retrieve- Returns:
- the Item with the specified ID, or null if not found
-
getItem
@Deprecated public static Item getItem(boolean myScreen, java.lang.String itemName)
Deprecated.Retrieves an item with the specified name from the current screen.- Parameters:
myScreen
- a boolean value indicating whether the item is on the player's screenitemName
- the name of the item to search for- Returns:
- the item with the specified name if found, or null otherwise
-
getItem
@Deprecated public static Item getItem(boolean myScreen, java.util.function.Predicate<Item> predicate)
Deprecated.Retrieves and returns an item from the Trade screen that satisfies the given condition, if any.- Parameters:
myScreen
- true if the item is from the player's screen, false if it's from the opponent's screenpredicate
- the condition to be satisfied by the item- Returns:
- the first item found on the Trade screen that satisfies the given condition, or null if none is found
-
getItem
@Deprecated public static Item getItem(boolean myScreen, Item item)
Deprecated.Retrieves an Item object from a list of items based on a specified ID.- Parameters:
myScreen
- true if the item is on my screen, false otherwiseitem
- the Item object to retrieve- Returns:
- the Item object matching the specified ID, or null if not found
-
getItems
@Deprecated public static java.util.List<Item> getItems(boolean mine)
Deprecated.Retrieves a list of items from the trade screen.- Parameters:
mine
- true if retrieving the items from the player's inventory, false if retrieving from the other player's inventory- Returns:
- a list of Item objects representing the items on the trade screen
-
getMyItems
public static java.util.List<Item> getMyItems()
Returns a list of the current player's items.- Returns:
- a list of the current player's items.
-
getTheirItems
public static java.util.List<Item> getTheirItems()
Retrieves the list of items offered by the other player in a trade.- Returns:
- The list of items offered by the other player
-
getTradingWith
public static java.lang.String getTradingWith()
Returns the name of the player the user is currently trading with, if any.- Returns:
- the name of the trading partner, or an empty string if not trading
-
isOpen
public static boolean isOpen()
Checks if the Trade screen is currently open.- Returns:
- true if the Trade screen is open, false otherwise.
-
isOpen
public static boolean isOpen(Screen screen)
Checks if the given screen is open.- Parameters:
screen
- the screen to check- Returns:
- true if the screen is open, false otherwise
-
removeItem
public static boolean removeItem(int itemId, int amount)
Removes a specified item from the trade with the given item ID and amount.- Parameters:
itemId
- the ID of the item to remove from the tradeamount
- the amount of the item to remove from the trade- Returns:
- true if the item was successfully removed from the trade, false otherwise
-
removeItem
public static boolean removeItem(java.util.function.Predicate<Item> predicate, int amount)
Removes a specified amount of items from the trade based on a given predicate.- Parameters:
predicate
- the condition that determines which items to removeamount
- the number of items to remove- Returns:
- true if the items were successfully removed, false otherwise
-
removeItem
public static boolean removeItem(Item item, int amount)
Removes the specified amount of the given item from the trade.- Parameters:
item
- the item to be removed from the tradeamount
- the amount of the item to be removed- Returns:
- true if the item was successfully removed, false otherwise
-
removeItem
public static boolean removeItem(java.lang.String itemName, int amount)
Removes a specified amount of an item from the trade.- Parameters:
itemName
- the name of the item to be removedamount
- the amount of the item to be removed- Returns:
- true if the item was successfully removed, false otherwise
-
tradeWithPlayer
public static boolean tradeWithPlayer(java.lang.String playerName)
Finds the closest player with the given name and initiates a trade with them.- Parameters:
playerName
- the name of the player to trade with- Returns:
- true if the trade is successfully initiated, false otherwise
-
hasAccepted
public static boolean hasAccepted()
Checks if the trade has been accepted.- Returns:
- true if the trade has been accepted, false otherwise.
-
isWaiting
public static boolean isWaiting()
Checks if the bot is currently waiting for a specific trade status.- Returns:
- true if the bot is waiting for a trade, otherwise false.
-
verifyTrade
@Deprecated public static boolean verifyTrade(boolean myScreen, java.util.List<Item> expected)
Deprecated.Verifies if the trade is correct by comparing the items displayed on the trade screen with the expected items.- Parameters:
myScreen
- true if it's the player's screen, false if it's the opponent's screenexpected
- a list of Item objects representing the expected items on the trade screen- Returns:
- true if the trade is verified, false otherwise
-
get
public static Item get(boolean mine, int id)
-
get
public static Item get(boolean mine, java.lang.String name)
-
get
public static Item get(boolean mine, ItemVariant itemVariant)
-
all
public static java.util.List<Item> all(boolean mine)
-
all
public static java.util.List<Item> all(boolean mine, int... ids)
-
all
public static java.util.List<Item> all(boolean mine, java.lang.String... names)
-
all
public static java.util.List<Item> all(boolean mine, ItemVariant itemVariant)
-
all
public static java.util.List<Item> all(boolean mine, java.util.function.Predicate<Item> predicate)
-
allExcept
public static java.util.List<Item> allExcept(boolean mine, int... ids)
-
allExcept
public static java.util.List<Item> allExcept(boolean mine, java.lang.String... names)
-
allExcept
public static java.util.List<Item> allExcept(boolean mine, ItemVariant itemVariant)
-
allExcept
public static java.util.List<Item> allExcept(boolean mine, java.util.function.Predicate<Item> predicate)
-
find
public static int find(boolean mine, int... ids)
-
find
public static int find(boolean mine, int[] ids, int defaultValue)
-
find
public static int find(boolean mine, ItemVariant variant)
-
find
public static int find(boolean mine, ItemVariant variant, int defaultValue)
-
find
public static int find(boolean mine, java.lang.String... names)
-
find
public static int find(boolean mine, java.lang.String[] names, int defaultValue)
-
find
public static int find(boolean mine, java.util.function.Predicate<Item> predicate)
-
find
public static int find(boolean mine, java.util.function.Predicate<Item> predicate, int defaultValue)
-
count
public static int count(boolean mine, int id)
-
count
public static int count(boolean mine, int... ids)
-
count
public static int count(boolean mine, java.lang.String name)
-
count
public static int count(boolean mine, java.lang.String... names)
-
count
public static int count(boolean mine, Item item)
-
count
public static int count(boolean mine, Item... items)
-
count
public static int count(boolean mine, ItemVariant itemVariant)
-
count
public static int count(boolean mine, java.util.function.Predicate<Item> predicate)
-
contains
public static boolean contains(boolean mine, int id)
-
contains
public static boolean contains(boolean mine, int... ids)
-
contains
public static boolean contains(boolean mine, java.lang.String name)
-
contains
public static boolean contains(boolean mine, java.lang.String... names)
-
contains
public static boolean contains(boolean mine, Item item)
-
contains
public static boolean contains(boolean mine, Item... items)
-
contains
public static boolean contains(boolean mine, ItemVariant itemVariant)
-
contains
public static boolean contains(boolean mine, java.util.function.Predicate<Item> predicate)
-
containsAll
public static boolean containsAll(boolean mine, int id)
-
containsAll
public static boolean containsAll(boolean mine, int... ids)
-
containsAll
public static boolean containsAll(boolean mine, java.lang.String name)
-
containsAll
public static boolean containsAll(boolean mine, java.lang.String... names)
-
containsAll
public static boolean containsAll(boolean mine, Item item)
-
containsAll
public static boolean containsAll(boolean mine, Item... items)
-
containsAll
public static boolean containsAll(boolean mine, ItemVariant itemVariant)
-
containsAll
public static boolean containsAll(boolean mine, java.util.function.Predicate<Item> predicate)
-
onlyContains
public static boolean onlyContains(boolean mine, int id)
-
onlyContains
public static boolean onlyContains(boolean mine, int... ids)
-
onlyContains
public static boolean onlyContains(boolean mine, java.lang.String name)
-
onlyContains
public static boolean onlyContains(boolean mine, java.lang.String... names)
-
onlyContains
public static boolean onlyContains(boolean mine, Item item)
-
onlyContains
public static boolean onlyContains(boolean mine, Item... items)
-
onlyContains
public static boolean onlyContains(boolean mine, ItemVariant itemVariant)
-
onlyContains
public static boolean onlyContains(boolean mine, java.util.function.Predicate<Item> predicate)
-
-