Class PacketHandlerProvider

java.lang.Object
com.kamikazejam.kamicommon.nms.provider.Provider<NMSPacketHandler>
com.kamikazejam.kamicommon.nms.provider.PacketHandlerProvider

public class PacketHandlerProvider extends Provider<NMSPacketHandler>
Provider for version-specific packet handler implementations.

This provider selects the appropriate NMSPacketHandler implementation based on the current Minecraft version, handling the evolution of packet systems and network protocols across different Minecraft releases. Packet handlers provide advanced packet manipulation capabilities for custom client-server communication.

The provider covers major changes in packet handling systems:

  • 1.8-1.12: Legacy packet systems with stable NMS structure
  • 1.13+: Updated packet protocols with protocol version changes
  • 1.17+: Significant NMS restructuring affecting packet access
  • 1.20.5+: Mojang-mapped Paper NMS for enhanced compatibility

Each implementation provides methods for packet creation, wrapping, and transmission that are essential for plugins requiring custom network communication, entity manipulation, or client-side effects that go beyond standard Bukkit capabilities.

See Also:
  • Constructor Details

    • PacketHandlerProvider

      public PacketHandlerProvider()
  • Method Details

    • provide

      @NotNull protected @NotNull NMSPacketHandler provide(int ver)
      Creates the appropriate implementation for the specified NMS version.

      This method must be implemented by subclasses to provide version-specific logic for creating the appropriate implementation. The method receives a formatted NMS integer that can be compared against known version thresholds to determine which implementation to create.

      Use the Provider.f(String) helper method to convert Minecraft version strings to formatted integers for comparison.

      Selects the appropriate packet handler implementation based on Minecraft version, accounting for protocol changes and NMS restructuring. The selection ensures compatibility with the packet systems and network protocols of each version.

      Specified by:
      provide in class Provider<NMSPacketHandler>
      Parameters:
      ver - the formatted NMS version integer
      Returns:
      the version-appropriate NMSPacketHandler implementation
      Throws:
      IllegalArgumentException - if the version is below 1.8 (unsupported)