Class WidgetPackets
- java.lang.Object
-
- com.kraken.api.core.packet.entity.WidgetPackets
-
public class WidgetPackets extends java.lang.ObjectA high-level utility class for sending widget-related game packets. This class abstracts the complexity of constructing and sending packets related to widget (interface) interactions, such as clicking buttons. It uses aPacketClientprovider to send the low-level packets, which are defined by thePacketDefFactory.
-
-
Constructor Summary
Constructors Constructor Description WidgetPackets()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidqueueDragAndDrop(net.runelite.api.widgets.Widget src, net.runelite.api.widgets.Widget dest)Queues the OPHELDD packet, which simulates a drag-and-drop action between two slots within the same or different widgets (e.g., moving an item in the inventory or bank).voidqueueResumeCount(int id)Queues the RESUME_COUNTDIALOG packet, sent in response to a numerical input dialog (e.g., "How many?" or "Enter amount").voidqueueResumeName(java.lang.String name)Queues the RESUME_NAMEDIALOG packet, sent in response to a chat dialog asking the player to enter a name (e.g., setting a clan name).voidqueueResumeObj(int value)Queues the RESUME_OBJDIALOG packet, typically sent as a continuation packet after selecting an option in a multi-choice dialog, where the value represents an item ID or object ID relevant to the dialog option.voidqueueResumePause(int packed)Queues the RESUME_PAUSEBUTTON packet, usually sent when interacting with non-interactable dialogs (e.g., "Click here to continue").voidqueueResumePause(int widgetId, int childId)Queues the RESUME_PAUSEBUTTON packet, typically sent when the player clicks a "Click here to continue" or "Close" button on a standard, non-interactable dialog, such as a dialogue with an NPC.voidqueueResumeString(java.lang.String string)Queues the RESUME_STRINGDIALOG packet, sent in response to a chat dialog asking the player to enter a generic string (e.g., a search query).voidqueueWidgetAction(net.runelite.api.widgets.Widget widget, java.lang.String... actionlist)Queues a widget action by searching for a specific action string (e.g., "Withdraw-1", "Bank").voidqueueWidgetActionPacket(int widgetId, int childId, int itemId, int actionFieldNo)Queues a low-level widget action packet (IF_BUTTONX).voidqueueWidgetOnWidget(int sourceWidgetId, int sourceSlot, int sourceItemId, int destinationWidgetId, int destinationSlot, int destinationItemId)Queues the raw IF_BUTTONT packet, simulating using an item/slot from a source widget on an item/slot of a destination widget.voidqueueWidgetOnWidget(net.runelite.api.widgets.Widget srcWidget, net.runelite.api.widgets.Widget destWidget)Queues a packet simulating the use of one widget item (source) on another widget item (destination).voidqueueWidgetSubAction(net.runelite.api.widgets.Widget widget, java.lang.String menu, java.lang.String action)Queues a widget sub-action packet by identifying the specific sub-action and menu options associated with a given widget.
-
-
-
Method Detail
-
queueWidgetActionPacket
public void queueWidgetActionPacket(int widgetId, int childId, int itemId, int actionFieldNo)Queues a low-level widget action packet (IF_BUTTONX).This method is a direct wrapper for the IF_BUTTONX packet, which is used for most widget interactions. It corresponds to one of the 10 "IF_BUTTON" opcodes (e.g., IF_BUTTON1, IF_BUTTON2, etc.).
- Parameters:
widgetId- The parent widget ID (e.g., WidgetInfo.BANK_CONTAINER.getId()).childId- The specific child widget index (slot) within the parent. -1 for no specific child.itemId- The item ID associated with the slot, if any. -1 for no item.actionFieldNo- The action number (1-10) to execute. This maps to the specific packet (e.g., 1 = IF_BUTTON1, 2 = IF_BUTTON2).
-
queueWidgetAction
public void queueWidgetAction(net.runelite.api.widgets.Widget widget, java.lang.String... actionlist)Queues a widget action by searching for a specific action string (e.g., "Withdraw-1", "Bank").This is a higher-level convenience method. Instead of needing to know the exact action number (1-10), you can provide the human-readable text of the action. The method will find the corresponding action number and send the correct packet.
- Parameters:
widget- TheWidgetobject to interact with.actionlist- A varargs list of action strings to search for. The method will use the *first* match it finds. The search is case-insensitive and ignores color tags.
-
queueWidgetSubAction
public void queueWidgetSubAction(net.runelite.api.widgets.Widget widget, java.lang.String menu, java.lang.String action)Queues a widget sub-action packet by identifying the specific sub-action and menu options associated with a given widget.This method identifies the indices of both a sub-action (from item definitions) and a specific menu option (from the widget's actions). If matches for both the sub-action and menu option are found, it sends a low-level packet to perform the action.
Only executes if the widget and its associated item ID are valid, while the sub-actions and menu options must contain the desired action and menu option.
- Parameters:
widget- TheWidgetinstance on which the action is to be performed. This is the target widget for the queued action.menu- A case-insensitive @<String> representing the menu action text to search for (e.g., "Use", "Examine").action- A case-insensitive @<String> representing the sub-action text to search for (e.g., "Clean", "Equip").
-
queueWidgetOnWidget
public void queueWidgetOnWidget(net.runelite.api.widgets.Widget srcWidget, net.runelite.api.widgets.Widget destWidget)Queues a packet simulating the use of one widget item (source) on another widget item (destination). This is typically used for "Use" menu actions like using a potion on a bank slot or an item on a piece of equipment.Delegates to the overloaded method using the raw IDs and indices.
- Parameters:
srcWidget- The source widget (e.g., the item being "used").destWidget- The destination widget (e.g., the item or slot being used "on").
-
queueWidgetOnWidget
public void queueWidgetOnWidget(int sourceWidgetId, int sourceSlot, int sourceItemId, int destinationWidgetId, int destinationSlot, int destinationItemId)Queues the raw IF_BUTTONT packet, simulating using an item/slot from a source widget on an item/slot of a destination widget.- Parameters:
sourceWidgetId- The ID of the source widget (interface).sourceSlot- The slot/index within the source widget.sourceItemId- The item ID within the source slot.destinationWidgetId- The ID of the destination widget (interface).destinationSlot- The slot/index within the destination widget.destinationItemId- The item ID within the destination slot.
-
queueResumePause
public void queueResumePause(int widgetId, int childId)Queues the RESUME_PAUSEBUTTON packet, typically sent when the player clicks a "Click here to continue" or "Close" button on a standard, non-interactable dialog, such as a dialogue with an NPC. The widget id should be a packed integer (containing both the group and child ids).- Parameters:
widgetId- The ID of the top-level widget (packed to include group and child ids).childId- The ID of the child component that was clicked.
-
queueResumePause
public void queueResumePause(int packed)
Queues the RESUME_PAUSEBUTTON packet, usually sent when interacting with non-interactable dialogs (e.g., "Click here to continue").This method sends a packet using the provided packed widget ID.
- Parameters:
packed- The packed widget ID, which includes both group and child IDs.
-
queueResumeCount
public void queueResumeCount(int id)
Queues the RESUME_COUNTDIALOG packet, sent in response to a numerical input dialog (e.g., "How many?" or "Enter amount").- Parameters:
id- The integer value entered by the player.
-
queueResumeObj
public void queueResumeObj(int value)
Queues the RESUME_OBJDIALOG packet, typically sent as a continuation packet after selecting an option in a multi-choice dialog, where the value represents an item ID or object ID relevant to the dialog option.- Parameters:
value- The numerical value associated with the dialog option.
-
queueDragAndDrop
public void queueDragAndDrop(net.runelite.api.widgets.Widget src, net.runelite.api.widgets.Widget dest)Queues the OPHELDD packet, which simulates a drag-and-drop action between two slots within the same or different widgets (e.g., moving an item in the inventory or bank).- Parameters:
src- The source widget/slot from which the item is dragged.dest- The destination widget/slot onto which the item is dropped.
-
queueResumeName
public void queueResumeName(java.lang.String name)
Queues the RESUME_NAMEDIALOG packet, sent in response to a chat dialog asking the player to enter a name (e.g., setting a clan name).Note: The packet data includes the length of the string plus one for the null terminator.
- Parameters:
name- The string name entered by the player.
-
queueResumeString
public void queueResumeString(java.lang.String string)
Queues the RESUME_STRINGDIALOG packet, sent in response to a chat dialog asking the player to enter a generic string (e.g., a search query).Note: The packet data includes the length of the string plus one for the null terminator.
- Parameters:
string- The string input entered by the player.
-
-