aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/api/0372-Add-enchantWithLevels-API.patch
diff options
context:
space:
mode:
authorNassim Jahnke <[email protected]>2022-10-02 09:56:36 +0200
committerGitHub <[email protected]>2022-10-02 09:56:36 +0200
commit928bcc8d3a058221146cea1de7d42d7e178e78f2 (patch)
treefdb518a8812097f983c41d36ea693baf5c208554 /patches/api/0372-Add-enchantWithLevels-API.patch
parentec3cfa9b7f147cf097692144f665893748fadc3b (diff)
downloadPaper-928bcc8d3a058221146cea1de7d42d7e178e78f2.tar.gz
Paper-928bcc8d3a058221146cea1de7d42d7e178e78f2.zip
Updated Upstream (Bukkit/CraftBukkit) (#8430)
Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: 09943450 Update SnakeYAML version 5515734f SPIGOT-7162: Incorrect description for Entity#getVehicle javadoc 6f82b381 PR-788: Add getHand() to all relevant events CraftBukkit Changes: aaf484f6f SPIGOT-7163: CraftMerchantRecipe doesn't copy demand and specialPrice from BukkitMerchantRecipe 5329dd6fd PR-1107: Add getHand() to all relevant events 93061706e SPIGOT-7045: Ocelots never spawn with babies with spawn reason OCELOT_BABY
Diffstat (limited to 'patches/api/0372-Add-enchantWithLevels-API.patch')
-rw-r--r--patches/api/0372-Add-enchantWithLevels-API.patch62
1 files changed, 62 insertions, 0 deletions
diff --git a/patches/api/0372-Add-enchantWithLevels-API.patch b/patches/api/0372-Add-enchantWithLevels-API.patch
new file mode 100644
index 0000000000..394fcb62bf
--- /dev/null
+++ b/patches/api/0372-Add-enchantWithLevels-API.patch
@@ -0,0 +1,62 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Jason Penilla <[email protected]>
+Date: Wed, 16 Mar 2022 20:35:13 -0700
+Subject: [PATCH] Add enchantWithLevels API
+
+
+diff --git a/src/main/java/org/bukkit/inventory/ItemFactory.java b/src/main/java/org/bukkit/inventory/ItemFactory.java
+index 2acafae468fcbb7213d6b6c30803a3924a3bbc30..40edff7c93b6bf75de81102326667135b9344666 100644
+--- a/src/main/java/org/bukkit/inventory/ItemFactory.java
++++ b/src/main/java/org/bukkit/inventory/ItemFactory.java
+@@ -161,6 +161,22 @@ public interface ItemFactory {
+ Material updateMaterial(@NotNull final ItemMeta meta, @NotNull final Material material) throws IllegalArgumentException;
+
+ // Paper start
++ /**
++ * Randomly enchants a copy of the provided {@link ItemStack} using the given experience levels.
++ *
++ * <p>If the provided ItemStack is already enchanted, the existing enchants will be removed before enchanting.</p>
++ *
++ * <p>Levels must be in range {@code [1, 30]}.</p>
++ *
++ * @param itemStack ItemStack to enchant
++ * @param levels levels to use for enchanting
++ * @param allowTreasure whether to allow enchantments where {@link org.bukkit.enchantments.Enchantment#isTreasure()} returns true
++ * @param random {@link java.util.Random} instance to use for enchanting
++ * @return enchanted copy of the provided ItemStack
++ * @throws IllegalArgumentException on bad arguments
++ */
++ @NotNull ItemStack enchantWithLevels(@NotNull ItemStack itemStack, @org.jetbrains.annotations.Range(from = 1, to = 30) int levels, boolean allowTreasure, @NotNull java.util.Random random);
++
+ /**
+ * Creates a hover event for the given item.
+ *
+diff --git a/src/main/java/org/bukkit/inventory/ItemStack.java b/src/main/java/org/bukkit/inventory/ItemStack.java
+index 77ef41527a05e2d7899633ef7fa813774dd15bd9..b8a344fd900dcbd4b28085a54b85b16c742e9c6f 100644
+--- a/src/main/java/org/bukkit/inventory/ItemStack.java
++++ b/src/main/java/org/bukkit/inventory/ItemStack.java
+@@ -648,6 +648,24 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, net.kyor
+ }
+
+ // Paper start
++ /**
++ * Randomly enchants a copy of this {@link ItemStack} using the given experience levels.
++ *
++ * <p>If this ItemStack is already enchanted, the existing enchants will be removed before enchanting.</p>
++ *
++ * <p>Levels must be in range {@code [1, 30]}.</p>
++ *
++ * @param levels levels to use for enchanting
++ * @param allowTreasure whether to allow enchantments where {@link org.bukkit.enchantments.Enchantment#isTreasure()} returns true
++ * @param random {@link java.util.Random} instance to use for enchanting
++ * @return enchanted copy of the provided ItemStack
++ * @throws IllegalArgumentException on bad arguments
++ */
++ @NotNull
++ public ItemStack enchantWithLevels(final @org.jetbrains.annotations.Range(from = 1, to = 30) int levels, final boolean allowTreasure, final @NotNull java.util.Random random) {
++ return Bukkit.getServer().getItemFactory().enchantWithLevels(this, levels, allowTreasure, random);
++ }
++
+ @NotNull
+ @Override
+ public net.kyori.adventure.text.event.HoverEvent<net.kyori.adventure.text.event.HoverEvent.ShowItem> asHoverEvent(final @NotNull java.util.function.UnaryOperator<net.kyori.adventure.text.event.HoverEvent.ShowItem> op) {