Skip to main content

Trade Actions

TradeActions handles writes on the two-screen player trade interface: offering items, accepting, and declining.

Action Methods

  • accept()InteractionResult - accepts whichever screen is currently open
  • acceptFirstScreen()InteractionResult - clicks accept on first screen (group 335, child 42)
  • acceptSecondScreen()InteractionResult - clicks accept on confirm screen (group 334, child 13)
  • decline()InteractionResult - declines whichever screen is currently open
  • declineFirstScreen()InteractionResult - clicks decline (group 335, child 43)
  • declineSecondScreen()InteractionResult - clicks decline (group 334, child 14)
  • offer(int itemId, int quantity)InteractionResult - finds item in inventory and offers it; returns TRADE_ITEM_NOT_FOUND if not in inventory

Example:

InteractionResult result = TradeActions.offer(ItemID.COINS_995, 1000);
if (result.failed() && result.getStatus() != InteractionStatus.PACED) {
log.debug("Offer failed: {}", result.getMessage());
}

Behavior notes:

  • All action methods return TRADE_NOT_OPEN when neither trade screen is visible.
  • offer uses Inventory.search().withId(itemId) to locate the item widget.
  • All write actions are paced through ActionPacer.

Inspect the current screen, acceptance state, and either side's item widgets through TradeQuery; see Query Helpers. Validate the other player's offer again on the confirmation screen before calling acceptSecondScreen().