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
  • Constructor Details

    • PaperNetworkHandler

      public PaperNetworkHandler(org.bukkit.plugin.java.JavaPlugin plugin, Side side)
  • Method Details

    • supports

      protected boolean supports(PacketContainer.PacketType type)
      Overrides:
      supports in class PacketRegistrationHandler
    • registerPacket

      protected <T> void registerPacket(PacketContainer<T> container)
    • shutdown

      public void shutdown()
    • onPluginMessageReceived

      public void onPluginMessageReceived(String channel, org.bukkit.entity.Player player, byte[] message)
      Specified by:
      onPluginMessageReceived in interface org.bukkit.plugin.messaging.PluginMessageListener
    • sendToClient

      public <T> void sendToClient(T packet, net.minecraft.server.level.ServerPlayer player, boolean ignoreCheck)
      Description copied from interface: NetworkHandler
      Sends the packet to the client player..
      Specified by:
      sendToClient in interface NetworkHandler
      Type Parameters:
      T - - The packet
      Parameters:
      packet - - the packet
      player - - the player
      ignoreCheck - - ignore the check if the client has the packet registered.
    • sendToServer

      public <T> void sendToServer(T packet, boolean ignoreCheck)
      Description copied from interface: NetworkHandler
      Sends 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:
      sendToServer in interface NetworkHandler
      Type Parameters:
      T - - The packet
      Parameters:
      packet - - the packet
      ignoreCheck - - 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: NetworkHandler
      Sends the packet to the connection.
      Specified by:
      send in interface NetworkHandler
      Type Parameters:
      T - - The packet
      Parameters:
      packet - - the packet
      connection - - the connection
    • getRawClientboundPacket

      @Nullable public <T> @Nullable net.minecraft.network.protocol.common.ClientboundCustomPayloadPacket getRawClientboundPacket(T packet)
      Description copied from interface: NetworkHandler
      Generates a ClientboundCustomPayloadPacket
      Specified by:
      getRawClientboundPacket in interface NetworkHandler
      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: NetworkHandler
      Generates a ServerboundCustomPayloadPacket
      Specified by:
      getRawServerboundPacket in interface NetworkHandler
      Type Parameters:
      T - - The packet
      Parameters:
      packet - - the packet
      Returns:
      - The packet wrapped into a ServerboundCustomPayloadPacket