Class ItemVisualProcessor
java.lang.Object
io.artificial.enchantments.optional.packetevents.ItemVisualProcessor
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:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionfinal classFluent builder for creating visual preferences.static final classContext object passed to lore formatters. -
Method Summary
Modifier and TypeMethodDescriptionvoidClears all registered custom formatters.Gets a default visual preferences object with sensible defaults.Creates a preferences builder with fluent API.@NotNull org.bukkit.inventory.ItemStackprocessForPlayer(@NotNull org.bukkit.inventory.ItemStack item, @NotNull UUID playerId) Processes an item for display to a specific player.@NotNull org.bukkit.inventory.ItemStackprocessWithPreferences(@NotNull org.bukkit.inventory.ItemStack item, PacketEventsAdapter.PlayerVisualPreferences preferences) Processes an item for display to a specific player with explicit preferences.voidregisterLoreFormatter(@NotNull String enchantmentKey, @NotNull Consumer<ItemVisualProcessor.VisualContext> formatter) Registers a custom lore formatter for a specific enchantment type.voidunregisterLoreFormatter(@NotNull String enchantmentKey) Unregisters a custom lore formatter.
-
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 itemplayerId- 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 itempreferences- 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.VisualContextcontaining enchantment information and can modify the lore output.- Parameters:
enchantmentKey- the enchantment's namespaced keyformatter- the formatter callback- Throws:
NullPointerException- if either parameter is null
-
unregisterLoreFormatter
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
Gets a default visual preferences object with sensible defaults.- Returns:
- default preferences
-
createPreferencesBuilder
Creates a preferences builder with fluent API.- Returns:
- a new preferences builder
-