Class Restock

java.lang.Object
privbot.hooks.Restock

public final class Restock extends Object
Bank to a gear setup: ctx.restock.

to(RestockTarget) (every server). A job that opens the bank, deposits unwanted items, withdraws what the worn and carried setups lack and puts the worn pieces on, proving each item. Use it on every server:


 Job restock = ctx.restock.to(RestockTarget.builder()
         .worn(ctx.loadouts.load("zulrah").get()).carried(supplies).build());
 // each tick, from one node: restock.step(ctx) until restock.state().finished()
 

run(Request) (deprecated) goes home and re-gears with whatever this server provides:

  • Impact: the shared home restock (loadout, home recording, expected change): replays the home-teleport Action Recording, waits to land, equips the loadout preset and checks it applied. One call runs the whole restock (blocking);
  • Elorin: the shared RestockRunner (shared by the boss plugins): home spell, the restore pool, the bank's last preset, the teleport back. One call runs ONE confirmed step of the plugin's RestockCycle; call it from one node while cycle.active(). The plugin owns the cycle (it calls cycle.begin(why, now)) and the RestockHost;
  • every other server: UNSUPPORTED (false and one [PrivBot API] line).
Call from a TaskNode's execute on the script worker. A request missing what this server needs answers false with the reason logged.

 Restock.Request req = Restock.request()
         .loadout(config.loadout()).homeRecording(config.homeRecording())     // Impact
         .cycle(runState.restock).host(restockHost).taskContext(ctx)         // Elorin
         .build();
 ctx.restock.run(req);
 
  • Method Details

    • request

      public static Restock.Builder request()
      Returns:
      a new request builder
    • to

      public Job to(RestockTarget target)
      Starts a job that banks until the player wears target.worn() and carries target.carried(), the same on every server (Impact, Elorin, Orion, SpawnPK, Roat Pkz). Stand at (or next to) a bank first; travel is not part of it.

      Each step is at most one action, then at most 2400 ms waiting for its proof. The order:

      1. the preset, when the target names one and this server has a preset button (Impact loadouts 1..6, Elorin "Last-preset"). Presets may replace the inventory, so with depositFirst unwanted items are banked first (open, deposit, close). The job then waits, across steps, until the preset lands or its confirm window (Elorin 10 s) passes. A preset is never proof: whatever it did not bring is withdrawn;
      2. missing worn pieces, and worn ammunition below its captured quantity (worn + carried): open the bank (the open is always sent, whatever the bank reads), deposit unwanted items, withdraw each by item id (Withdraw-All when the bank holds no more than is needed);
      3. close the bank and put the worn pieces on, one per step;
      4. reopen, deposit unwanted items (gear swapped out included), withdraw each carried shortfall by item id;
      5. close the bank. A target already met never opens it.

      What it proves: DONE ("restocked") only after readable equipment and inventory reads satisfy both setups and, with depositFirst, show nothing unwanted carried. Every withdrawal is proved by that item's carried count rising, a deposit by free slots rising, a worn piece by its slot holding it. FAILED reasons, in plain words: "empty target: nothing to restock to", "bank did not open", "bank has none: <name>", "could not withdraw: <name>", "inventory full: no room for <name>", "the inventory did not deposit", "<name> did not go on", "setup cannot all be worn at once (e.g. two-handed + shield)", "could not click <name>", "restock did not settle in 500 steps".

      Unreadable looks like: an unreadable bank state, inventory or equipment keeps the job RUNNING with reason "<what> unreadable" and never counts as "missing" or "closed"; five in a row end it FAILED with that reason.

      Thread rule: step it from one node on the script worker; reads marshal themselves and waits use PrivTaskContext.sleepUntil(java.util.function.BooleanSupplier, int). Not thread-safe.

      Parameters:
      target - what to end with
      Returns:
      a new job (already FAILED for an empty target)
    • run

      @Deprecated public boolean run(Restock.Request request)
      Deprecated.
      server-specific and unproved (Impact and Elorin only); use to(RestockTarget), which banks to a worn and carried setup on every server and proves each item
      Runs this server's restock (Impact: the whole restock; Elorin: one step of the cycle).
      Parameters:
      request - what this server needs
      Returns:
      Impact: true when the restock succeeded; Elorin: true when a step ran; false otherwise