Class GrandExchange
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 ClassesModifier and TypeClassDescriptionstatic classRepresents a search result item in the Grand Exchange item search. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidabortOffer(int itemId) Aborts an existing offer for the specified item ID.static voidabortOffer(String itemName) Aborts an existing offer for an item with the specified name.static booleanbuy(int itemId, int quantity, int price) Creates a buy offer for items at the specified price.static booleanbuy(int itemId, int quantity, int price, boolean collect, boolean toBank) Creates a buy offer with full control over all parameters.static booleanCreates a buy offer for items by name at the specified price.static booleanCreates a buy offer by name with full control over all parameters.static booleanChecks if there are items available to collect.static voidcollect()Collects completed offers to the inventory.static voidcollect(boolean toBank) Collects completed offers.static voidconfirm()Confirms the current buy or sell offer.static voidCreates a new buy offer by clicking an empty slot.static booleanexchange(boolean buy, int itemId, int quantity, int price) Creates a buy or sell offer by item ID.static booleanexchange(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 booleanCreates a buy or sell offer by item name with full control.static intGets the number of empty GE slots available.static intGets the guide price for the currently selected item.static intGets the item ID currently selected in the offer setup.static StringGets the name of the item currently selected in the offer setup.static List<net.runelite.api.GrandExchangeOffer> Gets all active Grand Exchange offers.static intgetPrice()Gets the currently set price in the offer setup.static intGets the currently set quantity in the offer setup.static List<GrandExchange.GESearchResult> Gets the search results displayed when searching for items to buy.static GrandExchangeStategetView()Gets the current view/state of the Grand Exchange interface.static booleanisBuying()Checks if currently setting up a buy offer.static booleanisEmpty()Checks if no offers are currently active.static booleanisFull()Checks if all GE slots are in use.static booleanisOpen()Checks if the Grand Exchange interface is currently open.static booleanChecks if currently in the item search state.static booleanChecks if the item search results panel is currently open.static booleanChecks if currently setting up a sell offer.static booleanChecks if an offer setup screen (buy or sell) is currently open.static voidopen()Opens the Grand Exchange interface.static voidopenBank()Opens the bank from the Grand Exchange booth.static voidOpens the item search dialog for creating a buy offer.static voidsell(int... ids) Initiates a sell offer for items matching any of the specified IDs.static booleansell(int itemId, int price, boolean collect, boolean toBank) Creates a sell offer for all of an item in inventory at the specified price.static booleansell(int itemId, int quantity, int price) Creates a sell offer for all of an item in inventory at the specified price.static booleansell(int itemId, int quantity, int price, boolean collect, boolean toBank) Creates a sell offer with full control over all parameters.static voidInitiates a sell offer for items matching any of the specified names.static voidInitiates a sell offer for items matching the filter.static voidsetItem(int id) Sets the item for a buy offer by item ID.static voidSets the item for a buy offer by searching for its name.static voidsetPrice(int price) Sets the price for the current offer.static voidsetQuantity(int quantity) Sets the quantity for the current offer.
-
Constructor Details
-
GrandExchange
public GrandExchange()
-
-
Method Details
-
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
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
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
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
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
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
Gets the search results displayed when searching for items to buy.- Returns:
- a list of
GrandExchange.GESearchResultobjects, or empty list if not searching
-
getOffers
Gets all active Grand Exchange offers.- Returns:
- a list of active
GrandExchangeOfferobjects
-
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 sellquantity- the quantity to sellprice- 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 sellprice- the price per itemcollect- true to auto-collect completed offerstoBank- 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 sellquantity- the quantity to sellprice- the price per itemcollect- true to auto-collect completed offerstoBank- 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 buyquantity- the quantity to buyprice- 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 buyquantity- the quantity to buyprice- the price per itemcollect- true to auto-collect completed offerstoBank- true to collect to bank, false to collect to inventory- Returns:
- true if the offer was confirmed, false if more steps are needed
-
buy
Creates a buy offer for items by name at the specified price.- Parameters:
itemName- the item name to buyquantity- the quantity to buyprice- 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 buyquantity- the quantity to buyprice- the price per itemcollect- true to auto-collect completed offerstoBank- 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 offeritemId- the item IDquantity- the quantityprice- 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 offeritemName- the item namequantity- the quantityprice- the price per itemcollect- true to auto-collect completed offerstoBank- 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 offeritemId- the item IDquantity- the quantityprice- the price per itemcollect- true to auto-collect completed offerstoBank- true to collect to bank, false to collect to inventory- Returns:
- true if the offer was confirmed, false if more steps are needed
-