Interface PacketDispatcher
- All Known Subinterfaces:
BasicHandshakePacketDispatcher
,PacketChannel
,TransactionalPacketDispatcher
-
Method Summary
Modifier and TypeMethodDescriptionboolean
isSupportedBy
(EngineConnection connection) Gets whether the packet channel this dispatcher belongs to is supported by the givenEngineConnection
.default CompletableFuture<Void>
sendTo
(ServerPlayer player, Packet packet) Sends the packet to the player using this channel.sendTo
(EngineConnection connection, Packet packet) Sends thePacket
to the other side of theEngineConnection
using this channel.default void
sendToAllPlayers
(Packet packet) Sends thePacket
to all players on the server.default void
sendToAllPlayersIn
(ServerWorld world, Packet packet) Sends thePacket
to all players in the given world.default CompletableFuture<Void>
sendToServer
(Packet packet) Sends thePacket
to the server.
-
Method Details
-
isSupportedBy
Gets whether the packet channel this dispatcher belongs to is supported by the givenEngineConnection
.A packet channel is supported if the other side of the connection also supports the channel.
- Parameters:
connection
- The connection to check- Returns:
- Whether the packet channel is supported
-
sendToAllPlayers
Sends thePacket
to all players on the server.A exception will be thrown if the specified packet type isn't registered in the
PacketChannel
this dispatcher belongs to.- Parameters:
packet
- The packet to send
-
sendToAllPlayersIn
Sends thePacket
to all players in the given world.A exception will be thrown if the specified packet type isn't registered in the
PacketChannel
this dispatcher belongs to.- Parameters:
world
- The worldpacket
- The packet to send
-
sendTo
Sends the packet to the player using this channel. The packet may not be sent if the player doesn't have a registered handler.A exception will be thrown if the specified packet type isn't registered in the
PacketChannel
this dispatcher belongs to.- Parameters:
player
- The player to send the packet topacket
- The packet to send- Returns:
- A future which will complete when the operation has finished
-
sendToServer
Sends thePacket
to the server.Calling this during the login phase is currently not supported, only responses to
RequestPacket
s byRequestPacketHandler
s are. Doing so will result in aIllegalStateException
when attempting to use the method.A exception will be thrown if the specified packet type isn't registered in the
PacketChannel
this dispatcher belongs to.- Parameters:
packet
- The packet to send- Returns:
- A future which will complete when the operation has finished
- Throws:
IllegalStateException
- If the server connection isn't in the play phase
-
sendTo
Sends thePacket
to the other side of theEngineConnection
using this channel.A exception will be thrown if the specified packet type isn't registered in the
PacketChannel
this dispatcher belongs to.- Parameters:
connection
- The connection to send the packet topacket
- The packet to send- Returns:
- A future which will complete when the operation has finished
-