Class Trade

java.lang.Object
privbot.hooks.Trade

public final class Trade extends Object
Trade interface state and interaction via Client and the game client.
  • Method Details

    • isFirstScreenOpen

      public boolean isFirstScreenOpen()
      Returns:
      whether the first trade screen is drawn; false when unreadable
    • isSecondScreenOpen

      public boolean isSecondScreenOpen()
      Returns:
      whether the confirmation screen is drawn; false when unreadable
    • isOpen

      public boolean isOpen()
      Returns:
      whether either trade screen is drawn
    • accept

      public boolean accept()
      Accepts the trade screen that is open (the confirmation screen first).
      Returns:
      dispatch acceptance; false when no trade screen is open
    • requestOption

      public boolean requestOption(PrivPlayer player, String optionPrefix, String option)
      Sends a player right-click option (optionPrefix, e.g. "Trade with") on Impact, Elorin and SpawnPK, the way the client's own click on that option is sent; a replayed menu action without the server's option code would be silently dropped.
    • acceptRequest

      public boolean acceptRequest(String playerName)
      Accept an INCOMING trade request from playerName — the chat link, not the trade screen. Needs TRADE_ACCEPT_REQUEST: on Elorin op 484, whose handler finds the player by the entry's target name and sends the accept packet.
    • request

      public boolean request(PrivPlayer player)
      Requests a trade with player, the way the client's own Trade with click is sent.
    • decline

      public boolean decline()
      Returns:
      dispatch acceptance of Decline on the first screen; false when it is not open
    • getMyOffer

      public List<Integer> getMyOffer()
      Returns:
      item ids in our offer (empty when none or unreadable)
    • getTheirOffer

      public List<Integer> getTheirOffer()
      Returns:
      item ids in the other player's offer (empty when none or unreadable)
    • offerAll

      public boolean offerAll(int slot, int itemId)
      Offers the entire stack in one inventory slot on the first trade screen.

      Trade options replace the ordinary inventory actions while group 335 is open. Offer-All is the fifth option, so preserving the live slot, inventory widget and item id lets the Impact mapper emit the server's native fifth-inventory-option packet instead of guessing a widget.

    • offerAll

      public boolean offerAll(int slot, int itemId, String itemName)
      Offers a whole stack from the trade screen's inventory, the way the client's own Offer-All click is sent.
    • offerAll

      public boolean offerAll(String name)
      Offers the first inventory stack matching name.
    • acceptFirst

      public boolean acceptFirst()
      Accepts the first trade screen, the way the client's own Accept click is sent.
    • acceptSecond

      public boolean acceptSecond()
      Accepts the second trade screen, the way the client's own Accept click is sent.