Class GrandExchange

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

public class GrandExchange extends Object
Static utility class for interacting with the Grand Exchange.

The Grand Exchange (GE) is a trading system where players can buy and sell items. Free-to-play players have 3 slots, while members have 8 slots. This class provides methods to create buy/sell offers, manage existing offers, and collect items.

Example usage:


 // Open the Grand Exchange
 GrandExchange.open();

 // Check if GE is open
 if (GrandExchange.isOpen()) {
     // Create a buy offer
     GrandExchange.buy(ItemID.LOBSTER, 100, 200); // Buy 100 lobsters at 200gp each

     // Create a sell offer
     GrandExchange.sell(ItemID.DRAGON_BONES, 50, 3000);

     // Collect completed offers
     if (GrandExchange.canCollect()) {
         GrandExchange.collect(true); // Collect to bank
     }

     // Check current offers
     List<GrandExchangeOffer> offers = GrandExchange.getOffers();

     // Abort an offer
     GrandExchange.abortOffer(ItemID.LOBSTER);
 }
 

See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    Represents a search result item in the Grand Exchange item search.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    abortOffer(int itemId)
    Aborts an existing offer for the specified item ID.
    static void
    abortOffer(String itemName)
    Aborts an existing offer for an item with the specified name.
    static boolean
    buy(int itemId, int quantity, int price)
    Creates a buy offer for items at the specified price.
    static boolean
    buy(int itemId, int quantity, int price, boolean collect, boolean toBank)
    Creates a buy offer with full control over all parameters.
    static boolean
    buy(String itemName, int quantity, int price)
    Creates a buy offer for items by name at the specified price.
    static boolean
    buy(String itemName, int quantity, int price, boolean collect, boolean toBank)
    Creates a buy offer by name with full control over all parameters.
    static boolean
    Checks if there are items available to collect.
    static void
    Collects completed offers to the inventory.
    static void
    collect(boolean toBank)
    Collects completed offers.
    static void
    Confirms the current buy or sell offer.
    static void
    Creates a new buy offer by clicking an empty slot.
    static boolean
    exchange(boolean buy, int itemId, int quantity, int price)
    Creates a buy or sell offer by item ID.
    static boolean
    exchange(boolean buy, int itemId, int quantity, int price, boolean collect, boolean toBank)
    Creates a buy or sell offer by item ID with full control.
    static boolean
    exchange(boolean buy, String itemName, int quantity, int price, boolean collect, boolean toBank)
    Creates a buy or sell offer by item name with full control.
    static int
    Gets the number of empty GE slots available.
    static int
    Gets the guide price for the currently selected item.
    static int
    Gets the item ID currently selected in the offer setup.
    static String
    Gets the name of the item currently selected in the offer setup.
    static List<net.runelite.api.GrandExchangeOffer>
    Gets all active Grand Exchange offers.
    static int
    Gets the currently set price in the offer setup.
    static int
    Gets the currently set quantity in the offer setup.
    Gets the search results displayed when searching for items to buy.
    Gets the current view/state of the Grand Exchange interface.
    static boolean
    Checks if currently setting up a buy offer.
    static boolean
    Checks if no offers are currently active.
    static boolean
    Checks if all GE slots are in use.
    static boolean
    Checks if the Grand Exchange interface is currently open.
    static boolean
    Checks if currently in the item search state.
    static boolean
    Checks if the item search results panel is currently open.
    static boolean
    Checks if currently setting up a sell offer.
    static boolean
    Checks if an offer setup screen (buy or sell) is currently open.
    static void
    Opens the Grand Exchange interface.
    static void
    Opens the bank from the Grand Exchange booth.
    static void
    Opens the item search dialog for creating a buy offer.
    static void
    sell(int... ids)
    Initiates a sell offer for items matching any of the specified IDs.
    static boolean
    sell(int itemId, int price, boolean collect, boolean toBank)
    Creates a sell offer for all of an item in inventory at the specified price.
    static boolean
    sell(int itemId, int quantity, int price)
    Creates a sell offer for all of an item in inventory at the specified price.
    static boolean
    sell(int itemId, int quantity, int price, boolean collect, boolean toBank)
    Creates a sell offer with full control over all parameters.
    static void
    sell(String... names)
    Initiates a sell offer for items matching any of the specified names.
    static void
    sell(Predicate<IItem> filter)
    Initiates a sell offer for items matching the filter.
    static void
    setItem(int id)
    Sets the item for a buy offer by item ID.
    static void
    Sets the item for a buy offer by searching for its name.
    static void
    setPrice(int price)
    Sets the price for the current offer.
    static void
    setQuantity(int quantity)
    Sets the quantity for the current offer.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • GrandExchange

      public GrandExchange()
  • Method Details

    • getView

      public static GrandExchangeState getView()
      Gets the current view/state of the Grand Exchange interface.
      Returns:
      the current GrandExchangeState
    • isOpen

      public static boolean isOpen()
      Checks if the Grand Exchange interface is currently open.
      Returns:
      true if the GE is open, false otherwise
    • isSetupOpen

      public static boolean isSetupOpen()
      Checks if an offer setup screen (buy or sell) is currently open.
      Returns:
      true if setting up a buy or sell offer, false otherwise
    • openBank

      public static void openBank()
      Opens the bank from the Grand Exchange booth.

      This interacts with the nearest exchange booth that has a "Bank" option.

    • isSelling

      public static boolean isSelling()
      Checks if currently setting up a sell offer.
      Returns:
      true if in sell mode, false otherwise
    • isBuying

      public static boolean isBuying()
      Checks if currently setting up a buy offer.
      Returns:
      true if in buy mode, false otherwise
    • getItemId

      public static int getItemId()
      Gets the item ID currently selected in the offer setup.
      Returns:
      the item ID, or -1 if no item is selected
    • getItemName

      public static String getItemName()
      Gets the name of the item currently selected in the offer setup.
      Returns:
      the item name, or empty string if no item is selected
    • setItem

      public static void setItem(int id)
      Sets the item for a buy offer by item ID.
      Parameters:
      id - the item ID to set
    • setItem

      public static void setItem(String name)
      Sets the item for a buy offer by searching for its name.
      Parameters:
      name - the item name to search for
    • getPrice

      public static int getPrice()
      Gets the currently set price in the offer setup.
      Returns:
      the price per item in gold coins
    • setPrice

      public static void setPrice(int price)
      Sets the price for the current offer.

      If a dialog is open, enters the price there. Otherwise, clicks the enter price button.

      Parameters:
      price - the price per item to set
    • getQuantity

      public static int getQuantity()
      Gets the currently set quantity in the offer setup.
      Returns:
      the quantity of items
    • setQuantity

      public static void setQuantity(int quantity)
      Sets the quantity for the current offer.

      If a dialog is open, enters the quantity there. Otherwise, clicks the enter quantity button.

      Parameters:
      quantity - the number of items to buy/sell
    • getGuidePrice

      public static int getGuidePrice()
      Gets the guide price for the currently selected item.
      Returns:
      the guide price, or -1 if unavailable
    • open

      public static void open()
      Opens the Grand Exchange interface.

      This method handles walking to the GE if necessary and interacting with a booth.

    • sell

      public static void sell(Predicate<IItem> filter)
      Initiates a sell offer for items matching the filter.
      Parameters:
      filter - the predicate to match items against
    • sell

      public static void sell(int... ids)
      Initiates a sell offer for items matching any of the specified IDs.
      Parameters:
      ids - the item IDs to sell
    • sell

      public static void sell(String... names)
      Initiates a sell offer for items matching any of the specified names.
      Parameters:
      names - the item names to sell
    • createBuyOffer

      public static void createBuyOffer()
      Creates a new buy offer by clicking an empty slot.
    • abortOffer

      public static void abortOffer(int itemId)
      Aborts an existing offer for the specified item ID.
      Parameters:
      itemId - the item ID of the offer to abort
    • abortOffer

      public static void abortOffer(String itemName)
      Aborts an existing offer for an item with the specified name.
      Parameters:
      itemName - the item name of the offer to abort (case-insensitive partial match)
    • isFull

      public static boolean isFull()
      Checks if all GE slots are in use.
      Returns:
      true if no empty slots are available, false otherwise
    • isEmpty

      public static boolean isEmpty()
      Checks if no offers are currently active.
      Returns:
      true if no offers exist, false otherwise
    • getEmptySlots

      public static int getEmptySlots()
      Gets the number of empty GE slots available.

      Free-to-play players have 3 slots total, members have 8 slots.

      Returns:
      the number of empty slots
    • getSearchResults

      public static List<GrandExchange.GESearchResult> getSearchResults()
      Gets the search results displayed when searching for items to buy.
      Returns:
      a list of GrandExchange.GESearchResult objects, or empty list if not searching
    • getOffers

      public static List<net.runelite.api.GrandExchangeOffer> getOffers()
      Gets all active Grand Exchange offers.
      Returns:
      a list of active GrandExchangeOffer objects
    • canCollect

      public static boolean canCollect()
      Checks if there are items available to collect.
      Returns:
      true if the collect button is visible, false otherwise
    • collect

      public static void collect()
      Collects completed offers to the inventory.
    • collect

      public static void collect(boolean toBank)
      Collects completed offers.
      Parameters:
      toBank - true to collect to bank, false to collect to inventory
    • confirm

      public static void confirm()
      Confirms the current buy or sell offer.
    • isSearchResultsOpen

      public static boolean isSearchResultsOpen()
      Checks if the item search results panel is currently open.
      Returns:
      true if search results are displayed, false otherwise
    • isSearchingItem

      public static boolean isSearchingItem()
      Checks if currently in the item search state.
      Returns:
      true if searching for an item, false otherwise
    • openItemSearch

      public static void openItemSearch()
      Opens the item search dialog for creating a buy offer.
    • sell

      public static boolean sell(int itemId, int quantity, int price)
      Creates a sell offer for all of an item in inventory at the specified price.
      Parameters:
      itemId - the item ID to sell
      quantity - the quantity to sell
      price - the price per item
      Returns:
      true if the offer was confirmed, false if more steps are needed
    • sell

      public static boolean sell(int itemId, int price, boolean collect, boolean toBank)
      Creates a sell offer for all of an item in inventory at the specified price.
      Parameters:
      itemId - the item ID to sell
      price - the price per item
      collect - true to auto-collect completed offers
      toBank - true to collect to bank, false to collect to inventory
      Returns:
      true if the offer was confirmed, false if more steps are needed
    • sell

      public static boolean sell(int itemId, int quantity, int price, boolean collect, boolean toBank)
      Creates a sell offer with full control over all parameters.
      Parameters:
      itemId - the item ID to sell
      quantity - the quantity to sell
      price - the price per item
      collect - true to auto-collect completed offers
      toBank - true to collect to bank, false to collect to inventory
      Returns:
      true if the offer was confirmed, false if more steps are needed
    • buy

      public static boolean buy(int itemId, int quantity, int price)
      Creates a buy offer for items at the specified price.
      Parameters:
      itemId - the item ID to buy
      quantity - the quantity to buy
      price - the price per item
      Returns:
      true if the offer was confirmed, false if more steps are needed
    • buy

      public static boolean buy(int itemId, int quantity, int price, boolean collect, boolean toBank)
      Creates a buy offer with full control over all parameters.
      Parameters:
      itemId - the item ID to buy
      quantity - the quantity to buy
      price - the price per item
      collect - true to auto-collect completed offers
      toBank - true to collect to bank, false to collect to inventory
      Returns:
      true if the offer was confirmed, false if more steps are needed
    • buy

      public static boolean buy(String itemName, int quantity, int price)
      Creates a buy offer for items by name at the specified price.
      Parameters:
      itemName - the item name to buy
      quantity - the quantity to buy
      price - the price per item
      Returns:
      true if the offer was confirmed, false if more steps are needed
    • buy

      public static boolean buy(String itemName, int quantity, int price, boolean collect, boolean toBank)
      Creates a buy offer by name with full control over all parameters.
      Parameters:
      itemName - the item name to buy
      quantity - the quantity to buy
      price - the price per item
      collect - true to auto-collect completed offers
      toBank - true to collect to bank, false to collect to inventory
      Returns:
      true if the offer was confirmed, false if more steps are needed
    • exchange

      public static boolean exchange(boolean buy, int itemId, int quantity, int price)
      Creates a buy or sell offer by item ID.
      Parameters:
      buy - true for buy offer, false for sell offer
      itemId - the item ID
      quantity - the quantity
      price - the price per item
      Returns:
      true if the offer was confirmed, false if more steps are needed
    • exchange

      public static boolean exchange(boolean buy, String itemName, int quantity, int price, boolean collect, boolean toBank)
      Creates a buy or sell offer by item name with full control.

      This method handles all the steps of creating an offer: opening the GE, collecting existing offers, selecting the item, setting price and quantity, and confirming.

      Parameters:
      buy - true for buy offer, false for sell offer
      itemName - the item name
      quantity - the quantity
      price - the price per item
      collect - true to auto-collect completed offers
      toBank - true to collect to bank, false to collect to inventory
      Returns:
      true if the offer was confirmed, false if more steps are needed
    • exchange

      public static boolean exchange(boolean buy, int itemId, int quantity, int price, boolean collect, boolean toBank)
      Creates a buy or sell offer by item ID with full control.

      This method handles all the steps of creating an offer: opening the GE, collecting existing offers, selecting the item, setting price and quantity, and confirming.

      Parameters:
      buy - true for buy offer, false for sell offer
      itemId - the item ID
      quantity - the quantity
      price - the price per item
      collect - true to auto-collect completed offers
      toBank - true to collect to bank, false to collect to inventory
      Returns:
      true if the offer was confirmed, false if more steps are needed