diff --git a/paper-api/src/main/java/org/bukkit/Bukkit.java b/paper-api/src/main/java/org/bukkit/Bukkit.java index 9a8eabc456..9708d79c1c 100644 --- a/paper-api/src/main/java/org/bukkit/Bukkit.java +++ b/paper-api/src/main/java/org/bukkit/Bukkit.java @@ -760,6 +760,61 @@ public final class Bukkit { return server.getRecipe(recipeKey); } + /** + * Get the {@link Recipe} for the list of ItemStacks provided. + * + *

The list is formatted as a crafting matrix where the index follow + * the pattern below:

+ * + *
+     * [ 0 1 2 ]
+     * [ 3 4 5 ]
+     * [ 6 7 8 ]
+     * 
+ * + *

NOTE: This method will not modify the provided ItemStack array, for that, use + * {@link #craftItem(ItemStack[], World, Player)}.

+ * + * @param craftingMatrix list of items to be crafted from. + * Must not contain more than 9 items. + * @param world The world the crafting takes place in. + * @return the {@link Recipe} resulting from the given crafting matrix. + */ + @Nullable + public static Recipe getCraftingRecipe(@NotNull ItemStack[] craftingMatrix, @NotNull World world) { + return server.getCraftingRecipe(craftingMatrix, world); + } + + /** + * Get the crafted item using the list of {@link ItemStack} provided. + * + *

The list is formatted as a crafting matrix where the index follow + * the pattern below:

+ * + *
+     * [ 0 1 2 ]
+     * [ 3 4 5 ]
+     * [ 6 7 8 ]
+     * 
+ * + *

The {@link World} and {@link Player} arguments are required to fulfill the Bukkit Crafting + * events.

+ * + *

Calls {@link org.bukkit.event.inventory.PrepareItemCraftEvent} to imitate the {@link Player} + * initiating the crafting event.

+ * + * @param craftingMatrix list of items to be crafted from. + * Must not contain more than 9 items. + * @param world The world the crafting takes place in. + * @param player The player to imitate the crafting event on. + * @return the {@link ItemStack} resulting from the given crafting matrix, if no recipe is found + * an ItemStack of {@link Material#AIR} is returned. + */ + @NotNull + public static ItemStack craftItem(@NotNull ItemStack[] craftingMatrix, @NotNull World world, @NotNull Player player) { + return server.craftItem(craftingMatrix, world, player); + } + /** * Get an iterator through the list of crafting recipes. * diff --git a/paper-api/src/main/java/org/bukkit/Server.java b/paper-api/src/main/java/org/bukkit/Server.java index 40e4036af0..3eeaa5719a 100644 --- a/paper-api/src/main/java/org/bukkit/Server.java +++ b/paper-api/src/main/java/org/bukkit/Server.java @@ -637,6 +637,57 @@ public interface Server extends PluginMessageRecipient { @Nullable public Recipe getRecipe(@NotNull NamespacedKey recipeKey); + /** + * Get the {@link Recipe} for the list of ItemStacks provided. + * + *

The list is formatted as a crafting matrix where the index follow + * the pattern below:

+ * + *
+     * [ 0 1 2 ]
+     * [ 3 4 5 ]
+     * [ 6 7 8 ]
+     * 
+ * + *

NOTE: This method will not modify the provided ItemStack array, for that, use + * {@link #craftItem(ItemStack[], World, Player)}.

+ * + * @param craftingMatrix list of items to be crafted from. + * Must not contain more than 9 items. + * @param world The world the crafting takes place in. + * @return the {@link Recipe} resulting from the given crafting matrix. + */ + @Nullable + public Recipe getCraftingRecipe(@NotNull ItemStack[] craftingMatrix, @NotNull World world); + + /** + * Get the crafted item using the list of {@link ItemStack} provided. + * + *

The list is formatted as a crafting matrix where the index follow + * the pattern below:

+ * + *
+     * [ 0 1 2 ]
+     * [ 3 4 5 ]
+     * [ 6 7 8 ]
+     * 
+ * + *

The {@link World} and {@link Player} arguments are required to fulfill the Bukkit Crafting + * events.

+ * + *

Calls {@link org.bukkit.event.inventory.PrepareItemCraftEvent} to imitate the {@link Player} + * initiating the crafting event.

+ * + * @param craftingMatrix list of items to be crafted from. + * Must not contain more than 9 items. + * @param world The world the crafting takes place in. + * @param player The player to imitate the crafting event on. + * @return the {@link ItemStack} resulting from the given crafting matrix, if no recipe is found + * an ItemStack of {@link Material#AIR} is returned. + */ + @NotNull + public ItemStack craftItem(@NotNull ItemStack[] craftingMatrix, @NotNull World world, @NotNull Player player); + /** * Get an iterator through the list of crafting recipes. *