Class ServerNetworking
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, receivinglogin 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, receivingclient 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.
-
Field Details
-
CHANNEL_REGISTERED
public static final Event<PacketChannelCallback<net.minecraft.server.network.ServerPlayNetworkHandler>> CHANNEL_REGISTEREDAn event for the server play network handler receiving an update indicating the connected client's ability to receive packets in certain channels.- See Also:
PlayPacketSender.hasChannel(Identifier)
-
CHANNEL_UNREGISTERED
public static final Event<PacketChannelCallback<net.minecraft.server.network.ServerPlayNetworkHandler>> CHANNEL_UNREGISTEREDAn event for the server play network handler receiving an update indicating the connected client's lack of ability to receive packets in certain channels.- See Also:
PlayPacketSender.hasChannel(Identifier)
-
PLAY_INITIALIZED
public static final Event<PacketListenerCallback<net.minecraft.server.network.ServerPlayNetworkHandler>> PLAY_INITIALIZEDAn event for the initialization of the server play network handler.At this stage, the network handler is ready to send packets to the client. Use
getPlaySender(ServerPlayNetworkHandler)
to obtain the packet sender in the callback. -
PLAY_DISCONNECTED
public static final Event<PacketListenerCallback<net.minecraft.server.network.ServerPlayNetworkHandler>> PLAY_DISCONNECTEDAn event for the disconnection of the server play network handler.No packets should be sent when this event is invoked.
-
LOGIN_QUERY_START
public static final Event<PacketListenerCallback<net.minecraft.server.network.ServerLoginNetworkHandler>> LOGIN_QUERY_STARTAn event for the start of login queries of the server login network handler.Use
getLoginSender(ServerLoginNetworkHandler)
to obtain the query request packet sender in the callback. -
LOGIN_DISCONNECTED
public static final Event<PacketListenerCallback<net.minecraft.server.network.ServerLoginNetworkHandler>> LOGIN_DISCONNECTEDAn event for the disconnection of the server login network handler.No packets should be sent when this event is invoked.
-
-
Constructor Details
-
ServerNetworking
public ServerNetworking()
-
-
Method Details
-
getPlayReceiver
Returns the packet receiver for channel handler registration on server play network handlers, receivingclient to server custom payload packets
. -
getLoginReceiver
Returns the packet receiver for channel handler registration on server play network handlers, receivinglogin 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
-