Class ServerLoginNetworking
java.lang.Object
net.fabricmc.fabric.api.networking.v1.ServerLoginNetworking
Offers access to login stage server-side networking functionalities.
Server-side networking functionalities include receiving serverbound query responses and sending clientbound query requests.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfacestatic interfaceAllows blocking client log-in until all futures passed intoServerLoginNetworking.LoginSynchronizer.waitFor(Future)are completed. -
Method Summary
Modifier and TypeMethodDescriptionstatic Set<net.minecraft.resources.Identifier> Gets all channel names which global receivers are registered for.static LoginPacketSendergetSender(net.minecraft.server.network.ServerLoginPacketListenerImpl listener) Gets the packet sender which sends packets to the connected client.static net.minecraft.server.MinecraftServergetServer(net.minecraft.server.network.ServerLoginPacketListenerImpl listener) Returns the Minecraft Server of a server login packet listener.static booleanregisterGlobalReceiver(net.minecraft.resources.Identifier channelName, ServerLoginNetworking.LoginQueryResponseHandler channelHandler) Registers a handler to a query response channel.static booleanregisterReceiver(net.minecraft.server.network.ServerLoginPacketListenerImpl packetListener, net.minecraft.resources.Identifier channelName, ServerLoginNetworking.LoginQueryResponseHandler responseHandler) Registers a handler to a query response channel.static @Nullable ServerLoginNetworking.LoginQueryResponseHandlerunregisterGlobalReceiver(net.minecraft.resources.Identifier channelName) Removes the handler of a query response channel.static @Nullable ServerLoginNetworking.LoginQueryResponseHandlerunregisterReceiver(net.minecraft.server.network.ServerLoginPacketListenerImpl packetListener, net.minecraft.resources.Identifier channelName) Removes the handler of a query response channel.
-
Method Details
-
registerGlobalReceiver
public static boolean registerGlobalReceiver(net.minecraft.resources.Identifier channelName, ServerLoginNetworking.LoginQueryResponseHandler channelHandler) Registers a handler to a query response channel. A global receiver is registered to all connections, in the present and future.If a handler is already registered to the
channel, this method will returnfalse, and no change will be made. UseunregisterGlobalReceiver(Identifier)to unregister the existing handler.- Parameters:
channelName- the id of the channelchannelHandler- the handler- Returns:
- false if a handler is already registered to the channel
- See Also:
-
unregisterGlobalReceiver
public static @Nullable ServerLoginNetworking.LoginQueryResponseHandler unregisterGlobalReceiver(net.minecraft.resources.Identifier channelName) Removes the handler of a query response channel. A global receiver is registered to all connections, in the present and future.The
channelis guaranteed not to have a handler after this call.- Parameters:
channelName- the id of the channel- Returns:
- the previous handler, or
nullif no handler was bound to the channel - See Also:
-
getGlobalReceivers
Gets all channel names which global receivers are registered for. A global receiver is registered to all connections, in the present and future.- Returns:
- all channel names which global receivers are registered for.
-
registerReceiver
public static boolean registerReceiver(net.minecraft.server.network.ServerLoginPacketListenerImpl packetListener, net.minecraft.resources.Identifier channelName, ServerLoginNetworking.LoginQueryResponseHandler responseHandler) Registers a handler to a query response channel.If a handler is already registered to the
channelName, this method will returnfalse, and no change will be made. UseunregisterReceiver(ServerLoginPacketListenerImpl, Identifier)to unregister the existing handler.- Parameters:
packetListener- the listenerchannelName- the id of the channelresponseHandler- the handler- Returns:
- false if a handler is already registered to the channel name
-
unregisterReceiver
public static @Nullable ServerLoginNetworking.LoginQueryResponseHandler unregisterReceiver(net.minecraft.server.network.ServerLoginPacketListenerImpl packetListener, net.minecraft.resources.Identifier channelName) Removes the handler of a query response channel.The
channelNameis guaranteed not to have a handler after this call.- Parameters:
channelName- the id of the channel- Returns:
- the previous handler, or
nullif no handler was bound to the channel name
-
getServer
public static net.minecraft.server.MinecraftServer getServer(net.minecraft.server.network.ServerLoginPacketListenerImpl listener) Returns the Minecraft Server of a server login packet listener.- Parameters:
listener- the server login packet listener
-
getSender
public static LoginPacketSender getSender(net.minecraft.server.network.ServerLoginPacketListenerImpl listener) Gets the packet sender which sends packets to the connected client.- Parameters:
listener- the packet listener, representing the connection to the client- Returns:
- the packet sender
-