Package net.storm.sdk.items
Class Trade
java.lang.Object
net.storm.sdk.items.Trade
Static utility class for interacting with the player-to-player trading interface.
Trading occurs in two screens: the first screen where items are offered, and the second confirmation screen. This class provides methods to check trade status, offer items, accept or decline trades, and query items in both trade windows.
Example usage:
// Check if trade is open
if (Trade.isOpen()) {
// Offer items from inventory
Trade.offer("Coins", 1000);
// Check what the other player is offering
List<IItem> theirOffer = Trade.getAll(true);
// Accept the first trade screen
if (Trade.isFirstScreenOpen() && !Trade.hasAcceptedFirstScreen(false)) {
Trade.acceptFirstScreen();
}
// Accept the second/confirmation screen
if (Trade.isSecondScreenOpen()) {
Trade.acceptSecondScreen();
}
}
// Check who you're trading with
String tradingWith = Trade.getTradingPlayer();
// Decline a trade
Trade.decline();
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaccept()Accepts the trade on the current screen (first or second).static voidAccepts the trade on the first screen.static voidAccepts the trade on the second (confirmation) screen.static booleancontains(boolean theirs, int... ids) Checks if the trade window contains an item matching any of the specified IDs.static booleanChecks if the trade window contains an item matching any of the specified names.static booleanChecks if the trade window contains an item matching the filter.static voiddecline()Declines the trade on the current screen.static voidDeclines the trade on the first screen.static voidDeclines the trade on the second (confirmation) screen.getAll(boolean theirs) Gets all items in the trade window.getAll(boolean theirs, int... ids) Gets all items in the trade window matching any of the specified IDs.Gets all items in the trade window matching any of the specified names.Gets all items in the trade window matching the filter.static IItemgetFirst(boolean theirs, int... ids) Gets the first item in the trade window matching any of the specified IDs.static IItemGets the first item in the trade window matching any of the specified names.static IItemGets the first item in the trade window matching the filter.getInventory(Predicate<IItem> filter) Gets all items in the trade inventory panel matching the filter.static StringGets the name of the player you are currently trading with.static booleanhasAccepted(boolean them) Checks if a party has accepted the trade on the current screen.static booleanhasAcceptedFirstScreen(boolean them) Checks if a party has accepted the first trade screen.static booleanhasAcceptedSecondScreen(boolean them) Checks if a party has accepted the second (confirmation) trade screen.static booleanChecks if the first trade screen is currently open.static booleanisOpen()Checks if any trade screen is currently open.static booleanChecks if the second (confirmation) trade screen is currently open.static voidoffer(int id, int quantity) Offers items by ID from your inventory into the trade.static voidoffer(int id, int quantity, boolean quick) Offers items by ID from your inventory into the trade.static voidOffers items by name from your inventory into the trade.static voidOffers items by name from your inventory into the trade.static voidOffers items matching the filter from your inventory into the trade.static voidOffers items matching the filter from your inventory into the trade.
-
Constructor Details
-
Trade
public Trade()
-
-
Method Details
-
isOpen
public static boolean isOpen()Checks if any trade screen is currently open.- Returns:
- true if a trade screen is open, false otherwise
-
isSecondScreenOpen
public static boolean isSecondScreenOpen()Checks if the second (confirmation) trade screen is currently open.- Returns:
- true if the second trade screen is open, false otherwise
-
isFirstScreenOpen
public static boolean isFirstScreenOpen()Checks if the first trade screen is currently open.- Returns:
- true if the first trade screen is open, false otherwise
-
accept
public static void accept()Accepts the trade on the current screen (first or second). -
acceptFirstScreen
public static void acceptFirstScreen()Accepts the trade on the first screen. -
acceptSecondScreen
public static void acceptSecondScreen()Accepts the trade on the second (confirmation) screen. -
decline
public static void decline()Declines the trade on the current screen. -
declineFirstScreen
public static void declineFirstScreen()Declines the trade on the first screen. -
declineSecondScreen
public static void declineSecondScreen()Declines the trade on the second (confirmation) screen. -
hasAccepted
public static boolean hasAccepted(boolean them) Checks if a party has accepted the trade on the current screen.- Parameters:
them- true to check if the other player has accepted, false to check yourself- Returns:
- true if the specified party has accepted, false otherwise
-
hasAcceptedFirstScreen
public static boolean hasAcceptedFirstScreen(boolean them) Checks if a party has accepted the first trade screen.- Parameters:
them- true to check if the other player has accepted, false to check yourself- Returns:
- true if the specified party has accepted, false otherwise
-
hasAcceptedSecondScreen
public static boolean hasAcceptedSecondScreen(boolean them) Checks if a party has accepted the second (confirmation) trade screen.- Parameters:
them- true to check if the other player has accepted, false to check yourself- Returns:
- true if the specified party has accepted, false otherwise
-
offer
Offers items matching the filter from your inventory into the trade.- Parameters:
filter- the predicate to match items againstquantity- the quantity to offerquick- true to use quick offer (optimized interaction)
-
offer
Offers items matching the filter from your inventory into the trade.- Parameters:
filter- the predicate to match items againstquantity- the quantity to offer
-
offer
public static void offer(int id, int quantity) Offers items by ID from your inventory into the trade.- Parameters:
id- the item ID to offerquantity- the quantity to offer
-
offer
public static void offer(int id, int quantity, boolean quick) Offers items by ID from your inventory into the trade.- Parameters:
id- the item ID to offerquantity- the quantity to offerquick- true to use quick offer (optimized interaction)
-
offer
Offers items by name from your inventory into the trade.- Parameters:
name- the item name to offerquantity- the quantity to offer
-
offer
Offers items by name from your inventory into the trade.- Parameters:
name- the item name to offerquantity- the quantity to offerquick- true to use quick offer (optimized interaction)
-
getAll
Gets all items in the trade window matching the filter.- Parameters:
theirs- true to get items from the other player's offer, false to get your own offered itemsfilter- the predicate to match items against- Returns:
- a list of matching items in the trade window
-
getInventory
Gets all items in the trade inventory panel matching the filter.- Parameters:
filter- the predicate to match items against- Returns:
- a list of matching items in the trade inventory
-
getAll
Gets all items in the trade window.- Parameters:
theirs- true to get items from the other player's offer, false to get your own offered items- Returns:
- a list of all items in the specified trade window
-
getAll
Gets all items in the trade window matching any of the specified IDs.- Parameters:
theirs- true to get items from the other player's offer, false to get your own offered itemsids- the item IDs to search for- Returns:
- a list of matching items in the trade window
-
getAll
Gets all items in the trade window matching any of the specified names.- Parameters:
theirs- true to get items from the other player's offer, false to get your own offered itemsnames- the item names to search for- Returns:
- a list of matching items in the trade window
-
getFirst
Gets the first item in the trade window matching the filter.- Parameters:
theirs- true to search the other player's offer, false to search your ownfilter- the predicate to match items against- Returns:
- the first matching item, or null if none found
-
getFirst
Gets the first item in the trade window matching any of the specified IDs.- Parameters:
theirs- true to search the other player's offer, false to search your ownids- the item IDs to search for- Returns:
- the first matching item, or null if none found
-
getFirst
Gets the first item in the trade window matching any of the specified names.- Parameters:
theirs- true to search the other player's offer, false to search your ownnames- the item names to search for- Returns:
- the first matching item, or null if none found
-
contains
Checks if the trade window contains an item matching the filter.- Parameters:
theirs- true to check the other player's offer, false to check your ownfilter- the predicate to match items against- Returns:
- true if a matching item exists, false otherwise
-
contains
public static boolean contains(boolean theirs, int... ids) Checks if the trade window contains an item matching any of the specified IDs.- Parameters:
theirs- true to check the other player's offer, false to check your ownids- the item IDs to search for- Returns:
- true if a matching item exists, false otherwise
-
contains
Checks if the trade window contains an item matching any of the specified names.- Parameters:
theirs- true to check the other player's offer, false to check your ownnames- the item names to search for- Returns:
- true if a matching item exists, false otherwise
-
getTradingPlayer
Gets the name of the player you are currently trading with.- Returns:
- the trading partner's name, or null if not in a trade
-