Interface PacketRegistry

All Known Subinterfaces:
BasicPacketChannel, PacketChannel, TransactionalPacketRegistry

public interface PacketRegistry
A registry for packets and their bindings.

Used opcodes should always be positive values.

  • Method Details

    • register

      <P extends Packet> HandlerPacketBinding<P> register(Class<P> packetClass, int packetOpcode)
      Register a packet class to this channel without a receiving handler. This will only allow the packet to be sent, this channel binding will not be able to receive the packet.

      RequestPacket types may not be registered using this method, they are only supported by TransactionalPacketRegistry.registerTransactional(java.lang.Class<P>, java.lang.Class<R>, int).

      Type Parameters:
      P - The type of the packet
      Parameters:
      packetClass - The class of the packet being registered. Note: the class must have a no-args constructor
      packetOpcode - A unique opcode for this packet
      Returns:
      The created packet binding
    • binding

      <P extends Packet> Optional<PacketBinding<P>> binding(Class<P> packetClass)
      Gets the PacketBinding for the given packet class, if the packet type is registered to this channel.
      Type Parameters:
      P - The type of the packet
      Parameters:
      packetClass - The packet class
      Returns:
      The packet binding, if found
    • bindings

      Collection<PacketBinding<?>> bindings()
      Gets a collection with all the PacketBindings.
      Returns:
      The opcode bindings
    • binding

      Optional<PacketBinding<?>> binding(int opcode)
      Gets the PacketBinding for the given packet class, if the packet type is registered to this channel.
      Parameters:
      opcode - The opcode
      Returns:
      The opcode binding, if found