Class XItemStack.Deserializer
java.lang.Object
com.cryptomorin.xseries.XItemStack.Deserializer
- Enclosing class:
XItemStack
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 Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptioncopy()Copies all properties of this handler, including the item.Copies all properties of this handler without the item.org.bukkit.inventory.ItemStack@NotNull XItemStack.DeserializerfromConfig(Map<String, Object> serializedItem) If you use any other configuration system, you can provide a map instead, which automatically gets converted into aConfigurationSection.fromConfig(org.bukkit.configuration.ConfigurationSection config) The config which this item is going to be deserialized from.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.withMiniMessage(Function<List<String>, List<? extends net.kyori.adventure.text.Component>> miniMessageHandler) If this server implementation supports adventure API,ItemMeta.getDisplayName()andItemMeta.getLore()will be set using their respective Paper adventure API.withRestart(Consumer<Exception> restart) Restarts are a way to handleExceptionwithout terminating the process in general by providing a solution on the fly.withTranslator(Function<String, String> translator) Used forItemMeta.getDisplayName()andItemMeta.getLore()if your plugin handles them in a specific way.
-
Field Details
-
item
@Nullable protected @Nullable org.bukkit.inventory.ItemStack item -
config
@Nullable protected @Nullable org.bukkit.configuration.ConfigurationSection config -
translator
-
meta
protected org.bukkit.inventory.meta.ItemMeta meta
-
-
Method Details
-
modifyItem
If an item is set, it'll modify this item instead of making a new one from the config. -
fromConfig
The config which this item is going to be deserialized from.- See Also:
-
fromConfig
If you use any other configuration system, you can provide a map instead, which automatically gets converted into aConfigurationSection.- See Also:
-
withTranslator
Used forItemMeta.getDisplayName()andItemMeta.getLore()if your plugin handles them in a specific way. This utility class does not colorize any strings by default. You can also set awithMiniMessage(Function)for Paper servers. -
withRestart
Restarts are a way to handleExceptionwithout 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.MaterialConditionany 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()andItemMeta.getLore()will be set using their respective Paper adventure API. If the adventure API implementation is not available,withTranslator(Function)is used instead. -
copy
Copies all properties of this handler, including the item. -
copySettings
Copies all properties of this handler without the item. -
deserialize
public org.bukkit.inventory.ItemStack deserialize()
-