endstone::PacketReceiveEvent
Called when the server receives a packet from a connected client.
Bases: endstone::Cancellable< ServerEvent >
Attributes:
Name | Description |
---|---|
NAME |
Functions:
Name | Description |
---|---|
PacketReceiveEvent | |
getAddress | Gets the network address to which this packet is being sent. |
getEventName | |
getPacketId | Gets the ID of the packet. |
getPayload | Gets the raw packet data excluding the header. |
getPlayer | Returns the player involved in this event. |
getSubClientId | Gets the SubClient ID. |
setPayload | Sets the raw packet data excluding the header. |
NAME
const std::string endstone::PacketReceiveEvent::NAME;
PacketReceiveEvent
PacketReceiveEvent(Player *player, const int packet_id,
std::string_view payload, SocketAddress address,
const int sub_client_id)
getAddress
SocketAddress getAddress() const
Gets the network address to which this packet is being sent.
Returns:
The SocketAddress of the destination client.
getEventName
std::string getEventName() override const
Gets a user-friendly identifier for this event.
Returns:
name of this event
getPacketId
int getPacketId() const
Gets the ID of the packet.
Returns:
The packet ID.
getPayload
std::string_view getPayload() const
Gets the raw packet data excluding the header.
Returns:
The packet payload data.
getPlayer
Player *getPlayer() const
Returns the player involved in this event.
Note:
This may return nullptr if the packet is sent before the player completes the login process.
Returns:
Player who is involved in this event
getSubClientId
int getSubClientId() const
Gets the SubClient ID.
Note:
Range is 0 to 3 (0 = primary client; 1-3 = split-screen clients).
Returns:
The SubClient ID.
setPayload
void setPayload(std::string_view payload)
Sets the raw packet data excluding the header.
Returns:
The packet payload data.