Interface PacketDispatcher
- 
- All Known Subinterfaces:
- BasicHandshakePacketDispatcher,- PacketChannel,- TransactionalPacketDispatcher
 
 public interface PacketDispatcherRepresents a dispatcher of packets.
- 
- 
Method SummaryAll Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description booleanisSupportedBy(EngineConnection connection)Gets whether the packet channel this dispatcher belongs to is supported by the givenEngineConnection.default java.util.concurrent.CompletableFuture<java.lang.Void>sendTo(ServerPlayer player, Packet packet)Sends the packet to the player using this channel.java.util.concurrent.CompletableFuture<java.lang.Void>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 java.util.concurrent.CompletableFuture<java.lang.Void>sendToServer(Packet packet)Sends thePacketto the server.
 
- 
- 
- 
Method Detail- 
isSupportedByboolean isSupportedBy(EngineConnection connection) 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
 
 - 
sendToAllPlayersdefault void sendToAllPlayers(Packet packet) 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
 
 - 
sendToAllPlayersIndefault void sendToAllPlayersIn(ServerWorld world, Packet packet) 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 world
- packet- The packet to send
 
 - 
sendTodefault java.util.concurrent.CompletableFuture<java.lang.Void> sendTo(ServerPlayer player, Packet packet) 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 to
- packet- The packet to send
- Returns:
- A future which will complete when the operation has finished
 
 - 
sendToServerdefault java.util.concurrent.CompletableFuture<java.lang.Void> sendToServer(Packet packet) 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:
- java.lang.IllegalStateException- If the server connection isn't in the play phase
 
 - 
sendTojava.util.concurrent.CompletableFuture<java.lang.Void> sendTo(EngineConnection connection, Packet packet) 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 to
- packet- The packet to send
- Returns:
- A future which will complete when the operation has finished
 
 
- 
 
-