Class ServerLoginNetworking

java.lang.Object
net.fabricmc.fabric.api.networking.v1.ServerLoginNetworking

public final class ServerLoginNetworking extends Object
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:
  • Method Details

    • registerGlobalReceiver

      public static boolean registerGlobalReceiver(net.minecraft.util.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 return false, and no change will be made. Use unregisterGlobalReceiver(Identifier) to unregister the existing handler.

      Parameters:
      channelName - the id of the channel
      channelHandler - the handler
      Returns:
      false if a handler is already registered to the channel
      See Also:
    • unregisterGlobalReceiver

      @Nullable public static ServerLoginNetworking.LoginQueryResponseHandler unregisterGlobalReceiver(net.minecraft.util.Identifier channelName)
      Removes the handler of a query response channel. A global receiver is registered to all connections, in the present and future.

      The channel is guaranteed not to have a handler after this call.

      Parameters:
      channelName - the id of the channel
      Returns:
      the previous handler, or null if no handler was bound to the channel
      See Also:
    • getGlobalReceivers

      public static Set<net.minecraft.util.Identifier> 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.ServerLoginNetworkHandler networkHandler, net.minecraft.util.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 return false, and no change will be made. Use unregisterReceiver(ServerLoginNetworkHandler, Identifier) to unregister the existing handler.

      Parameters:
      networkHandler - the handler
      channelName - the id of the channel
      responseHandler - the handler
      Returns:
      false if a handler is already registered to the channel name
    • unregisterReceiver

      @Nullable public static ServerLoginNetworking.LoginQueryResponseHandler unregisterReceiver(net.minecraft.server.network.ServerLoginNetworkHandler networkHandler, net.minecraft.util.Identifier channelName)
      Removes the handler of a query response channel.

      The channelName is guaranteed not to have a handler after this call.

      Parameters:
      channelName - the id of the channel
      Returns:
      the previous handler, or null if no handler was bound to the channel name
    • getServer

      public static net.minecraft.server.MinecraftServer getServer(net.minecraft.server.network.ServerLoginNetworkHandler handler)
      Returns the Minecraft Server of a server login network handler.
      Parameters:
      handler - the server login network handler