Item System
The paper module exposes a small framework for building, serializing, and resolving item stacks. The same types are used everywhere an item is configured (menus, dialogs, NPC equipment, the /give command).
Overview
Type | Module / Package | Purpose |
|---|---|---|
|
| Placeholder-aware item template; lazily resolves to a Bukkit |
|
| Pluggable component that reads YAML and applies a piece of item meta. |
|
| Resolves an |
|
| Holds the named registries for components and suppliers. |
|
| Static helpers ( |
ItemStackWrapper
ItemStackWrapper is an immutable record that implements PlaceholderWrapper<ItemStack>. Calling get() or get(parser) materializes the underlying Bukkit ItemStack — placeholders, math, and component values are re-evaluated each call.
The wrapper holds:
material— the baseMaterial(or a placeholder resolving to one).copyFrom— optionalItemStackplaceholder; when set, the wrapper clones it before applying overrides.name,lore— AdventureComponentWrapper/ComponentWrapperListfor placeholder-aware text.enchantments,itemFlags,amount— vanilla item meta values.components— a map of registeredItemComponent<?>→ its deserialized data object.appendLore— whencopyFromis set, prepends the original lore to the wrapper's lore instead of replacing it.
Use it whenever you want config-defined items with placeholder substitution. For one-off items, build a plain Bukkit ItemStack directly.
ItemComponent
Each component declares its own data type T. deserialize is called once at config load; apply is called every time the wrapper resolves. The parser argument is the placeholder context — pass it on to any PlaceholderWrapper fields you carry on T.
Registering a custom component
Components are stored in CommonRegistries.itemComponents(). Register early — before any YAML that references the new key is parsed:
The component is now usable in any item-stack block:
Built-in components
The 17 built-in components are documented from a user perspective in Menu Items › Item Components. The concrete implementations live in com.astralrealms.core.paper.model.itemstack.component.
ItemStackSupplier
A supplier produces real ItemStack instances for a (namespace, key) pair. Suppliers are how the system integrates with item plugins like HeadDatabase and CraftEngine.
Built-in suppliers
Namespace | Class | Registered when |
|---|---|---|
|
| Always (built-in) |
|
|
|
|
|
|
Registering a custom supplier
After registration, the namespace is usable as a YAML material prefix:
/give <player> mymod:magic_sword [amount] automatically gains a completion entry if the supplier returns the key from completions().
How the prefix is parsed
AstralPaperAPI.provideItemStack(String id) splits on the first -. The left side is looked up in the supplier registry; the right side is passed verbatim to supplier.get(key). A value with no - is treated as a plain vanilla Material name.
ItemStackUtils
Static helpers in com.astralrealms.core.paper.utils.ItemStackUtils:
Method | Description |
|---|---|
|
|
| Compare type, item meta, enchantments (or stored enchants for books), damage / max damage, and PersistentDataContainer bytes. Ignores amount. |
|
|
| Deprecated. Compares item-model + custom-model-data only. |
/give Command
The paper module ships a /give <player> <itemId> [amount] command (permission: astralrealms.command.give). It iterates all registered suppliers and uses the first one whose completions() contains the requested key.
When the MailboxService is available, the item goes through the mailbox; otherwise it falls back to inventory.addItem and drops the leftovers at the player's feet. A PlayerItemGiveEvent is fired on success.
Events
Event | When | Cancellable |
|---|---|---|
| After | No |
See Custom Events for the wider event API.