Package net.storm.api.items
Interface ITrade
public interface ITrade
Provides an interface for managing player-to-player trading interactions.
This interface handles all aspects of the trading system, including:
- Opening and managing trade windows (first and second screens)
- Accepting and declining trades
- Offering items to the trade
- Querying items in both parties' trade offers
- Checking trade acceptance status
The trading process consists of two screens:
- First screen - where items are offered and can be modified
- Second screen - confirmation screen showing final trade details
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptiondefault voidaccept()Accepts the trade on both screens.voidAccepts the trade on the first screen.voidAccepts the trade on the second (confirmation) screen.default booleancontains(boolean theirs, int... ids) Checks if either party's trade offer contains an item with the specified IDs.default booleanChecks if either party's trade offer contains an item with the specified names.default booleanChecks if either party's trade offer contains an item matching the filter.default voiddecline()Declines the trade on both screens.voidDeclines the trade on the first screen.voidDeclines the trade on the second (confirmation) screen.getAll(boolean theirs) Gets all items in either party's trade offer.getAll(boolean theirs, int... ids) Gets all items in either party's trade offer matching the specified IDs.Gets all items in either party's trade offer matching the specified names.Gets all items in either party's trade offer matching the filter.default IItemgetFirst(boolean theirs, int... ids) Gets the first item in either party's trade offer matching the specified IDs.default IItemGets the first item in either party's trade offer matching the specified names.default IItemGets the first item in either party's trade offer matching the filter.getInventory(Predicate<IItem> filter) Gets all items in the trade inventory matching the filter.Gets the name of the player being traded with.default booleanhasAccepted(boolean them) Checks if either party has accepted on any screen.booleanhasAcceptedFirstScreen(boolean them) Checks if a party has accepted on the first trade screen.booleanhasAcceptedSecondScreen(boolean them) Checks if a party has accepted on the second trade screen.booleanChecks if the first (offering) trade screen is currently open.default booleanisOpen()Checks if any trade screen is currently open.booleanChecks if the second (confirmation) trade screen is currently open.default voidoffer(int id, int quantity) Offers items with the specified ID to the trade using standard mode.default voidoffer(int id, int quantity, boolean quick) Offers items with the specified ID to the trade.default voidOffers items with the specified name to the trade using standard mode.default voidOffers items with the specified name to the trade.default voidOffers items matching the filter to the trade using standard mode.voidOffers items matching the filter to the trade.
-
Method Details
-
isOpen
default boolean isOpen()Checks if any trade screen is currently open.- Returns:
trueif either the first or second trade screen is open,falseotherwise
-
isSecondScreenOpen
boolean isSecondScreenOpen()Checks if the second (confirmation) trade screen is currently open.- Returns:
trueif the second trade screen is open,falseotherwise
-
isFirstScreenOpen
boolean isFirstScreenOpen()Checks if the first (offering) trade screen is currently open.- Returns:
trueif the first trade screen is open,falseotherwise
-
accept
default void accept()Accepts the trade on both screens.This is a convenience method that calls both
acceptFirstScreen()andacceptSecondScreen(). -
acceptFirstScreen
void acceptFirstScreen()Accepts the trade on the first screen.This indicates agreement to the current trade offer and readiness to proceed to the confirmation screen.
-
acceptSecondScreen
void acceptSecondScreen()Accepts the trade on the second (confirmation) screen.This finalizes the trade and exchanges items between players.
-
decline
default void decline()Declines the trade on both screens.This is a convenience method that calls both
declineFirstScreen()anddeclineSecondScreen(). -
declineFirstScreen
void declineFirstScreen()Declines the trade on the first screen.This cancels the trade and closes the trade window.
-
declineSecondScreen
void declineSecondScreen()Declines the trade on the second (confirmation) screen.This cancels the trade at the final confirmation stage.
-
hasAccepted
default boolean hasAccepted(boolean them) Checks if either party has accepted on any screen.- Parameters:
them-trueto check if the other player has accepted,falseto check if the local player has accepted- Returns:
trueif the specified party has accepted on either screen
-
hasAcceptedFirstScreen
boolean hasAcceptedFirstScreen(boolean them) Checks if a party has accepted on the first trade screen.- Parameters:
them-trueto check the other player's acceptance status,falseto check the local player's acceptance status- Returns:
trueif the specified party has accepted on the first screen
-
hasAcceptedSecondScreen
boolean hasAcceptedSecondScreen(boolean them) Checks if a party has accepted on the second trade screen.- Parameters:
them-trueto check the other player's acceptance status,falseto check the local player's acceptance status- Returns:
trueif the specified party has accepted on the second screen
-
offer
Offers items matching the filter to the trade.- Parameters:
filter- the predicate to match items in the inventoryquantity- the number of items to offerquick-trueto use quick offer mode (right-click menu),falsefor standard offering
-
offer
Offers items matching the filter to the trade using standard mode.- Parameters:
filter- the predicate to match items in the inventoryquantity- the number of items to offer
-
offer
default void offer(int id, int quantity) Offers items with the specified ID to the trade using standard mode.- Parameters:
id- the item ID to offerquantity- the number of items to offer
-
offer
default void offer(int id, int quantity, boolean quick) Offers items with the specified ID to the trade.- Parameters:
id- the item ID to offerquantity- the number of items to offerquick-trueto use quick offer mode,falsefor standard offering
-
offer
Offers items with the specified name to the trade using standard mode.- Parameters:
name- the exact item name to offerquantity- the number of items to offer
-
offer
Offers items with the specified name to the trade.- Parameters:
name- the exact item name to offerquantity- the number of items to offerquick-trueto use quick offer mode,falsefor standard offering
-
getAll
Gets all items in either party's trade offer matching the filter.- Parameters:
theirs-trueto get items from the other player's offer,falseto get items from the local player's offerfilter- the predicate to filter items- Returns:
- a list of items matching the filter, never
null
-
getInventory
Gets all items in the trade inventory matching the filter.- Parameters:
filter- the predicate to filter items- Returns:
- a list of items matching the filter, never
null
-
getAll
Gets all items in either party's trade offer.- Parameters:
theirs-trueto get items from the other player's offer,falseto get items from the local player's offer- Returns:
- a list of all items in the specified trade offer, never
null
-
getAll
Gets all items in either party's trade offer matching the specified IDs.- Parameters:
theirs-trueto get items from the other player's offer,falseto get items from the local player's offerids- the item IDs to match- Returns:
- a list of items with matching IDs, never
null
-
getAll
Gets all items in either party's trade offer matching the specified names.- Parameters:
theirs-trueto get items from the other player's offer,falseto get items from the local player's offernames- the exact item names to match- Returns:
- a list of items with matching names, never
null
-
getFirst
Gets the first item in either party's trade offer matching the filter.- Parameters:
theirs-trueto search the other player's offer,falseto search the local player's offerfilter- the predicate to match items- Returns:
- the first matching item, or
nullif no match is found
-
getFirst
Gets the first item in either party's trade offer matching the specified IDs.- Parameters:
theirs-trueto search the other player's offer,falseto search the local player's offerids- the item IDs to match- Returns:
- the first item with a matching ID, or
nullif no match is found
-
getFirst
Gets the first item in either party's trade offer matching the specified names.- Parameters:
theirs-trueto search the other player's offer,falseto search the local player's offernames- the exact item names to match- Returns:
- the first item with a matching name, or
nullif no match is found
-
contains
Checks if either party's trade offer contains an item matching the filter.- Parameters:
theirs-trueto check the other player's offer,falseto check the local player's offerfilter- the predicate to match items- Returns:
trueif a matching item is found
-
contains
default boolean contains(boolean theirs, int... ids) Checks if either party's trade offer contains an item with the specified IDs.- Parameters:
theirs-trueto check the other player's offer,falseto check the local player's offerids- the item IDs to check for- Returns:
trueif an item with a matching ID is found
-
contains
Checks if either party's trade offer contains an item with the specified names.- Parameters:
theirs-trueto check the other player's offer,falseto check the local player's offernames- the exact item names to check for- Returns:
trueif an item with a matching name is found
-
getTradingPlayer
String getTradingPlayer()Gets the name of the player being traded with.- Returns:
- the trading partner's display name, or
nullif not in a trade
-