Class PlayerPackets
- java.lang.Object
-
- com.kraken.api.core.packet.entity.PlayerPackets
-
public class PlayerPackets extends java.lang.ObjectA high-level utility class for sending packets related toPlayerinteractions to the game server.This class handles actions like right-clicking other players (e.g., Follow, Trade) and "use-on" actions (e.g., using an item on a player). It abstracts the low-level packet construction and uses client data to determine the correct action index.
-
-
Constructor Summary
Constructors Constructor Description PlayerPackets()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidqueuePlayerAction(int actionFieldNo, int playerIndex, boolean ctrlDown)Queues the low-level packet to perform a generic action click on another player.voidqueuePlayerAction(net.runelite.api.Player player, java.lang.String... actionlist)Queues a player action by matching a human-readable action string (e.g., "Attack", "Trade", "Follow").voidqueueWidgetOnPlayer(int playerIndex, int sourceItemId, int sourceSlot, int sourceWidgetId, boolean ctrlDown)Queues the raw packet for using a widget (typically an item) on another player.voidqueueWidgetOnPlayer(net.runelite.api.Player player, net.runelite.api.widgets.Widget widget)Queues the packet for using a specificWidget(or item it represents) on a targetPlayer.
-
-
-
Method Detail
-
queuePlayerAction
public void queuePlayerAction(int actionFieldNo, int playerIndex, boolean ctrlDown)Queues the low-level packet to perform a generic action click on another player.This method sends one of the
OPPLAYERpackets (e.g.,OPPLAYER1throughOPPLAYER10), where the action is determined by theactionFieldNo(which corresponds to a Player Option).- Parameters:
actionFieldNo- The 1-based index of the action to execute (1-10).playerIndex- The server index/ID of the target player.ctrlDown- If true, indicates the control key was held down.
-
queuePlayerAction
public void queuePlayerAction(net.runelite.api.Player player, java.lang.String... actionlist)Queues a player action by matching a human-readable action string (e.g., "Attack", "Trade", "Follow").This is a high-level convenience method that checks the client's current **Player Options** (the text that appears on the right-click menu) for a matching action, finds the corresponding action number (1-10), and sends the correct packet.
- Parameters:
player- The targetPlayerobject to interact with.actionlist- A varargs list of action strings to search for (case-insensitive).
-
queueWidgetOnPlayer
public void queueWidgetOnPlayer(int playerIndex, int sourceItemId, int sourceSlot, int sourceWidgetId, boolean ctrlDown)Queues the raw packet for using a widget (typically an item) on another player.This method sends the
OPPLAYERT(Use Widget on Player) packet, which contains the details of the source item/widget and the target player.- Parameters:
playerIndex- The server index/ID of the target player.sourceItemId- The ID of the item being used.sourceSlot- The slot index of the item being used (e.g., inventory slot).sourceWidgetId- The ID of the parent widget containing the item (e.g., inventory widget ID).ctrlDown- If true, indicates the control key was held down.
-
queueWidgetOnPlayer
public void queueWidgetOnPlayer(net.runelite.api.Player player, net.runelite.api.widgets.Widget widget)Queues the packet for using a specificWidget(or item it represents) on a targetPlayer.This is a convenience method that extracts the necessary item and widget details from the provided
Widgetobject and calls the rawqueueWidgetOnPlayermethod.- Parameters:
player- The targetPlayerobject.widget- The sourceWidgetcontaining the item or action to be used on the player.
-
-