Class XItemStack.Deserializer

java.lang.Object
com.cryptomorin.xseries.XItemStack.Deserializer
Enclosing class:
XItemStack

public static final class XItemStack.Deserializer extends Object
The deserializer only requires a config to be set. All other properties are optional. To use this class, you have to use XItemStack.deserializer(). This class is not thread-safe.
Version:
9.0.0
Author:
Crypto Morin
  • Field Details

    • item

      @Nullable protected @Nullable org.bukkit.inventory.ItemStack item
    • config

      @Nullable protected @Nullable org.bukkit.configuration.ConfigurationSection config
    • translator

      @Nullable protected @Nullable Function<String,String> translator
    • meta

      protected org.bukkit.inventory.meta.ItemMeta meta
  • Method Details

    • modifyItem

      public XItemStack.Deserializer modifyItem(org.bukkit.inventory.ItemStack item)
      If an item is set, it'll modify this item instead of making a new one from the config.
    • fromConfig

      public XItemStack.Deserializer fromConfig(org.bukkit.configuration.ConfigurationSection config)
      The config which this item is going to be deserialized from.
      See Also:
    • fromConfig

      @NotNull public @NotNull XItemStack.Deserializer fromConfig(Map<String,Object> serializedItem)
      If you use any other configuration system, you can provide a map instead, which automatically gets converted into a ConfigurationSection.
      See Also:
    • withTranslator

      public XItemStack.Deserializer withTranslator(Function<String,String> translator)
      Used for ItemMeta.getDisplayName() and ItemMeta.getLore() if your plugin handles them in a specific way. This utility class does not colorize any strings by default. You can also set a withMiniMessage(Function) for Paper servers.
    • withRestart

      public XItemStack.Deserializer withRestart(Consumer<Exception> restart)
      Restarts are a way to handle Exception without terminating the process in general by providing a solution on the fly. If you don't set a restart, the deserialization will fail entirely with the exception.

      Currently the only properly handled exceptions that support restarts are XItemStack.MaterialCondition any other exception will not trigger a restart.

    • withMiniMessage

      @Experimental public XItemStack.Deserializer withMiniMessage(Function<List<String>, List<? extends net.kyori.adventure.text.Component>> miniMessageHandler)
      If this server implementation supports adventure API, ItemMeta.getDisplayName() and ItemMeta.getLore() will be set using their respective Paper adventure API. If the adventure API implementation is not available, withTranslator(Function) is used instead.
    • copy

      public XItemStack.Deserializer copy()
      Copies all properties of this handler, including the item.
    • copySettings

      public XItemStack.Deserializer copySettings()
      Copies all properties of this handler without the item.
    • deserialize

      public org.bukkit.inventory.ItemStack deserialize()