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:

  1. First screen - where items are offered and can be modified
  2. Second screen - confirmation screen showing final trade details

See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    default void
    Accepts the trade on both screens.
    void
    Accepts the trade on the first screen.
    void
    Accepts the trade on the second (confirmation) screen.
    default boolean
    contains(boolean theirs, int... ids)
    Checks if either party's trade offer contains an item with the specified IDs.
    default boolean
    contains(boolean theirs, String... names)
    Checks if either party's trade offer contains an item with the specified names.
    default boolean
    contains(boolean theirs, Predicate<IItem> filter)
    Checks if either party's trade offer contains an item matching the filter.
    default void
    Declines the trade on both screens.
    void
    Declines the trade on the first screen.
    void
    Declines the trade on the second (confirmation) screen.
    default List<IItem>
    getAll(boolean theirs)
    Gets all items in either party's trade offer.
    default List<IItem>
    getAll(boolean theirs, int... ids)
    Gets all items in either party's trade offer matching the specified IDs.
    default List<IItem>
    getAll(boolean theirs, String... names)
    Gets all items in either party's trade offer matching the specified names.
    getAll(boolean theirs, Predicate<? super IItem> filter)
    Gets all items in either party's trade offer matching the filter.
    default IItem
    getFirst(boolean theirs, int... ids)
    Gets the first item in either party's trade offer matching the specified IDs.
    default IItem
    getFirst(boolean theirs, String... names)
    Gets the first item in either party's trade offer matching the specified names.
    default IItem
    getFirst(boolean theirs, Predicate<IItem> filter)
    Gets the first item in either party's trade offer matching the filter.
    Gets all items in the trade inventory matching the filter.
    Gets the name of the player being traded with.
    default boolean
    hasAccepted(boolean them)
    Checks if either party has accepted on any screen.
    boolean
    hasAcceptedFirstScreen(boolean them)
    Checks if a party has accepted on the first trade screen.
    boolean
    Checks if a party has accepted on the second trade screen.
    boolean
    Checks if the first (offering) trade screen is currently open.
    default boolean
    Checks if any trade screen is currently open.
    boolean
    Checks if the second (confirmation) trade screen is currently open.
    default void
    offer(int id, int quantity)
    Offers items with the specified ID to the trade using standard mode.
    default void
    offer(int id, int quantity, boolean quick)
    Offers items with the specified ID to the trade.
    default void
    offer(String name, int quantity)
    Offers items with the specified name to the trade using standard mode.
    default void
    offer(String name, int quantity, boolean quick)
    Offers items with the specified name to the trade.
    default void
    offer(Predicate<IItem> filter, int quantity)
    Offers items matching the filter to the trade using standard mode.
    void
    offer(Predicate<IItem> filter, int quantity, boolean quick)
    Offers items matching the filter to the trade.
  • Method Details

    • isOpen

      default boolean isOpen()
      Checks if any trade screen is currently open.
      Returns:
      true if either the first or second trade screen is open, false otherwise
    • isSecondScreenOpen

      boolean isSecondScreenOpen()
      Checks if the second (confirmation) trade screen is currently open.
      Returns:
      true if the second trade screen is open, false otherwise
    • isFirstScreenOpen

      boolean isFirstScreenOpen()
      Checks if the first (offering) trade screen is currently open.
      Returns:
      true if the first trade screen is open, false otherwise
    • accept

      default void accept()
      Accepts the trade on both screens.

      This is a convenience method that calls both acceptFirstScreen() and acceptSecondScreen().

    • 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() and declineSecondScreen().

    • 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 - true to check if the other player has accepted, false to check if the local player has accepted
      Returns:
      true if 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 - true to check the other player's acceptance status, false to check the local player's acceptance status
      Returns:
      true if 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 - true to check the other player's acceptance status, false to check the local player's acceptance status
      Returns:
      true if the specified party has accepted on the second screen
    • offer

      void offer(Predicate<IItem> filter, int quantity, boolean quick)
      Offers items matching the filter to the trade.
      Parameters:
      filter - the predicate to match items in the inventory
      quantity - the number of items to offer
      quick - true to use quick offer mode (right-click menu), false for standard offering
    • offer

      default void offer(Predicate<IItem> filter, int quantity)
      Offers items matching the filter to the trade using standard mode.
      Parameters:
      filter - the predicate to match items in the inventory
      quantity - 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 offer
      quantity - 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 offer
      quantity - the number of items to offer
      quick - true to use quick offer mode, false for standard offering
    • offer

      default void offer(String name, int quantity)
      Offers items with the specified name to the trade using standard mode.
      Parameters:
      name - the exact item name to offer
      quantity - the number of items to offer
    • offer

      default void offer(String name, int quantity, boolean quick)
      Offers items with the specified name to the trade.
      Parameters:
      name - the exact item name to offer
      quantity - the number of items to offer
      quick - true to use quick offer mode, false for standard offering
    • getAll

      List<IItem> getAll(boolean theirs, Predicate<? super IItem> filter)
      Gets all items in either party's trade offer matching the filter.
      Parameters:
      theirs - true to get items from the other player's offer, false to get items from the local player's offer
      filter - the predicate to filter items
      Returns:
      a list of items matching the filter, never null
    • getInventory

      List<IItem> getInventory(Predicate<IItem> filter)
      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

      default List<IItem> getAll(boolean theirs)
      Gets all items in either party's trade offer.
      Parameters:
      theirs - true to get items from the other player's offer, false to get items from the local player's offer
      Returns:
      a list of all items in the specified trade offer, never null
    • getAll

      default List<IItem> getAll(boolean theirs, int... ids)
      Gets all items in either party's trade offer matching the specified IDs.
      Parameters:
      theirs - true to get items from the other player's offer, false to get items from the local player's offer
      ids - the item IDs to match
      Returns:
      a list of items with matching IDs, never null
    • getAll

      default List<IItem> getAll(boolean theirs, String... names)
      Gets all items in either party's trade offer matching the specified names.
      Parameters:
      theirs - true to get items from the other player's offer, false to get items from the local player's offer
      names - the exact item names to match
      Returns:
      a list of items with matching names, never null
    • getFirst

      default IItem getFirst(boolean theirs, Predicate<IItem> filter)
      Gets the first item in either party's trade offer matching the filter.
      Parameters:
      theirs - true to search the other player's offer, false to search the local player's offer
      filter - the predicate to match items
      Returns:
      the first matching item, or null if no match is found
    • getFirst

      default IItem getFirst(boolean theirs, int... ids)
      Gets the first item in either party's trade offer matching the specified IDs.
      Parameters:
      theirs - true to search the other player's offer, false to search the local player's offer
      ids - the item IDs to match
      Returns:
      the first item with a matching ID, or null if no match is found
    • getFirst

      default IItem getFirst(boolean theirs, String... names)
      Gets the first item in either party's trade offer matching the specified names.
      Parameters:
      theirs - true to search the other player's offer, false to search the local player's offer
      names - the exact item names to match
      Returns:
      the first item with a matching name, or null if no match is found
    • contains

      default boolean contains(boolean theirs, Predicate<IItem> filter)
      Checks if either party's trade offer contains an item matching the filter.
      Parameters:
      theirs - true to check the other player's offer, false to check the local player's offer
      filter - the predicate to match items
      Returns:
      true if 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 - true to check the other player's offer, false to check the local player's offer
      ids - the item IDs to check for
      Returns:
      true if an item with a matching ID is found
    • contains

      default boolean contains(boolean theirs, String... names)
      Checks if either party's trade offer contains an item with the specified names.
      Parameters:
      theirs - true to check the other player's offer, false to check the local player's offer
      names - the exact item names to check for
      Returns:
      true if 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 null if not in a trade