Skip to main content

Inventory Plan

InventoryPlan describes inventory requirements before a workflow step runs. It can use the live inventory or a test snapshot.

Example:

InventoryPlan plan = InventoryPlan.create()
.require(561, 100)
.requireFreeSlots(2);

if (!plan.satisfied()) {
log.debug(plan.describeMissing());
}

Testing with a snapshot:

InventoryPlan plan = InventoryPlan.create(new InventoryPlan.InventorySnapshot() {
public int count(int itemId) {
return itemId == 561 ? 50 : 0;
}

public int freeSlots() {
return 1;
}
});

Behavior:

  • Required item amounts are clamped to zero or above.
  • Required free slots keep the highest requested value.
  • describeMissing() reports item counts and free slot deficits.

Gate A Workflow Step

Use an inventory plan before an action that would fail noisily without required items or free space.

InventoryPlan runesForTeleport = InventoryPlan.create()
.require(563, 1) // Law rune
.require(556, 3) // Air rune
.requireFreeSlots(1);

if (!runesForTeleport.satisfied()) {
log.debug("Cannot teleport yet: {}", runesForTeleport.describeMissing());
return StepResult.waitTicks(1, "Waiting for teleport supplies");
}

InteractionResult result = MagicActions.cast(TeleportSpell.FALADOR_TELEPORT);
return result.failed()
? StepResult.failed(result.getMessage())
: StepResult.success("Queued teleport");

Pure Unit Tests

Snapshots let tests cover missing-item and free-slot logic without a RuneLite client.

InventoryPlan.InventorySnapshot snapshot = new InventoryPlan.InventorySnapshot() {
public int count(int itemId) {
return itemId == 561 ? 50 : 0;
}

public int freeSlots() {
return 1;
}
};

InventoryPlan plan = InventoryPlan.create(snapshot)
.require(561, 100)
.requireFreeSlots(2);

assertFalse(plan.satisfied());
assertTrue(plan.describeMissing().contains("561"));