Class PaperNetworkHandler
java.lang.Object
commonnetwork.networking.PacketRegistrationHandler
commonnetwork.networking.PaperNetworkHandler
- All Implemented Interfaces:
NetworkHandler, PacketRegistrar, org.bukkit.plugin.messaging.PluginMessageListener
public class PaperNetworkHandler
extends PacketRegistrationHandler
implements org.bukkit.plugin.messaging.PluginMessageListener
-
Field Summary
Fields inherited from class PacketRegistrationHandler
side -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T> @Nullable net.minecraft.network.protocol.common.ClientboundCustomPayloadPacketgetRawClientboundPacket(T packet) Generates a ClientboundCustomPayloadPacket<T> @Nullable net.minecraft.network.protocol.common.ServerboundCustomPayloadPacketgetRawServerboundPacket(T packet) Generates a ServerboundCustomPayloadPacketvoidonPluginMessageReceived(String channel, org.bukkit.entity.Player player, byte[] message) protected <T> voidregisterPacket(PacketContainer<T> container) <T> voidsend(T packet, net.minecraft.network.Connection connection) Sends the packet to the connection.<T> voidsendToClient(T packet, net.minecraft.server.level.ServerPlayer player, boolean ignoreCheck) Sends the packet to the client player..<T> voidsendToServer(T packet, boolean ignoreCheck) Sends the packet to the server.voidshutdown()protected booleanMethods inherited from class PacketRegistrationHandler
getPacketContainer, getPacketContainer, getSide, registerConfigurationPacket, registerPacket, registerPacketMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface NetworkHandler
sendToAllClients, sendToAllClients, sendToClient, sendToClients, sendToClients, sendToClientsInLevel, sendToClientsInLevel, sendToClientsInRange, sendToClientsInRange, sendToClientsLoadingChunk, sendToClientsLoadingChunk, sendToClientsLoadingPos, sendToClientsLoadingPos, sendToClientsLoadingPos, sendToClientsLoadingPos, sendToServerMethods inherited from interface org.bukkit.plugin.messaging.PluginMessageListener
onPluginMessageReceived
-
Constructor Details
-
PaperNetworkHandler
-
-
Method Details
-
supports
- Overrides:
supportsin classPacketRegistrationHandler
-
registerPacket
-
shutdown
public void shutdown() -
onPluginMessageReceived
public void onPluginMessageReceived(String channel, org.bukkit.entity.Player player, byte[] message) - Specified by:
onPluginMessageReceivedin interfaceorg.bukkit.plugin.messaging.PluginMessageListener
-
sendToClient
public <T> void sendToClient(T packet, net.minecraft.server.level.ServerPlayer player, boolean ignoreCheck) Description copied from interface:NetworkHandlerSends the packet to the client player..- Specified by:
sendToClientin interfaceNetworkHandler- Type Parameters:
T- - The packet- Parameters:
packet- - the packetplayer- - the playerignoreCheck- - ignore the check if the client has the packet registered.
-
sendToServer
public <T> void sendToServer(T packet, boolean ignoreCheck) Description copied from interface:NetworkHandlerSends the packet to the server. Can ignore the check if the server has the packet registered. Likely use case for this is talking to bukkit/spigot/paper servers.- Specified by:
sendToServerin interfaceNetworkHandler- Type Parameters:
T- - The packet- Parameters:
packet- - the packetignoreCheck- - ignore the check if the server has the packet registered.
-
send
public <T> void send(T packet, net.minecraft.network.Connection connection) Description copied from interface:NetworkHandlerSends the packet to the connection.- Specified by:
sendin interfaceNetworkHandler- Type Parameters:
T- - The packet- Parameters:
packet- - the packetconnection- - the connection
-
getRawClientboundPacket
@Nullable public <T> @Nullable net.minecraft.network.protocol.common.ClientboundCustomPayloadPacket getRawClientboundPacket(T packet) Description copied from interface:NetworkHandlerGenerates a ClientboundCustomPayloadPacket- Specified by:
getRawClientboundPacketin interfaceNetworkHandler- Type Parameters:
T- - The packet- Parameters:
packet- - the packet- Returns:
- - The packet wrapped into a ClientboundCustomPayloadPacket
-
getRawServerboundPacket
@Nullable public <T> @Nullable net.minecraft.network.protocol.common.ServerboundCustomPayloadPacket getRawServerboundPacket(T packet) Description copied from interface:NetworkHandlerGenerates a ServerboundCustomPayloadPacket- Specified by:
getRawServerboundPacketin interfaceNetworkHandler- Type Parameters:
T- - The packet- Parameters:
packet- - the packet- Returns:
- - The packet wrapped into a ServerboundCustomPayloadPacket
-