Class ChatColorProvider
This provider selects the appropriate IChatColorNMS
implementation
based on the current Minecraft version, handling the evolution of chat color
APIs and the introduction of hex color support in Minecraft 1.16.2+.
The provider addresses a significant API change in Minecraft's color handling:
- Pre-1.16.2: Limited to 16 predefined chat colors with approximated AWT colors
- 1.16.2+: Native hex color support with direct color retrieval methods
This allows plugins to consistently convert Bukkit ChatColor
values to AWT Color
objects across all supported Minecraft versions,
with enhanced accuracy on newer versions that support hex colors.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected @NotNull IChatColorNMS
provide
(int ver) Creates the appropriate implementation for the specified NMS version.
-
Constructor Details
-
ChatColorProvider
public ChatColorProvider()
-
-
Method Details
-
provide
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 chat color implementation based on hex color support availability. Versions 1.16.2+ can use native color methods, while older versions rely on color approximations for the standard 16 chat colors.
- Specified by:
provide
in classProvider<IChatColorNMS>
- Parameters:
ver
- the formatted NMS version integer- Returns:
- the version-appropriate
IChatColorNMS
implementation
-