Class ItemVisualProcessor

java.lang.Object
io.artificial.enchantments.optional.packetevents.ItemVisualProcessor

public final class ItemVisualProcessor extends Object
Processes items for visual customization on a per-player basis.

This class provides the core logic for modifying item appearance without affecting the actual item state stored on the server. All modifications are display-only and player-specific.

Supported customizations:

  • Lore text modifications (add/remove enchantment info)
  • Glint control (show/hide enchantment glint)
  • Custom lore formatting via callbacks
  • Rarity-based coloring

All methods are thread-safe for read operations. Write operations on player preferences are synchronized via concurrent collections in the parent adapter.

Since:
0.1.0
See Also:
  • Method Details

    • processForPlayer

      @NotNull public @NotNull org.bukkit.inventory.ItemStack processForPlayer(@NotNull @NotNull org.bukkit.inventory.ItemStack item, @NotNull @NotNull UUID playerId)
      Processes an item for display to a specific player.

      This is the main entry point for visual customization. It applies all enabled customizations based on the player's preferences.

      Parameters:
      item - the original item
      playerId - the player to customize for
      Returns:
      the visually customized item (may be the same instance)
      Throws:
      NullPointerException - if item is null
    • processWithPreferences

      @NotNull public @NotNull org.bukkit.inventory.ItemStack processWithPreferences(@NotNull @NotNull org.bukkit.inventory.ItemStack item, @NotNull PacketEventsAdapter.PlayerVisualPreferences preferences)
      Processes an item for display to a specific player with explicit preferences.
      Parameters:
      item - the original item
      preferences - the preferences to apply
      Returns:
      the visually customized item
      Throws:
      NullPointerException - if either parameter is null
    • registerLoreFormatter

      public void registerLoreFormatter(@NotNull @NotNull String enchantmentKey, @NotNull @NotNull Consumer<ItemVisualProcessor.VisualContext> formatter)
      Registers a custom lore formatter for a specific enchantment type.

      The formatter receives a ItemVisualProcessor.VisualContext containing enchantment information and can modify the lore output.

      Parameters:
      enchantmentKey - the enchantment's namespaced key
      formatter - the formatter callback
      Throws:
      NullPointerException - if either parameter is null
    • unregisterLoreFormatter

      public void unregisterLoreFormatter(@NotNull @NotNull String enchantmentKey)
      Unregisters a custom lore formatter.
      Parameters:
      enchantmentKey - the enchantment's namespaced key
      Throws:
      NullPointerException - if enchantmentKey is null
    • clearLoreFormatters

      public void clearLoreFormatters()
      Clears all registered custom formatters.
    • createDefaultPreferences

      @NotNull public PacketEventsAdapter.PlayerVisualPreferences createDefaultPreferences()
      Gets a default visual preferences object with sensible defaults.
      Returns:
      default preferences
    • createPreferencesBuilder

      @NotNull public @NotNull ItemVisualProcessor.PreferencesBuilder createPreferencesBuilder()
      Creates a preferences builder with fluent API.
      Returns:
      a new preferences builder