Interface PacketDispatcher
- All Known Subinterfaces:
BasicHandshakePacketDispatcher,PacketChannel,TransactionalPacketDispatcher
-
Method Summary
Modifier and TypeMethodDescriptionbooleanisSupportedBy(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 thePacketto the other side of theEngineConnectionusing this channel.default voidsendToAllPlayers(Packet packet) Sends thePacketto all players on the server.default voidsendToAllPlayersIn(ServerWorld world, Packet packet) Sends thePacketto all players in the given world.default CompletableFuture<Void> sendToServer(Packet packet) Sends thePacketto 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 thePacketto all players on the server.A exception will be thrown if the specified packet type isn't registered in the
PacketChannelthis dispatcher belongs to.- Parameters:
packet- The packet to send
-
sendToAllPlayersIn
Sends thePacketto all players in the given world.A exception will be thrown if the specified packet type isn't registered in the
PacketChannelthis 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
PacketChannelthis 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 thePacketto the server.Calling this during the login phase is currently not supported, only responses to
RequestPackets byRequestPacketHandlers are. Doing so will result in aIllegalStateExceptionwhen attempting to use the method.A exception will be thrown if the specified packet type isn't registered in the
PacketChannelthis 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 thePacketto the other side of theEngineConnectionusing this channel.A exception will be thrown if the specified packet type isn't registered in the
PacketChannelthis 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
-