Class GrandExchange
- java.lang.Object
-
- org.dreambot.api.methods.grandexchange.GrandExchange
-
public class GrandExchange extends java.lang.Object
Created by Nezz on 12/10/2014.
-
-
Field Summary
Fields Modifier and Type Field Description static int
ALL
static int
GUIDE_PRICE_AMOUNT
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean
addBuyItem(java.lang.String itemName)
Adds an item to the buy offer Now checks if there's already an item selected, if it's the wrong item it will attempt to click the back button instead.static boolean
addBuyItem(Item item)
Adds an item to the buy offer Now checks if there's already an item selected, if it's the wrong item it will attempt to click the back button instead.static boolean
addSellItem(java.lang.String itemName)
Adds an item to the sell offerstatic boolean
addSellItem(Item item)
Adds an item to the sell offerstatic boolean
buyItem(int itemId, int amount, int price)
Puts in a buy order in the Grand Exchangestatic boolean
buyItem(java.lang.String itemName, int amount, int price)
Puts in a buy order in the Grand Exchangestatic boolean
cancelAll()
Cancels all available offers If inside an offer, will cancel inside the offer, otherwise it will cancel from main screenstatic boolean
cancelOffer(int slot)
Aborts the current offer in the slot specified in the Grand Exchange Works with buy/sell open or from main ge screenstatic boolean
close()
Closes the GrandExchange screen If close interface with ESC is enabled, will use esc key to close interfacestatic boolean
collect()
Presses the collect button on the main interface, collects to inventorystatic boolean
collectToBank()
Uses the collect button to collect everything directly to the bankstatic boolean
confirm()
Confirms the offer in the Grand Exchangestatic boolean
contains(int[] ids)
static boolean
contains(java.lang.Integer... ids)
Checks if your collection contains one item which meets one of the specified ids.static boolean
contains(java.lang.String... names)
Checks if your collection contains one item which meets one of the specified names.static boolean
contains(Filter<Item> filter)
Checks if your collection contains one item which meets the specified filter.static WidgetChild
getCloseButton()
static int
getCurrentAmount()
Gets the current quantity set based on the player setting for current amountstatic Item
getCurrentChosenItem()
Gets the Item based on the ID returned fromgetCurrentChosenItemID()
static int
getCurrentChosenItemID()
Gets the current chosen Item ID from the Set Up Buy/Sell Offer menu in the GEstatic int
getCurrentPrice()
Gets the currently set price of the offer based on the player settingsstatic WidgetChild
getDecreasePriceFivePercentButton()
Gets the -5% price WidgetChild in the offer screenstatic WidgetChild
getDecreasePriceXPercentButton()
Gets the -X% price WidgetChild in the offer screenstatic WidgetChild
getEnterAllButton()
Gets the Enter All button in the offer screenstatic WidgetChild
getEnterPriceButton()
Gets the Enter Price WidgetChild in the offer screenstatic WidgetChild
getEnterQuantityButton()
Gets the WidgetChild of the "Enter Quantity" buttonstatic int
getFirstOpenSlot()
Gets the number of the first open slotstatic WidgetChild
getGuidePriceButton()
Gets the Guide Price WidgetChild in the offer screenstatic WidgetChild
getIncreasePriceFivePercentButton()
Gets the +5% price WidgetChild in the offer screenstatic WidgetChild
getIncreasePriceXPercentButton()
Gets the +X% price WidgetChild in the offer screenstatic GrandExchangeItem
getItem(int[] ids)
static GrandExchangeItem
getItem(java.lang.Integer... ids)
Gets aGrandExchangeItem
that matches one of the given ID'sstatic GrandExchangeItem
getItem(java.lang.String... names)
Gets aGrandExchangeItem
that matches one of the given namesstatic GrandExchangeItem
getItem(Filter<Item> filter)
Gets aGrandExchangeItem
that matches one of the given filterstatic WidgetChild
getItemChildInSearch(java.lang.String itemName)
Gets the widget child of the item you searched forstatic WidgetChild
getItemChildInSearch(java.lang.String name, int id)
Gets theWidgetChild
of the item you searched forstatic GrandExchangeItem[]
getItems()
Gets an array of the GrandExchangeItemsstatic Item
getLastChosenItem()
Gets the last chosen buy Item based on the ID returned fromgetLastChosenItemID()
static int
getLastChosenItemID()
Gets the Item ID of the last chosen buy itemstatic WidgetChild
getOfferFirstItemWidget()
Gets the WidgetChild of the first item slot of the open offerstatic WidgetChild
getOfferSecondItemWidget()
Gets the WidgetChild of the second item slot of the open offerstatic java.lang.String
getOfferText()
Returns the text in the offer screen for whether it says Buy offer or Sell offerstatic int
getOpenSlot()
Returns the index of the open slot / offerstatic int
getOpenSlots()
Gets the number of slots that do not have an item and are enabledstatic java.lang.String
getSearchedItem()
Gets the currently typed item in the search bar of the GE If no item is typed, widget is not visible, or buy screen is not open it will return "" NOT NULLstatic int
getUsedSlots()
Gets the number of slots that contain an item SeeslotContainsItem(int)
static boolean
goBack()
Clicks the back button in the offer screenstatic boolean
isBuyOpen()
Checks if the buying screen of the Grand Exchange is open.static boolean
isGeneralOpen()
Checks if the general Grand Exchange is openstatic boolean
isOpen()
Returns if the Grand Exchange is open or notstatic boolean
isReadyToCollect()
Checks if any slot is done selling/buying and is ready to collectstatic boolean
isReadyToCollect(int slot)
Checks if the slot is done selling/buying and is ready to collect.static boolean
isSearchOpen()
Checks to see if the search item name widget is visiblestatic boolean
isSellOpen()
Checks if the selling screen of the Grand Exchange is openstatic boolean
isSlotEnabled(int slot)
Checks if the specified slot is enabled.static boolean
itemVisible(WidgetChild item)
Checks to see if the searched item widget is visible in the item container under the search item textstatic boolean
open()
Opens nearest Grand Exchange boothstatic boolean
open(java.lang.String action)
Opens the nearest Grand Exchange booth using the specified action.static boolean
openBuyScreen(int slot)
Opens the buy screen in the Grand Exchange of the specified slot.static boolean
openSellScreen(int slot)
Opens the sell screen in the Grand Exchange of the specified slot.static boolean
openSlotInterface(int slot)
Opens the general slot interface when a slot has an item in itstatic boolean
readyToEnterAmount()
Checks to see if the Dialogue can enter input with text "How many do you wish to" seeDialogues.canEnterInput(String)
"How many do you wish to"static boolean
readyToEnterPrice()
Checks to see if the Dialogue can enter input with text "Set a price for each item:" seeDialogues.canEnterInput(String)
"Set a price for each item:"static boolean
scrollToItem(WidgetChild item)
Scrolls to the provided widget in the item search containerstatic boolean
searchItem(java.lang.String itemName)
Searches for an item in the buy screenstatic boolean
sellItem(int itemId, int amount, int price)
Puts an item up for sale in the Grand Exchangestatic boolean
sellItem(java.lang.String itemName, int amount, int price)
Puts an item up for sale in the Grand Exchangestatic boolean
setPrice(int amount)
Sets the price of the current buy/sell offer.static boolean
setQuantity(int amount)
Sets the quantity of a buy/sell offerstatic boolean
slotContainsItem(int slot)
Checks if there's an item in the slot specified
-
-
-
Method Detail
-
open
public static boolean open(java.lang.String action)
Opens the nearest Grand Exchange booth using the specified action.- Parameters:
action
- Action to use when opening booth- Returns:
- True if interaction returns true else false
-
open
public static boolean open()
Opens nearest Grand Exchange booth- Returns:
- true if interaction with booth is successful else false.
-
isOpen
public static boolean isOpen()
Returns if the Grand Exchange is open or not- Returns:
- True if open, else False
-
isGeneralOpen
public static boolean isGeneralOpen()
Checks if the general Grand Exchange is open- Returns:
- True if it's open, else false.
-
isSellOpen
public static boolean isSellOpen()
Checks if the selling screen of the Grand Exchange is open- Returns:
- True if open, else False
-
getOpenSlot
public static int getOpenSlot()
Returns the index of the open slot / offer- Returns:
- index of the open slot, -1 if none are open
-
isBuyOpen
public static boolean isBuyOpen()
Checks if the buying screen of the Grand Exchange is open.
-
isSearchOpen
public static boolean isSearchOpen()
Checks to see if the search item name widget is visible
-
getOfferText
public static java.lang.String getOfferText()
Returns the text in the offer screen for whether it says Buy offer or Sell offer
-
openSellScreen
public static boolean openSellScreen(int slot)
Opens the sell screen in the Grand Exchange of the specified slot.- Parameters:
slot
- Slot to open- Returns:
- true if interaction with the Sell offer button returns true, false if slot contains item or interaction fails
-
openBuyScreen
public static boolean openBuyScreen(int slot)
Opens the buy screen in the Grand Exchange of the specified slot.- Parameters:
slot
- Slot to open- Returns:
- true if interaction with the Buy offer button returns true, false if slot contains item or interaction fails
-
openSlotInterface
public static boolean openSlotInterface(int slot)
Opens the general slot interface when a slot has an item in it- Parameters:
slot
- slot to open- Returns:
- false if slot doesn't contain item or interaction fails, true if interaction is successful
-
addSellItem
public static boolean addSellItem(java.lang.String itemName)
Adds an item to the sell offer- Parameters:
itemName
- Item name to add to offer- Returns:
- True if inventory contains item and interaction is successful
-
addSellItem
public static boolean addSellItem(Item item)
Adds an item to the sell offer- Parameters:
item
- Item to offer- Returns:
- True if inventory contains item and interaction is successful
-
searchItem
public static boolean searchItem(java.lang.String itemName)
Searches for an item in the buy screen- Parameters:
itemName
- name of item to search for- Returns:
- false if the buy screen isn't open otherwise true
-
getSearchedItem
public static java.lang.String getSearchedItem()
Gets the currently typed item in the search bar of the GE If no item is typed, widget is not visible, or buy screen is not open it will return "" NOT NULL- Returns:
- Typed name in search bar or ""
-
addBuyItem
public static boolean addBuyItem(java.lang.String itemName)
Adds an item to the buy offer Now checks if there's already an item selected, if it's the wrong item it will attempt to click the back button instead.- Parameters:
itemName
- name of item to add- Returns:
- false if searchItem returns false, otherwise return interaction result
-
addBuyItem
public static boolean addBuyItem(Item item)
Adds an item to the buy offer Now checks if there's already an item selected, if it's the wrong item it will attempt to click the back button instead.- Parameters:
item
- The item to add- Returns:
- false if searchItem returns false, otherwise return interaction result
-
itemVisible
public static boolean itemVisible(WidgetChild item)
Checks to see if the searched item widget is visible in the item container under the search item text- Parameters:
item
-WidgetChild
representing the item you're looking for- Returns:
- true if the rectangle is visible else false
-
scrollToItem
public static boolean scrollToItem(WidgetChild item)
Scrolls to the provided widget in the item search container- Parameters:
item
-WidgetChild
to search for- Returns:
- True if successfully scrolls to the widget
-
getItemChildInSearch
public static WidgetChild getItemChildInSearch(java.lang.String itemName)
Gets the widget child of the item you searched for- Parameters:
itemName
- name of item you searched for- Returns:
- WidgetChild if found, else null
-
getItemChildInSearch
public static WidgetChild getItemChildInSearch(java.lang.String name, int id)
Gets theWidgetChild
of the item you searched for- Parameters:
name
- name of the item you searched forid
- ID of the item you searched for, -1 if you don't want to check by ID- Returns:
WidgetChild
of the item you searched for
-
setQuantity
public static boolean setQuantity(int amount)
Sets the quantity of a buy/sell offer- Parameters:
amount
- Integer value of quantity you want to set- Returns:
- true if current set quantity is equal to your specified amount, else return interaction result
-
setPrice
public static boolean setPrice(int amount)
Sets the price of the current buy/sell offer.- Parameters:
amount
- Integer value of the price you want it to be- Returns:
- true if current price is equal to your specified price, else return interaction result
-
readyToEnterAmount
public static boolean readyToEnterAmount()
Checks to see if the Dialogue can enter input with text "How many do you wish to" seeDialogues.canEnterInput(String)
"How many do you wish to"
-
readyToEnterPrice
public static boolean readyToEnterPrice()
Checks to see if the Dialogue can enter input with text "Set a price for each item:" seeDialogues.canEnterInput(String)
"Set a price for each item:"
-
getOfferFirstItemWidget
public static WidgetChild getOfferFirstItemWidget()
Gets the WidgetChild of the first item slot of the open offer- Returns:
- WidgetChild or null if the offer screen isn't open
-
getOfferSecondItemWidget
public static WidgetChild getOfferSecondItemWidget()
Gets the WidgetChild of the second item slot of the open offer- Returns:
- WidgetChild or null if the offer screen isn't open
-
getEnterQuantityButton
public static WidgetChild getEnterQuantityButton()
Gets the WidgetChild of the "Enter Quantity" button- Returns:
- WidgetChild of the button or null
-
getEnterAllButton
public static WidgetChild getEnterAllButton()
Gets the Enter All button in the offer screen- Returns:
- WidgetChild of the enter all button or null
-
getCurrentPrice
public static int getCurrentPrice()
Gets the currently set price of the offer based on the player settings- Returns:
- Value of the player setting for the current price, if no offer is up then -1
-
getCurrentAmount
public static int getCurrentAmount()
Gets the current quantity set based on the player setting for current amount- Returns:
- Integer value of player setting, or if no offer is currently made then -1
-
getEnterPriceButton
public static WidgetChild getEnterPriceButton()
Gets the Enter Price WidgetChild in the offer screen- Returns:
- WidgetChild of the enter price button or null
-
getGuidePriceButton
public static WidgetChild getGuidePriceButton()
Gets the Guide Price WidgetChild in the offer screen- Returns:
- WidgetChild of the guide price button or null
-
getDecreasePriceFivePercentButton
public static WidgetChild getDecreasePriceFivePercentButton()
Gets the -5% price WidgetChild in the offer screen- Returns:
- WidgetChild of the -5% price button or null
-
getIncreasePriceFivePercentButton
public static WidgetChild getIncreasePriceFivePercentButton()
Gets the +5% price WidgetChild in the offer screen- Returns:
- WidgetChild of the +5% price button or null
-
getDecreasePriceXPercentButton
public static WidgetChild getDecreasePriceXPercentButton()
Gets the -X% price WidgetChild in the offer screen- Returns:
- WidgetChild of the -X% price button or null
-
getIncreasePriceXPercentButton
public static WidgetChild getIncreasePriceXPercentButton()
Gets the +X% price WidgetChild in the offer screen- Returns:
- WidgetChild of the +X% price button or null
-
close
public static boolean close()
Closes the GrandExchange screen If close interface with ESC is enabled, will use esc key to close interface- Returns:
- True if the interaction is successful or the GrandExchange isn't open, else False
-
getCloseButton
public static WidgetChild getCloseButton()
-
sellItem
public static boolean sellItem(java.lang.String itemName, int amount, int price)
Puts an item up for sale in the Grand Exchange- Parameters:
itemName
- Name of item to put up for sale- Returns:
- True if item successfully gets put up for sale, else False
-
sellItem
public static boolean sellItem(int itemId, int amount, int price)
Puts an item up for sale in the Grand Exchange- Parameters:
itemId
- Id of item to put up for sale- Returns:
- True if item successfully gets put up for sale, else False
-
buyItem
public static boolean buyItem(java.lang.String itemName, int amount, int price)
Puts in a buy order in the Grand Exchange- Parameters:
itemName
- Name of item to buyamount
- Amount of the item to buyprice
- Price per item to pay- Returns:
- True if buy order is successfully placed, else False
-
buyItem
public static boolean buyItem(int itemId, int amount, int price)
Puts in a buy order in the Grand Exchange- Parameters:
itemId
- ID of item to buyamount
- Amount of the item to buyprice
- Price per item to pay- Returns:
- True if buy order is successfully placed, else False
-
confirm
public static boolean confirm()
Confirms the offer in the Grand Exchange- Returns:
- True if interaction with the confirm button was successful, else False
-
goBack
public static boolean goBack()
Clicks the back button in the offer screen- Returns:
- True if neither buy or sell screen is open else return interaction results with back widget
-
cancelOffer
public static boolean cancelOffer(int slot)
Aborts the current offer in the slot specified in the Grand Exchange Works with buy/sell open or from main ge screen- Parameters:
slot
- 0-7 inclusive- Returns:
- True if interaction with the slot was successful, else False
-
cancelAll
public static boolean cancelAll()
Cancels all available offers If inside an offer, will cancel inside the offer, otherwise it will cancel from main screen- Returns:
- true if all offers are successfully canceled, false if any offers fail to cancel
-
collect
public static boolean collect()
Presses the collect button on the main interface, collects to inventory- Returns:
- false if not ready to collect, else return interaction result
-
collectToBank
public static boolean collectToBank()
Uses the collect button to collect everything directly to the bank- Returns:
- false if not ready to collect, else return interaction result
-
isReadyToCollect
public static boolean isReadyToCollect(int slot)
Checks if the slot is done selling/buying and is ready to collect. SeeGrandExchangeItem.isReadyToCollect()
- Parameters:
slot
- Slot to check- Returns:
- True if ready to collect, else false
-
isReadyToCollect
public static boolean isReadyToCollect()
Checks if any slot is done selling/buying and is ready to collect- Returns:
- True if any slot is ready to be collected, else false
-
slotContainsItem
public static boolean slotContainsItem(int slot)
Checks if there's an item in the slot specified- Parameters:
slot
- 0-8 inclusive- Returns:
- True if slot has an item, else False
-
getFirstOpenSlot
public static int getFirstOpenSlot()
Gets the number of the first open slot- Returns:
- -1 if no slots open, otherwise 0 through 7 inclusive
-
isSlotEnabled
public static boolean isSlotEnabled(int slot)
Checks if the specified slot is enabled.- Parameters:
slot
- Slot to check- Returns:
- True if there's an item in the slot or the actions list size is greater than 0
-
getItems
public static GrandExchangeItem[] getItems()
Gets an array of the GrandExchangeItems- Returns:
- Array of GrandExchangeItems size 8
-
getCurrentChosenItemID
public static int getCurrentChosenItemID()
Gets the current chosen Item ID from the Set Up Buy/Sell Offer menu in the GE- Returns:
- -1 if the GE is closed, otherwise whatever the player setting says
-
getLastChosenItemID
public static int getLastChosenItemID()
Gets the Item ID of the last chosen buy item- Returns:
- ID of the last chosen buy item
-
getCurrentChosenItem
public static Item getCurrentChosenItem()
Gets the Item based on the ID returned fromgetCurrentChosenItemID()
- Returns:
- if ID is -1, returns null, otherwise returns Item based on the ID
-
getLastChosenItem
public static Item getLastChosenItem()
Gets the last chosen buy Item based on the ID returned fromgetLastChosenItemID()
- Returns:
-
getUsedSlots
public static int getUsedSlots()
Gets the number of slots that contain an item SeeslotContainsItem(int)
-
getOpenSlots
public static int getOpenSlots()
Gets the number of slots that do not have an item and are enabled
-
contains
public static boolean contains(java.lang.Integer... ids)
Checks if your collection contains one item which meets one of the specified ids.- Parameters:
ids
- Item IDs to check for- Returns:
- True if contains one of, else false
-
contains
public static boolean contains(int[] ids)
-
contains
public static boolean contains(java.lang.String... names)
Checks if your collection contains one item which meets one of the specified names.- Parameters:
names
- names to check for- Returns:
- true if contains one of, else false.
-
contains
public static boolean contains(Filter<Item> filter)
Checks if your collection contains one item which meets the specified filter.- Parameters:
filter
- the filter to search with.- Returns:
- true if contains one of, else false.
-
getItem
public static GrandExchangeItem getItem(java.lang.Integer... ids)
Gets aGrandExchangeItem
that matches one of the given ID's- Parameters:
ids
- Item IDs to search for- Returns:
- GrandExchangeItem if found, else null
-
getItem
public static GrandExchangeItem getItem(int[] ids)
-
getItem
public static GrandExchangeItem getItem(java.lang.String... names)
Gets aGrandExchangeItem
that matches one of the given names- Parameters:
names
- names to search for- Returns:
- GrandExchangeItem if found, else null
-
getItem
public static GrandExchangeItem getItem(Filter<Item> filter)
Gets aGrandExchangeItem
that matches one of the given filter- Parameters:
filter
- the filter to search with.- Returns:
- GrandExchangeItem if found, else null
-
-