Package org.dreambot.api.methods.trade
Class Trade
- java.lang.Object
-
- org.dreambot.api.methods.trade.Trade
-
public class Trade extends java.lang.Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean
acceptTrade()
Accepts the trade based on which screen is currently openstatic boolean
acceptTrade(int tradeScreen)
Accepts trade based on which screen you're instatic boolean
addItem(int itemId, int amount)
Adds an item from your inventory to trade screen.static boolean
addItem(@NonNull java.lang.String itemName, int amount)
Adds an item from your inventory to trade screen.static boolean
addItem(@NonNull Item i, int amount)
Adds an item from your inventory to trade screen.static boolean
canAccept()
Checks if the Accept button is available to clickstatic boolean
close()
Closes screen based on which screen is currently openstatic boolean
close(int tradeScreen)
Closes trade screen depending on which screen you inputstatic boolean
contains(boolean myScreen, int @NonNull ... itemIds)
Checks if your or their trade screen contains all the specified item IDsstatic boolean
contains(boolean myScreen, int amount, int itemId)
Checks if your or their trade screen contains at least specified amount of specified item ID.static boolean
contains(boolean myScreen, int amount, @NonNull java.lang.String itemName)
Checks if your or their trade screen contains at least specified amount of specified item name.static boolean
contains(boolean myScreen, @NonNull java.lang.String... itemNames)
Checks if your or their trade screen contains all items specifiedstatic boolean
declineTrade()
Declines the trade based on which screen is currently openstatic boolean
declineTrade(int tradeScreen)
Declines trade for screen specifiedstatic @Nullable java.lang.String
getFirstTitle()
Gets the Title of the first trade screen - contains Trading With namestatic @Nullable Item
getItem(boolean myScreen, int itemId)
Returns the item from the specified screen with specified IDstatic @Nullable Item
getItem(boolean myScreen, @NonNull java.lang.String itemName)
Returns item specified from the screen with name specified.static @NonNull Item @Nullable []
getItems(boolean mine)
Returns an array of items from the trade screenstatic @NonNull Item @Nullable []
getMyItems()
Gets the items in your trade screenstatic @NonNull Item @Nullable []
getTheirItems()
Gets the items in the other player's trade screenstatic java.lang.String
getTradingWith()
Gets the name of the player you're trading with.static int
getValue(boolean myOffer)
Returns the value of the trade offerstatic boolean
hasAcceptedTrade(@NonNull TradeUser tradeUser)
Checks if the user specified has accepted the tradestatic boolean
isOpen()
Checks if trade is open at allstatic boolean
isOpen(int tradeScreen)
Checks if specified trade screen is openstatic boolean
removeItem(int itemId, int amount)
Removes an item from the trade screen.static boolean
removeItem(@NonNull java.lang.String itemName, int amount)
Removes an item from the trade screen.static boolean
removeItem(@NonNull Item i, int amount)
Removes an item from the trade screen.static @Nullable java.awt.Rectangle
slotBounds(int slot)
static boolean
tradeWithPlayer(@NonNull java.lang.String playerName)
Trades with player specifiedstatic boolean
tradeWithPlayer(@NonNull Player player)
Trades with player specifiedstatic boolean
verifyTrade(boolean myScreen, @NonNull Item[] expected)
Simply checks the given array of Items against the array of items in the screen - must be on the second trade screen
-
-
-
Method Detail
-
getItems
public static @NonNull Item @Nullable [] getItems(boolean mine)
Returns an array of items from the trade screen- Parameters:
mine
- true if you want your items, false if you want their items- Returns:
- An array of Items from the trade screen, or null if it's never held an item or if the trade screen is closed
-
getMyItems
public static @NonNull Item @Nullable [] getMyItems()
Gets the items in your trade screen- Returns:
- get an array of Items
-
getTheirItems
public static @NonNull Item @Nullable [] getTheirItems()
Gets the items in the other player's trade screen- Returns:
- an array of Items
-
isOpen
public static boolean isOpen()
Checks if trade is open at all- Returns:
- true if either trade screen is open
-
isOpen
public static boolean isOpen(int tradeScreen)
Checks if specified trade screen is open- Parameters:
tradeScreen
- 1 or 2- Returns:
- whether the trade screen is open
-
getFirstTitle
public static @Nullable java.lang.String getFirstTitle()
Gets the Title of the first trade screen - contains Trading With name- Returns:
- String
-
getTradingWith
public static java.lang.String getTradingWith()
Gets the name of the player you're trading with.- Returns:
- the other player's name
-
canAccept
public static boolean canAccept()
Checks if the Accept button is available to click- Returns:
- true if either trade screen is open and the button is available
-
acceptTrade
public static boolean acceptTrade()
Accepts the trade based on which screen is currently open- Returns:
- Whether interaction with the Accept Button was successful
-
acceptTrade
public static boolean acceptTrade(int tradeScreen)
Accepts trade based on which screen you're in- Parameters:
tradeScreen
- 1 or 2- Returns:
- whether interaction with the accept button was successful
-
hasAcceptedTrade
public static boolean hasAcceptedTrade(@NonNull TradeUser tradeUser)
Checks if the user specified has accepted the trade- Parameters:
tradeUser
- Which user to check for acceptance- Returns:
- true if they have accepted, false if they haven't or if the trade interface isn't open
-
declineTrade
public static boolean declineTrade()
Declines the trade based on which screen is currently open- Returns:
- Whether interaction with the Decline Button was successful
-
declineTrade
public static boolean declineTrade(int tradeScreen)
Declines trade for screen specified- Parameters:
tradeScreen
- 1 or 2- Returns:
- whether interaction with decline button was successful
-
close
public static boolean close()
Closes screen based on which screen is currently open- Returns:
- Whether interaction with the close button was successful or true if trade isn't even open
-
close
public static boolean close(int tradeScreen)
Closes trade screen depending on which screen you input- Parameters:
tradeScreen
- 1 or 2- Returns:
- whether interaction with the close button was successful
-
verifyTrade
public static boolean verifyTrade(boolean myScreen, @NonNull Item[] expected)
Simply checks the given array of Items against the array of items in the screen - must be on the second trade screen- Parameters:
myScreen
- true if your screen, false if theirsexpected
- array of items to check for- Returns:
- true if every item in expected is inside the trade screen, with equal amounts
-
contains
public static boolean contains(boolean myScreen, int amount, @NonNull java.lang.String itemName)
Checks if your or their trade screen contains at least specified amount of specified item name.- Parameters:
myScreen
- true if your screen, false if theirsamount
- amount to check foritemName
- item name to check for- Returns:
- Returns true if the specified screen contains GREATER THAN OR EQUAL TO of item with the specified name.
-
contains
public static boolean contains(boolean myScreen, @NonNull java.lang.String... itemNames)
Checks if your or their trade screen contains all items specified- Parameters:
myScreen
- true if your screen, false if theirsitemNames
- item names to check for- Returns:
- Returns true if specified screen contains all the specified item names
-
contains
public static boolean contains(boolean myScreen, int amount, int itemId)
Checks if your or their trade screen contains at least specified amount of specified item ID.- Parameters:
myScreen
- true if your screen, false if theirsamount
- amount to check foritemId
- item ID to check for- Returns:
- Returns true if the specified screen contains GREATER THAN OR EQUAL TO of item with specified ID.
-
contains
public static boolean contains(boolean myScreen, int @NonNull ... itemIds)
Checks if your or their trade screen contains all the specified item IDs- Parameters:
myScreen
- true if your screen, false if theirsitemIds
- item ID's to check for- Returns:
- Returns true if the specified screen contains all the specified item ID's
-
getValue
public static int getValue(boolean myOffer)
Returns the value of the trade offer- Parameters:
myOffer
- true for the value of your player's offer, false for the value of the other party- Returns:
- The value of the offer, or -1 if it's unavailable for any reason
-
getItem
public static @Nullable Item getItem(boolean myScreen, @NonNull java.lang.String itemName)
Returns item specified from the screen with name specified.- Parameters:
myScreen
- true if your screen, false if theirsitemName
- Item name- Returns:
- Item from specified screen with specified name.
-
getItem
public static @Nullable Item getItem(boolean myScreen, int itemId)
Returns the item from the specified screen with specified ID- Parameters:
myScreen
- true if your screen, false if theirsitemId
- ID of the item you're looking for- Returns:
- Item from specified screen with specified ID
-
tradeWithPlayer
public static boolean tradeWithPlayer(@NonNull java.lang.String playerName)
Trades with player specified- Parameters:
playerName
- name of player to trade with- Returns:
- whether interaction with player was successful or trade is already opened
-
tradeWithPlayer
public static boolean tradeWithPlayer(@NonNull Player player)
Trades with player specified- Parameters:
player
- player to trade with- Returns:
- whether interaction with player was successful or trade is already opened
-
addItem
public static boolean addItem(@NonNull java.lang.String itemName, int amount)
Adds an item from your inventory to trade screen. If the amount is greater than or equal to your current inventory amount, it puts all in.- Parameters:
itemName
- name of item to addamount
- amount of item to add- Returns:
- returns whether interaction with item was successful
-
addItem
public static boolean addItem(int itemId, int amount)
Adds an item from your inventory to trade screen. If the amount is greater than or equal to your current inventory amount, it puts all in.- Parameters:
itemId
- ID of item to addamount
- amount of item to add- Returns:
- returns whether interaction with item was successful
-
addItem
public static boolean addItem(@NonNull Item i, int amount)
Adds an item from your inventory to trade screen. If the amount is greater than or equal to your current inventory amount, it puts all in.- Parameters:
i
- Item to addamount
- amount of item to add- Returns:
- returns whether interaction with item was successful
-
removeItem
public static boolean removeItem(@NonNull java.lang.String itemName, int amount)
Removes an item from the trade screen. If the amount is greater than or equal to the current amount in trade, it removes ALL- Parameters:
itemName
- name of item to removeConnectoramount
- amount of item to removeConnector- Returns:
- Whether interaction was successful
-
removeItem
public static boolean removeItem(int itemId, int amount)
Removes an item from the trade screen. If the amount is greater than or equal to the current amount in trade, it removes ALL- Parameters:
itemId
- ID of item to removeConnectoramount
- amount of item to removeConnector- Returns:
- Whether interaction was successful
-
slotBounds
public static @Nullable java.awt.Rectangle slotBounds(int slot)
-
removeItem
public static boolean removeItem(@NonNull Item i, int amount)
Removes an item from the trade screen. If the amount is greater than or equal to the current amount in trade, it removes ALL- Parameters:
i
- Item to removeConnectoramount
- amount of item to removeConnector- Returns:
- Whether interaction was successful
-
-