Class Trade

java.lang.Object
dev.twilite.game.facade.Trade

public class Trade extends Object
Helpers for the player-to-player trade interfaces.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    Accessors for the trade offer panel represented by the other side of the API.
    static enum 
    Trade interface state.
    static class 
    Accessors for the trade offer panel represented by this side of the API.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    Clicks the visible trade Accept button.
    static void
    Clicks the visible trade Decline button.
    static void
    offer(Function<ItemView,Optional<Item>> query, int amount)
    Offers an inventory item into the trade.
    static void
    remove(Function<ItemView,Optional<Item>> query, int amount)
    Removes an item from the trade offer.
    Returns the currently open trade screen.
    static boolean
    Returns whether either trade screen is currently visible.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Trade

      public Trade()
  • Method Details

    • screen

      public static Trade.Screen screen()
      Returns the currently open trade screen.
      Returns:
      Trade.Screen.MAIN for the first trade screen, Trade.Screen.CONFIRM for the second confirmation screen, or Trade.Screen.CLOSED when no trade interface is visible.
    • showing

      public static boolean showing()
      Returns whether either trade screen is currently visible.
    • accept

      public static void accept()
      Clicks the visible trade Accept button.

      This works on both the main trade screen and the confirmation screen. If no trade screen is open, this method does nothing.

    • decline

      public static void decline()
      Clicks the visible trade Decline button.

      This works on both the main trade screen and the confirmation screen. If no trade screen is open, this method does nothing.

    • offer

      public static void offer(Function<ItemView,Optional<Item>> query, int amount)
      Offers an inventory item into the trade.

      The query is applied to Inventory.items(). The method chooses a direct amount action when available, falls back to Offer-All when the requested amount is at least the available amount, otherwise uses Offer-X and submits the amount.

      Parameters:
      query - item selector applied to the carried inventory
      amount - amount to offer; values below 1 are treated as 1
    • remove

      public static void remove(Function<ItemView,Optional<Item>> query, int amount)
      Removes an item from the trade offer.

      The query is applied to Trade.Theirs.items(). The method chooses a direct amount action when available, falls back to Remove-All when the requested amount is at least the available amount, otherwise uses Remove-X and submits the amount.

      Parameters:
      query - item selector applied to the trade offer item view
      amount - amount to remove; values below 1 are treated as 1