Package dev.twilite.game.loadout
Class Restocker
java.lang.Object
dev.twilite.game.loadout.Restocker
- All Implemented Interfaces:
ItemDepletionListener
Grand Exchange restocking helper that can be used as a loadout depletion listener.
Register preferred restock quantities with item(int, int), attach the restocker to an
InventoryLoadout using InventoryLoadout.depletionListener(ItemDepletionListener),
and call tick() while the script is in its restocking branch. Each call performs at
most one meaningful Grand Exchange step so client state can update between calls.
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAllows the restocker to withdraw a Grand Exchange teleport from a nearby bank before walking there.allowWithdrawTeleports(boolean allowWithdrawTeleports) Sets whether the restocker may withdraw a Grand Exchange teleport from a nearby bank before walking there.voidclear()Clears all queued requests but keeps configured restock quantities.static Restockercreate()Creates an empty restocker.defaultAmount(int amount) Sets the fallback amount for depleted items that do not have an explicit restock entry.Sets the default price resolver for newly registered restock entries.defaultCollectionMode(GrandExchange.CollectionMode collectionMode) Sets where completed restock offers should be collected.defaultMaxRetries(int retries) Sets how many times a stale active offer may be aborted and repriced.defaultRetryAfterTicks(int ticks) Sets how long an active offer may sit before it is aborted and retried.defaultSellPrice(GrandExchange.Price sellPrice) Sets the default price resolver for sell requests.booleanempty()Returns whether no restock entries are currently queued.item(int itemId, int amount) Registers a restock entry using the restocker's default price resolver.item(int itemId, int amount, GrandExchange.Price price) Registers a restock entry.items()Returns all configured restock entries.voidonDeplete(LoadoutItem item) Called by loadouts when a required item is missing from the bank.queued()Returns queued restock entries.request(int itemId) Queues a restock request for an item id.request(int itemId, int amount) Queues a restock request for an item id and amount.request(LoadoutItem item) Queues the configured restock entry for a depleted loadout item.requestSell(int itemId) Queues a configured sell request.requestSell(int itemId, int amount) Queues a sell request for an item id and amount.sell(int itemId, int amount) Queues a sell request using the restocker's default sell price resolver.sell(int itemId, int amount, GrandExchange.Price price) Queues a sell request.voidtick()Progresses collection, buying, and selling for queued restock entries.
-
Constructor Details
-
Restocker
public Restocker()
-
-
Method Details
-
create
Creates an empty restocker. -
defaultAmount
Sets the fallback amount for depleted items that do not have an explicit restock entry. -
defaultRetryAfterTicks
Sets how long an active offer may sit before it is aborted and retried. -
defaultMaxRetries
Sets how many times a stale active offer may be aborted and repriced. -
defaultBuyPrice
Sets the default price resolver for newly registered restock entries. -
defaultSellPrice
Sets the default price resolver for sell requests. -
defaultCollectionMode
Sets where completed restock offers should be collected. -
allowWithdrawTeleports
Allows the restocker to withdraw a Grand Exchange teleport from a nearby bank before walking there. -
allowWithdrawTeleports
Sets whether the restocker may withdraw a Grand Exchange teleport from a nearby bank before walking there. -
item
Registers a restock entry using the restocker's default price resolver. -
item
Registers a restock entry. -
sell
Queues a sell request using the restocker's default sell price resolver. -
sell
Queues a sell request. -
request
Queues a restock request for an item id. -
request
Queues a restock request for an item id and amount. -
requestSell
Queues a configured sell request. -
requestSell
Queues a sell request for an item id and amount. -
request
Queues the configured restock entry for a depleted loadout item. -
onDeplete
Called by loadouts when a required item is missing from the bank.- Specified by:
onDepletein interfaceItemDepletionListener
-
queued
Returns queued restock entries. -
items
Returns all configured restock entries. -
empty
public boolean empty()Returns whether no restock entries are currently queued. -
clear
public void clear()Clears all queued requests but keeps configured restock quantities. -
tick
public void tick()Progresses collection, buying, and selling for queued restock entries.
-