Class PacketRegistry

java.lang.Object
com.comphenix.protocol.injector.packet.PacketRegistry

public class PacketRegistry extends Object
Static packet registry in Minecraft.
  • Field Details

  • Constructor Details

    • PacketRegistry

      public PacketRegistry()
  • Method Details

    • synchronize

      public static void synchronize()
      Ensure that our local register is up-to-date with Minecraft.

      This operation may block the calling thread.

    • createOldRegister

      protected static PacketRegistry.Register createOldRegister()
    • associatePackets

      protected static void associatePackets(PacketRegistry.Register register, Map<Integer,Class<?>> lookup, PacketType.Protocol protocol, PacketType.Sender sender)
    • getStreamCodec

      @Nullable public static WrappedStreamCodec getStreamCodec(Class<?> packetClass)
      Returns the wrapped stream codec to de-/serialize the given packet class
      Parameters:
      packetClass - - the packet class
      Returns:
      wrapped stream codec if existing, otherwise null
    • isSupported

      public static boolean isSupported(PacketType type)
      Determine if the given packet type is supported on the current server.
      Parameters:
      type - - the type to check.
      Returns:
      TRUE if it is, FALSE otherwise.
    • getServerPacketTypes

      public static Set<PacketType> getServerPacketTypes()
      Retrieve every known and supported server packet type.
      Returns:
      Every server packet type.
    • getClientPacketTypes

      public static Set<PacketType> getClientPacketTypes()
      Retrieve every known and supported server packet type.
      Returns:
      Every server packet type.
    • getPacketClassFromType

      @Deprecated public static Class<?> getPacketClassFromType(PacketType type, boolean forceVanilla)
      Deprecated.
      forceVanilla no longer has any effect
      Retrieves the correct packet class from a given type.
      Parameters:
      type - - the packet type.
      forceVanilla - - whether or not to look for vanilla classes, not injected classes.
      Returns:
      The associated class.
    • tryGetPacketClass

      public static Optional<Class<?>> tryGetPacketClass(PacketType type)
    • getPacketClassFromType

      public static Class<?> getPacketClassFromType(PacketType type)
      Get the packet class associated with a given type. First attempts to read from the type-to-class mapping, and tries
      Parameters:
      type - the packet type
      Returns:
      The associated class
    • getPacketType

      @Deprecated public static PacketType getPacketType(Class<?> packet)
      Deprecated.
      major issues due to packets with shared classes being registered in multiple states.
      Retrieve the packet type of a given packet.
      Parameters:
      packet - - the class of the packet.
      Returns:
      The packet type, or NULL if not found.
    • getPacketType

      public static PacketType getPacketType(PacketType.Protocol protocol, Class<?> packet)
      Retrieve the associated packet type for a packet class in the given protocol state.
      Parameters:
      protocol - the protocol state to retrieve the packet from.
      packet - the class identifying the packet type.
      Returns:
      the packet type associated with the given class in the given protocol state, or null if not found.
    • getPacketType

      @Deprecated public static PacketType getPacketType(Class<?> packet, PacketType.Sender sender)
      Deprecated.
      sender no longer has any effect
      Retrieve the packet type of a given packet.
      Parameters:
      packet - - the class of the packet.
      sender - - the sender of the packet, or NULL.
      Returns:
      The packet type, or NULL if not found.