java.lang.Object
io.github.fablabsmc.fablabs.api.networking.v1.server.ServerNetworking

public final class ServerNetworking
extends Object
Offers access to 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:
ClientNetworking
  • Field Summary

    Fields 
    Modifier and Type Field Description
    static Event<PacketChannelCallback<net.minecraft.server.network.ServerPlayNetworkHandler>> CHANNEL_REGISTERED
    An event for the server play network handler receiving an update indicating the connected client's ability to receive packets in certain channels.
    static Event<PacketChannelCallback<net.minecraft.server.network.ServerPlayNetworkHandler>> CHANNEL_UNREGISTERED
    An event for the server play network handler receiving an update indicating the connected client's lack of ability to receive packets in certain channels.
    static Event<PacketListenerCallback<net.minecraft.server.network.ServerLoginNetworkHandler>> LOGIN_DISCONNECTED
    An event for the disconnection of the server login network handler.
    static Event<PacketListenerCallback<net.minecraft.server.network.ServerLoginNetworkHandler>> LOGIN_QUERY_START
    An event for the start of login queries of the server login network handler.
    static Event<PacketListenerCallback<net.minecraft.server.network.ServerPlayNetworkHandler>> PLAY_DISCONNECTED
    An event for the disconnection of the server play network handler.
    static Event<PacketListenerCallback<net.minecraft.server.network.ServerPlayNetworkHandler>> PLAY_INITIALIZED
    An event for the initialization of the server play network handler.
  • Constructor Summary

    Constructors 
    Constructor Description
    ServerNetworking()  
  • Method Summary

    Modifier and Type Method Description
    static PacketReceiver<ServerLoginContext> getLoginReceiver()
    Returns the packet receiver for channel handler registration on server play network handlers, receiving login query response packets.
    static PacketSender getLoginSender​(net.minecraft.server.network.ServerLoginNetworkHandler handler)
    Returns the login query packet sender for a server login network handler.
    static PacketReceiver<ServerPlayContext> getPlayReceiver()
    Returns the packet receiver for channel handler registration on server play network handlers, receiving client to server custom payload packets.
    static PlayPacketSender getPlaySender​(net.minecraft.server.network.ServerPlayerEntity player)
    Returns the packet sender for a server player.
    static PlayPacketSender getPlaySender​(net.minecraft.server.network.ServerPlayNetworkHandler handler)
    Returns the packet sender for a server play network handler.
    static net.minecraft.server.MinecraftServer getServer​(net.minecraft.server.network.ServerLoginNetworkHandler handler)
    Returns the Minecraft Server of a server login network handler.
    static net.minecraft.server.MinecraftServer getServer​(net.minecraft.server.network.ServerPlayNetworkHandler handler)
    Returns the Minecraft Server of a server play network handler.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

  • Method Details

    • getPlayReceiver

      public static PacketReceiver<ServerPlayContext> getPlayReceiver()
      Returns the packet receiver for channel handler registration on server play network handlers, receiving client to server custom payload packets.
    • getLoginReceiver

      public static PacketReceiver<ServerLoginContext> getLoginReceiver()
      Returns the packet receiver for channel handler registration on server play network handlers, receiving login query response packets.
    • getPlaySender

      public static PlayPacketSender getPlaySender​(net.minecraft.server.network.ServerPlayNetworkHandler handler)
      Returns the packet sender for a server play network handler.
      Parameters:
      handler - a server play network handler
      Returns:
      the associated packet sender
    • getLoginSender

      public static PacketSender getLoginSender​(net.minecraft.server.network.ServerLoginNetworkHandler handler)
      Returns the login query packet sender for a server login network handler.
      Parameters:
      handler - the server login network handler
      Returns:
      the associated login query packet sender
    • getPlaySender

      public static PlayPacketSender getPlaySender​(net.minecraft.server.network.ServerPlayerEntity player)
      Returns the packet sender for a server player.

      This is a shortcut for getPlaySender(ServerPlayNetworkHandler).

      Parameters:
      player - a server player
      Returns:
      the associated packet sender
    • getServer

      public static net.minecraft.server.MinecraftServer getServer​(net.minecraft.server.network.ServerPlayNetworkHandler handler)
      Returns the Minecraft Server of a server play network handler.
      Parameters:
      handler - the server play network handler
    • 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