Interface NativePacketsApi


public interface NativePacketsApi
Entry point exposed to NativePackets consumers.
  • Method Details

    • version

      String version()
      Returns the NativePackets implementation version.
      Returns:
      implementation version
    • platform

      PlatformInfo platform()
      Returns the detected runtime platform.
      Returns:
      runtime platform
    • listeners

      Returns the public packet listener registry.
      Returns:
      listener registry
    • supportedPacketTypes

      default Set<PacketType<?>> supportedPacketTypes()
      Returns the immutable, stable set of typed packets registered by the active adapter.

      Unlike PacketTypes.values(), this describes the exact server runtime. It includes explicitly registered semantic aliases. It does not guarantee support for every view field, packet factory overload, or negotiated client protocol. No view or native packet is created by this query.

      Returns:
      exact-runtime typed packet capabilities, with no iteration order guarantee
      Throws:
      IllegalStateException - when the runtime is not enabled
      UnsupportedOperationException - when an older implementation lacks discovery
    • supports

      default boolean supports(PacketType<?> type)
      Reports whether the active adapter provides a typed view for this canonical packet type.

      Use during listener setup instead of comparing Minecraft version strings. A separately created type with the same key or index is not the canonical type.

      Parameters:
      type - non-null semantic packet type
      Returns:
      whether the type belongs to supportedPacketTypes()
      Throws:
      IllegalStateException - when the runtime is not enabled
      UnsupportedOperationException - when an older implementation lacks discovery
    • connection

      ConnectionHandle connection(Object platformPlayer)
      Returns the active connection for a platform player.
      Parameters:
      platformPlayer - platform player owned by this server
      Returns:
      cached connection handle
      Throws:
      IllegalStateException - when the player connection is not injected
    • fast

      Returns allocation-minimal semantic packet sends addressed to platform players.
      Returns:
      stable fast packet sender
    • packets

      Returns the exact-version packet factory.

      The factory creates native packets for the active server version. Its returned packet objects are version-coupled and must only be sent through this runtime's ConnectionHandle.

      Returns:
      exact-adapter packet factory
    • utilities

      PlatformUtilities utilities()
      Returns exact-adapter platform utilities.
      Returns:
      platform utilities
    • textFactory

      NativeTextFactory textFactory()
      Returns the exact-adapter native text factory.
      Returns:
      native text factory