ServerPlayNetworking

public final class ServerPlayNetworking

Offers access to play stage server-side networking functionalities.

Server-side networking functionalities include receiving serverbound packets, sending clientbound packets, and events related to server-side network handlers.

This class should be only used for the logical server.

See also

Types

PlayChannelHandler
Link copied to clipboard
public interface PlayChannelHandler

Functions

canSend
Link copied to clipboard
static boolean canSend(ServerPlayNetworkHandler handler, Identifier channelName)
Checks if the connected client declared the ability to receive a packet on a specified channel name.
static boolean canSend(ServerPlayerEntity player, Identifier channelName)
Checks if the connected client declared the ability to receive a packet on a specified channel name.
createS2CPacket
Link copied to clipboard
static Packet<? extends ObjectcreateS2CPacket(Identifier channelName, PacketByteBuf buf)
Creates a packet which may be sent to a the connected client.
getGlobalReceivers
Link copied to clipboard
static Set<IdentifiergetGlobalReceivers()
Gets all channel names which global receivers are registered for.A global receiver is registered to all connections, in the present and future.
getReceived
Link copied to clipboard
static Set<IdentifiergetReceived(ServerPlayNetworkHandler handler)
Gets all the channel names that the server can receive packets on.
static Set<IdentifiergetReceived(ServerPlayerEntity player)
Gets all the channel names that the server can receive packets on.
getSendable
Link copied to clipboard
static Set<IdentifiergetSendable(ServerPlayNetworkHandler handler)
Gets all channel names that a the connected client declared the ability to receive a packets on.
static Set<IdentifiergetSendable(ServerPlayerEntity player)
Gets all channel names that the connected client declared the ability to receive a packets on.
getSender
Link copied to clipboard
static PacketSender getSender(ServerPlayNetworkHandler handler)
Gets the packet sender which sends packets to the connected client.
static PacketSender getSender(ServerPlayerEntity player)
Gets the packet sender which sends packets to the connected client.
getServer
Link copied to clipboard
static MinecraftServer getServer(ServerPlayNetworkHandler handler)
Returns the Minecraft Server of a server play network handler.
registerGlobalReceiver
Link copied to clipboard
static boolean registerGlobalReceiver(Identifier channelName, ServerPlayNetworking.PlayChannelHandler channelHandler)
Registers a handler to a channel.A global receiver is registered to all connections, in the present and future.
registerReceiver
Link copied to clipboard
static boolean registerReceiver(ServerPlayNetworkHandler networkHandler, Identifier channelName, ServerPlayNetworking.PlayChannelHandler channelHandler)
Registers a handler to a channel.
send
Link copied to clipboard
static void send(ServerPlayerEntity player, Identifier channelName, PacketByteBuf buf)
Sends a packet to a player.
unregisterGlobalReceiver
Link copied to clipboard
@Nullable()
static ServerPlayNetworking.PlayChannelHandler unregisterGlobalReceiver(Identifier channelName)
Removes the handler of a channel.A global receiver is registered to all connections, in the present and future.
unregisterReceiver
Link copied to clipboard
@Nullable()
static ServerPlayNetworking.PlayChannelHandler unregisterReceiver(ServerPlayNetworkHandler networkHandler, Identifier channelName)
Removes the handler of a channel.

Sources

jvm source
Link copied to clipboard