Class Trade

java.lang.Object
net.storm.sdk.items.Trade

public class Trade extends Object
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
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    Accepts the trade on the current screen (first or second).
    static void
    Accepts the trade on the first screen.
    static void
    Accepts the trade on the second (confirmation) screen.
    static boolean
    contains(boolean theirs, int... ids)
    Checks if the trade window contains an item matching any of the specified IDs.
    static boolean
    contains(boolean theirs, String... names)
    Checks if the trade window contains an item matching any of the specified names.
    static boolean
    contains(boolean theirs, Predicate<IItem> filter)
    Checks if the trade window contains an item matching the filter.
    static void
    Declines the trade on the current screen.
    static void
    Declines the trade on the first screen.
    static void
    Declines the trade on the second (confirmation) screen.
    static List<IItem>
    getAll(boolean theirs)
    Gets all items in the trade window.
    static List<IItem>
    getAll(boolean theirs, int... ids)
    Gets all items in the trade window matching any of the specified IDs.
    static List<IItem>
    getAll(boolean theirs, String... names)
    Gets all items in the trade window matching any of the specified names.
    static List<IItem>
    getAll(boolean theirs, Predicate<? super IItem> filter)
    Gets all items in the trade window matching the filter.
    static IItem
    getFirst(boolean theirs, int... ids)
    Gets the first item in the trade window matching any of the specified IDs.
    static IItem
    getFirst(boolean theirs, String... names)
    Gets the first item in the trade window matching any of the specified names.
    static IItem
    getFirst(boolean theirs, Predicate<IItem> filter)
    Gets the first item in the trade window matching the filter.
    static List<IItem>
    Gets all items in the trade inventory panel matching the filter.
    static String
    Gets the name of the player you are currently trading with.
    static boolean
    hasAccepted(boolean them)
    Checks if a party has accepted the trade on the current screen.
    static boolean
    hasAcceptedFirstScreen(boolean them)
    Checks if a party has accepted the first trade screen.
    static boolean
    Checks if a party has accepted the second (confirmation) trade screen.
    static boolean
    Checks if the first trade screen is currently open.
    static boolean
    Checks if any trade screen is currently open.
    static boolean
    Checks if the second (confirmation) trade screen is currently open.
    static void
    offer(int id, int quantity)
    Offers items by ID from your inventory into the trade.
    static void
    offer(int id, int quantity, boolean quick)
    Offers items by ID from your inventory into the trade.
    static void
    offer(String name, int quantity)
    Offers items by name from your inventory into the trade.
    static void
    offer(String name, int quantity, boolean quick)
    Offers items by name from your inventory into the trade.
    static void
    offer(Predicate<IItem> filter, int quantity)
    Offers items matching the filter from your inventory into the trade.
    static void
    offer(Predicate<IItem> filter, int quantity, boolean quick)
    Offers items matching the filter from your inventory into the trade.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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

      public static void offer(Predicate<IItem> filter, int quantity, boolean quick)
      Offers items matching the filter from your inventory into the trade.
      Parameters:
      filter - the predicate to match items against
      quantity - the quantity to offer
      quick - true to use quick offer (optimized interaction)
    • offer

      public static void offer(Predicate<IItem> filter, int quantity)
      Offers items matching the filter from your inventory into the trade.
      Parameters:
      filter - the predicate to match items against
      quantity - 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 offer
      quantity - 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 offer
      quantity - the quantity to offer
      quick - true to use quick offer (optimized interaction)
    • offer

      public static void offer(String name, int quantity)
      Offers items by name from your inventory into the trade.
      Parameters:
      name - the item name to offer
      quantity - the quantity to offer
    • offer

      public static void offer(String name, int quantity, boolean quick)
      Offers items by name from your inventory into the trade.
      Parameters:
      name - the item name to offer
      quantity - the quantity to offer
      quick - true to use quick offer (optimized interaction)
    • getAll

      public static List<IItem> getAll(boolean theirs, Predicate<? super IItem> filter)
      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 items
      filter - the predicate to match items against
      Returns:
      a list of matching items in the trade window
    • getInventory

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

      public static List<IItem> getAll(boolean theirs)
      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

      public static List<IItem> getAll(boolean theirs, int... ids)
      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 items
      ids - the item IDs to search for
      Returns:
      a list of matching items in the trade window
    • getAll

      public static List<IItem> getAll(boolean theirs, String... names)
      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 items
      names - the item names to search for
      Returns:
      a list of matching items in the trade window
    • getFirst

      public static IItem getFirst(boolean theirs, Predicate<IItem> filter)
      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 own
      filter - the predicate to match items against
      Returns:
      the first matching item, or null if none found
    • getFirst

      public static IItem getFirst(boolean theirs, int... ids)
      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 own
      ids - the item IDs to search for
      Returns:
      the first matching item, or null if none found
    • getFirst

      public static IItem getFirst(boolean theirs, String... names)
      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 own
      names - the item names to search for
      Returns:
      the first matching item, or null if none found
    • contains

      public static boolean contains(boolean theirs, Predicate<IItem> filter)
      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 own
      filter - 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 own
      ids - the item IDs to search for
      Returns:
      true if a matching item exists, false otherwise
    • contains

      public static boolean contains(boolean theirs, String... names)
      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 own
      names - the item names to search for
      Returns:
      true if a matching item exists, false otherwise
    • getTradingPlayer

      public static String 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