Class CommandMapModifierProvider

java.lang.Object
com.kamikazejam.kamicommon.nms.provider.Provider<CommandMapModifier>
com.kamikazejam.kamicommon.nms.provider.CommandMapModifierProvider

public class CommandMapModifierProvider extends Provider<CommandMapModifier>
Provider for version-specific command map modifier implementations.

This provider selects the appropriate CommandMapModifier implementation based on the current Minecraft version, handling changes in Bukkit's internal command registration system. Command map modifiers enable dynamic command registration and unregistration without requiring plugin reloads.

The provider addresses the major NMS restructuring that occurred in Minecraft 1.17:

  • 1.8-1.16: Classic NMS structure with stable command map access
  • 1.17+: Restructured NMS with updated command map handling

This allows plugins to dynamically manage commands across all supported versions, enabling features like command aliasing, temporary commands, and runtime command modifications without requiring server restarts.

See Also:
  • Constructor Details

    • CommandMapModifierProvider

      public CommandMapModifierProvider()
  • Method Details

    • provide

      @NotNull protected @NotNull CommandMapModifier 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 command map modifier implementation based on the major NMS restructuring that occurred in Minecraft 1.17. The selection ensures compatibility with both legacy and modern command registration systems.

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