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 openacceptFirstScreen()→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 opendeclineFirstScreen()→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; returnsTRADE_ITEM_NOT_FOUNDif 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_OPENwhen neither trade screen is visible. offerusesInventory.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().