Package rs.kreme.ksbot.api.hooks
Class Trade
- java.lang.Object
-
- rs.kreme.ksbot.api.hooks.Trade
-
public class Trade extends java.lang.Object
This class provides methods for managing player trades, including initiating trades, verifying trade partners, and interacting with trade items.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
Trade.Inventory
-
Constructor Summary
Constructors Constructor Description Trade()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
acceptTrade()
Accepts the trade or confirmation screen.void
declineTrade()
Declines the trade or confirmation screen.int
getTheirTradeValue()
Retrieves the total value of the other player's offered items in the trade.int
getTradeState()
Gets the current trade state.int
getYourTradeValue()
Retrieves the total value of your offered items in the trade.boolean
hasActiveTradeRequest()
Checks if there's an active trade request (within the last 30 seconds).boolean
isOpen()
Checks if the trade screen or confirmation screen is open.void
offer(int itemId, int quantity)
Offers an item by ID and quantity to the trade.void
offer(java.lang.String itemName, int quantity)
Offers an item by name and quantity to the trade.void
offer(KSItem item, int quantity)
Offers a KSItem object to the trade.void
onChatMessage(net.runelite.api.events.ChatMessage message)
Event listener for chat messages to detect trade requests.ItemQuery
query(boolean yours)
void
remove(int item, int quantity)
void
remove(java.lang.String item, int quantity)
void
remove(KSItem item, int quantity)
boolean
sendTradeOffer(java.lang.String playerName)
Sends a trade offer to the player by name.boolean
sendTradeOffer(KSPlayer player)
Sends a trade offer to the given player.boolean
waitingForThem()
Checks if you are waiting for the other player to accept the trade.boolean
waitingForYou()
Checks if the other player is waiting for you to accept the trade.
-
-
-
Method Detail
-
query
public ItemQuery query(boolean yours)
-
isOpen
public boolean isOpen()
Checks if the trade screen or confirmation screen is open.- Returns:
- True if either trade or confirm screen is open, false otherwise.
-
getTradeState
public int getTradeState()
Gets the current trade state.- Returns:
- 1 if in the first trade screen, 2 if in the confirmation screen, -1 if not open.
-
getYourTradeValue
public int getYourTradeValue()
Retrieves the total value of your offered items in the trade.- Returns:
- Integer value representing your trade value.
-
getTheirTradeValue
public int getTheirTradeValue()
Retrieves the total value of the other player's offered items in the trade.- Returns:
- Integer value representing the other player's trade value.
-
acceptTrade
public void acceptTrade()
Accepts the trade or confirmation screen.
-
declineTrade
public void declineTrade()
Declines the trade or confirmation screen.
-
waitingForThem
public boolean waitingForThem()
Checks if you are waiting for the other player to accept the trade.- Returns:
- True if waiting for the other player, false otherwise.
-
waitingForYou
public boolean waitingForYou()
Checks if the other player is waiting for you to accept the trade.- Returns:
- True if they are waiting for you, false otherwise.
-
offer
public void offer(java.lang.String itemName, int quantity)
Offers an item by name and quantity to the trade.- Parameters:
itemName
- The name of the item to offer.quantity
- The quantity of the item to offer.
-
offer
public void offer(int itemId, int quantity)
Offers an item by ID and quantity to the trade.- Parameters:
itemId
- The ID of the item to offer.quantity
- The quantity of the item to offer.
-
offer
public void offer(KSItem item, int quantity)
Offers a KSItem object to the trade.- Parameters:
item
- The KSItem to offer.quantity
- The quantity of the item to offer.
-
remove
public void remove(KSItem item, int quantity)
-
remove
public void remove(int item, int quantity)
-
remove
public void remove(java.lang.String item, int quantity)
-
sendTradeOffer
public boolean sendTradeOffer(KSPlayer player)
Sends a trade offer to the given player.- Parameters:
player
- The KSPlayer to send the trade offer to.- Returns:
- True if the trade offer was sent, false otherwise.
-
sendTradeOffer
public boolean sendTradeOffer(java.lang.String playerName)
Sends a trade offer to the player by name.- Parameters:
playerName
- The name of the player to send the trade offer to.- Returns:
- True if the trade offer was sent, false otherwise.
-
hasActiveTradeRequest
public boolean hasActiveTradeRequest()
Checks if there's an active trade request (within the last 30 seconds).- Returns:
- True if there is an active trade request, false otherwise.
-
onChatMessage
@Subscribe public void onChatMessage(net.runelite.api.events.ChatMessage message)
Event listener for chat messages to detect trade requests.- Parameters:
message
- The ChatMessage event.
-
-