Class Shop
java.lang.Object
privbot.hooks.Shop
High-level shop interaction: open an NPC's shop, then sell items from inventory
using the shop's widget actions (Sell 1 / Sell 5 / Sell 10 / Sell 50).
Selling is driven by the Widgets hook — it locates the requested action
slot via getActions() on each shop-inventory child widget and dispatches
the correct CC_OP packet. This keeps identifier math out of caller code and works
across servers that re-order actions.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intOSRS/RSPS default: shop stock list (group 300, child 16).static final intOSRS/RSPS default: the shop's player-inventory container (group 301, child 0). -
Method Summary
Modifier and TypeMethodDescriptionbooleanBuysquantityof the named stock item from the open shop, using the buy quantities this server's shop offers (ShopInterfaceon Impact, Elorin and SpawnPK; the shop-stock widget'sBuy 1/5/10/50actions elsewhere).booleanisOpen()True if the default shop widget is present and visible.booleanisOpen(int widgetId) booleanOpens an NPC's shop using"Trade"as the default action.booleanbooleanInteracts with the nearest NPC matchingnpcNameusingaction, then waits up totimeoutMsfor the shop widget to appear.intopenAndSell(String npcName, String npcAction, int postOpenDelayTicks, List<String> names, boolean partialMatch, boolean sellAllExcept, String option, int widgetId) Opens the NPC's shop, waitspostOpenDelayTicksgame ticks, then sells items.booleanSellsquantityof the named inventory item to the open shop, with the shop'sSell 1/5/10/50actions.intSells items from the open shop without any per-item delay.intsell(List, boolean, boolean, String)against a specific shop widget.
-
Field Details
-
DEFAULT_SHOP_WIDGET_ID
public static final int DEFAULT_SHOP_WIDGET_IDOSRS/RSPS default: the shop's player-inventory container (group 301, child 0).- See Also:
-
DEFAULT_SHOP_STOCK_WIDGET_ID
public static final int DEFAULT_SHOP_STOCK_WIDGET_IDOSRS/RSPS default: shop stock list (group 300, child 16).- See Also:
-
-
Method Details
-
isOpen
public boolean isOpen()True if the default shop widget is present and visible. -
isOpen
public boolean isOpen(int widgetId) - Parameters:
widgetId- the shop interface's widget id- Returns:
- whether that widget is present and visible
-
open
Opens an NPC's shop using"Trade"as the default action. -
open
-
open
Interacts with the nearest NPC matchingnpcNameusingaction, then waits up totimeoutMsfor the shop widget to appear. Returns true if the shop widget is visible at the end of the wait.No-op (returns true) if the shop is already open.
-
buy
Buysquantityof the named stock item from the open shop, using the buy quantities this server's shop offers (ShopInterfaceon Impact, Elorin and SpawnPK; the shop-stock widget'sBuy 1/5/10/50actions elsewhere). -
sell
Sellsquantityof the named inventory item to the open shop, with the shop'sSell 1/5/10/50actions. Not supported on Impact, Elorin and SpawnPK yet. -
sell
Sells items from the open shop without any per-item delay. Matches item names againstnames(case-insensitive, optionally partial). WhensellAllExceptis true,namesis treated as a keep-list and everything else is sold.- Parameters:
option- widget action to invoke (e.g."Sell 50","Sell 10")- Returns:
- number of items dispatched
-
sell
public int sell(List<String> names, boolean partialMatch, boolean sellAllExcept, String option, int widgetId) sell(List, boolean, boolean, String)against a specific shop widget.- Parameters:
names- item names (a keep-list whensellAllExcept)partialMatch- match names as substringssellAllExcept- sell everything not namedoption- the sell option (blank:Sell 50)widgetId- the shop interface's widget id- Returns:
- number of items dispatched
-
openAndSell
public int openAndSell(String npcName, String npcAction, int postOpenDelayTicks, List<String> names, boolean partialMatch, boolean sellAllExcept, String option, int widgetId) Opens the NPC's shop, waitspostOpenDelayTicksgame ticks, then sells items. Returns the number of items sold, or -1 if the shop failed to open.
-