mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-26 12:36:07 +01:00
2641c02193
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: 69fa4695 Add some missing deprecation annotations f850da2e Update Maven plugins/versions 8d8400db Use regular compiler seeing as ECJ doesn't support Java 21 JRE c29e1688 Revert "BUILDTOOLS-676: Downgrade Maven compiler version" 07bce714 SPIGOT-7355: More field renames and fixes 6a8ea764 Fix bad merge in penultimate commit 50a7920c Fix imports in previous commit 83640dd1 PR-995: Add required feature to MinecraftExperimental for easy lookups fc1f96cf BUILDTOOLS-676: Downgrade Maven compiler version CraftBukkit Changes: 90f1059ba Fix item placement 661afb43c SPIGOT-7633: Clearer error message for missing particle data 807b465b3 SPIGOT-7634: Armadillo updates infrequently 590cf09a8 Fix unit tests always seeing Mojang server as unavailable 7c7ac5eb2 SPIGOT-7636: Fix clearing ItemMeta 4a72905cf SPIGOT-7635: Fix Player#transfer and cookie methods ebb50e136 Fix incorrect Vault implementation b33fed8b7 Update Maven plugins/versions 6f00f0608 SPIGOT-7632: Control middle clicking chest does not copy contents db821f405 Use regular compiler seeing as ECJ doesn't support Java 21 JRE 8a2976737 Revert "BUILDTOOLS-676: Downgrade Maven compiler version" 0297f87bb SPIGOT-7355: More field renames and fixes 2d03bdf6a SPIGOT-7629: Fix loading banner patterns e77951fac Fix equality of deserialized display names c66f3e4fd SPIGOT-7631: Fix deserialisation of BlockStateMeta 9c2c7be8d SPIGOT-7630: Fix crash saving unticked leashed entities 8c1e7c841 PR-1384: Disable certain PlayerProfile tests, if Mojang's services or internet are not available ced93d572 SPIGOT-7626: sendSignChange() has no effect c77362cae SPIGOT-7625: ItemStack with lore cannot be serialized in 1.20.5 ff2004387 SPIGOT-7620: Fix server crash when hoppers transfer items to double chests 8b4abeb03 BUILDTOOLS-676: Downgrade Maven compiler version
101 lines
5.5 KiB
Diff
101 lines
5.5 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Jason Penilla <11360596+jpenilla@users.noreply.github.com>
|
|
Date: Wed, 16 Mar 2022 20:35:13 -0700
|
|
Subject: [PATCH] Add enchantWithLevels API
|
|
|
|
Deprecate upstream's newer and poorly implemented similar
|
|
API.
|
|
|
|
diff --git a/src/main/java/org/bukkit/inventory/ItemFactory.java b/src/main/java/org/bukkit/inventory/ItemFactory.java
|
|
index dbebaf8172ec6872f56958b9583affde4f8400a4..98a970a6582dca22e719a31559c7becea4725cb2 100644
|
|
--- a/src/main/java/org/bukkit/inventory/ItemFactory.java
|
|
+++ b/src/main/java/org/bukkit/inventory/ItemFactory.java
|
|
@@ -185,8 +185,11 @@ public interface ItemFactory {
|
|
* @param level the level to use, which is the level in the enchantment table
|
|
* @param allowTreasures allows treasure enchants, e.g. mending, if true.
|
|
* @return a new ItemStack containing the result of the Enchantment
|
|
+ * @deprecated use {@link #enchantWithLevels(ItemStack, int, boolean, java.util.Random)}. This method's implementation is poorly
|
|
+ * designed and was originally broken.
|
|
*/
|
|
@NotNull
|
|
+ @Deprecated // Paper
|
|
ItemStack enchantItem(@NotNull final Entity entity, @NotNull final ItemStack item, final int level, final boolean allowTreasures);
|
|
|
|
/**
|
|
@@ -199,8 +202,11 @@ public interface ItemFactory {
|
|
* @param level the level to use, which is the level in the enchantment table
|
|
* @param allowTreasures allow the treasure enchants, e.g. mending, if true.
|
|
* @return a new ItemStack containing the result of the Enchantment
|
|
+ * @deprecated use {@link #enchantWithLevels(ItemStack, int, boolean, java.util.Random)}. This method's implementation is poorly
|
|
+ * designed and was originally broken.
|
|
*/
|
|
@NotNull
|
|
+ @Deprecated // Paper
|
|
ItemStack enchantItem(@NotNull final World world, @NotNull final ItemStack item, final int level, final boolean allowTreasures);
|
|
|
|
/**
|
|
@@ -212,8 +218,11 @@ public interface ItemFactory {
|
|
* @param level the level to use, which is the level in the enchantment table
|
|
* @param allowTreasures allow treasure enchantments, e.g. mending, if true.
|
|
* @return a new ItemStack containing the result of the Enchantment
|
|
+ * @deprecated use {@link #enchantWithLevels(ItemStack, int, boolean, java.util.Random)}. This method's implementation is poorly
|
|
+ * designed and was originally broken.
|
|
*/
|
|
@NotNull
|
|
+ @Deprecated // Paper
|
|
ItemStack enchantItem(@NotNull final ItemStack item, final int level, final boolean allowTreasures);
|
|
|
|
// Paper start - Adventure
|
|
@@ -326,4 +335,22 @@ public interface ItemFactory {
|
|
@Deprecated
|
|
net.md_5.bungee.api.chat.hover.content.Content hoverContentOf(@NotNull org.bukkit.entity.Entity entity, @NotNull net.md_5.bungee.api.chat.BaseComponent[] customName);
|
|
// Paper end - bungee hover events
|
|
+
|
|
+ // Paper start - enchantWithLevels API
|
|
+ /**
|
|
+ * 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);
|
|
+ // Paper end - enchantWithLevels API
|
|
}
|
|
diff --git a/src/main/java/org/bukkit/inventory/ItemStack.java b/src/main/java/org/bukkit/inventory/ItemStack.java
|
|
index 0f3ef975293d0e970a35fd6845f8bf911e933169..984b6e96a5ebebc38ab62790c4d6a9946c9c6944 100644
|
|
--- a/src/main/java/org/bukkit/inventory/ItemStack.java
|
|
+++ b/src/main/java/org/bukkit/inventory/ItemStack.java
|
|
@@ -667,6 +667,24 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, Translat
|
|
}
|
|
|
|
// 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) {
|