Package dev.twilite.game.facade
Class Trade
java.lang.Object
dev.twilite.game.facade.Trade
Helpers for the player-to-player trade interfaces.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classAccessors for the trade offer panel represented by the other side of the API.static enumTrade interface state.static classAccessors for the trade offer panel represented by this side of the API. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaccept()Clicks the visible trade Accept button.static voiddecline()Clicks the visible trade Decline button.static voidOffers an inventory item into the trade.static voidRemoves an item from the trade offer.static Trade.Screenscreen()Returns the currently open trade screen.static booleanshowing()Returns whether either trade screen is currently visible.
-
Constructor Details
-
Trade
public Trade()
-
-
Method Details
-
screen
Returns the currently open trade screen.- Returns:
Trade.Screen.MAINfor the first trade screen,Trade.Screen.CONFIRMfor the second confirmation screen, orTrade.Screen.CLOSEDwhen 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
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 inventoryamount- amount to offer; values below 1 are treated as 1
-
remove
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 viewamount- amount to remove; values below 1 are treated as 1
-