Class PaperItems

java.lang.Object
fr.robie.machineengine.api.paper.PaperItems

public final class PaperItems extends Object
Converts between Paper ItemStacks and Items.ITEM resources (ยง23.4).
  • Method Summary

    Modifier and Type
    Method
    Description
    static @NotNull List<ResourceStack>
    drop(@NotNull org.bukkit.World world, int x, int y, int z, @NotNull List<ResourceStack> resources)
    Drops the item resources among resources at the block's position (owner thread).
    static @NotNull net.kyori.adventure.key.Key
    idOf(@NotNull org.bukkit.inventory.ItemStack stack)
    The item's id: a CraftEngine custom id for CraftEngine items, else the material key.
    static @Nullable org.bukkit.inventory.ItemStack
    itemOf(@NotNull net.kyori.adventure.key.Key id)
    One item with this id (CraftEngine or vanilla), or null if there is none.
    static void
    setIdResolver(@NotNull Function<org.bukkit.inventory.ItemStack, net.kyori.adventure.key.Key> resolver)
    How an item stack's id is found; the CraftEngine integration reports custom ids (E10).
    static void
    setItemFactory(@NotNull Function<net.kyori.adventure.key.Key, org.bukkit.inventory.ItemStack> factory)
    How an item is built from its id; the CraftEngine integration builds custom items.
    static @Nullable org.bukkit.inventory.ItemStack
    toItemStack(@NotNull ResourceVariant variant, int amount)
     
    static @NotNull List<org.bukkit.inventory.ItemStack>
    toItemStacks(@NotNull ResourceStack stack)
    Splits an item resource into stacks no larger than the item's max stack size.
    static @NotNull ResourceStack
    toResource(@NotNull org.bukkit.inventory.ItemStack stack)
     
    static @NotNull ResourceStack
    toResource(@NotNull org.bukkit.inventory.ItemStack stack, @Nullable net.kyori.adventure.key.Key itemId)
     

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • setIdResolver

      @Internal public static void setIdResolver(@NotNull @NotNull Function<org.bukkit.inventory.ItemStack, net.kyori.adventure.key.Key> resolver)
      How an item stack's id is found; the CraftEngine integration reports custom ids (E10).
    • setItemFactory

      @Internal public static void setItemFactory(@NotNull @NotNull Function<net.kyori.adventure.key.Key, org.bukkit.inventory.ItemStack> factory)
      How an item is built from its id; the CraftEngine integration builds custom items.
    • itemOf

      @Nullable public static @Nullable org.bukkit.inventory.ItemStack itemOf(@NotNull @NotNull net.kyori.adventure.key.Key id)
      One item with this id (CraftEngine or vanilla), or null if there is none.
    • idOf

      @NotNull public static @NotNull net.kyori.adventure.key.Key idOf(@NotNull @NotNull org.bukkit.inventory.ItemStack stack)
      The item's id: a CraftEngine custom id for CraftEngine items, else the material key.
    • toResource

      @NotNull public static @NotNull ResourceStack toResource(@NotNull @NotNull org.bukkit.inventory.ItemStack stack, @Nullable @Nullable net.kyori.adventure.key.Key itemId)
      Parameters:
      itemId - the item's id; pass a CraftEngine id for CraftEngine items, otherwise the material key is used
    • toResource

      @NotNull public static @NotNull ResourceStack toResource(@NotNull @NotNull org.bukkit.inventory.ItemStack stack)
    • toItemStack

      @Nullable public static @Nullable org.bukkit.inventory.ItemStack toItemStack(@NotNull @NotNull ResourceVariant variant, int amount)
      Returns:
      null if the variant is not an item
    • toItemStacks

      @NotNull public static @NotNull List<org.bukkit.inventory.ItemStack> toItemStacks(@NotNull @NotNull ResourceStack stack)
      Splits an item resource into stacks no larger than the item's max stack size.
    • drop

      @NotNull public static @NotNull List<ResourceStack> drop(@NotNull @NotNull org.bukkit.World world, int x, int y, int z, @NotNull @NotNull List<ResourceStack> resources)
      Drops the item resources among resources at the block's position (owner thread).
      Returns:
      the resources that have no item form and were not dropped