diff --git a/patches/api/Add-enchantWithLevels-API.patch b/patches/api/Add-enchantWithLevels-API.patch index b95ed29d8d..778f6fb684 100644 --- a/patches/api/Add-enchantWithLevels-API.patch +++ b/patches/api/Add-enchantWithLevels-API.patch @@ -3,15 +3,55 @@ 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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/inventory/ItemFactory.java +++ b/src/main/java/org/bukkit/inventory/ItemFactory.java @@ -0,0 +0,0 @@ public interface ItemFactory { - Material getSpawnEgg(@NotNull EntityType type); + * @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 the modified ItemStack, or a copy if the ItemStack cannot be enchanted directly ++ * @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); + + /** +@@ -0,0 +0,0 @@ public interface ItemFactory { + * @param allowTreasures allow the treasure enchants, e.g. mending, if true. + * @return the modified ItemStack, or a copy if the ItemStack cannot be + * enchanted directly ++ * @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); + + /** +@@ -0,0 +0,0 @@ public interface ItemFactory { + * @param allowTreasures allow treasure enchantments, e.g. mending, if true. + * @return the modified ItemStack, or a copy if the ItemStack cannot be + * enchanted directly ++ * @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 +@@ -0,0 +0,0 @@ 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. + * @@ -27,10 +67,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @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. - * ++ // 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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/inventory/ItemStack.java diff --git a/patches/api/Adventure.patch b/patches/api/Adventure.patch index 78ee8119ff..df1c751ecb 100644 --- a/patches/api/Adventure.patch +++ b/patches/api/Adventure.patch @@ -4012,8 +4012,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +++ b/src/main/java/org/bukkit/inventory/ItemFactory.java @@ -0,0 +0,0 @@ public interface ItemFactory { */ - @Nullable - Material getSpawnEgg(@NotNull EntityType type); + @NotNull + ItemStack enchantItem(@NotNull final ItemStack item, final int level, final boolean allowTreasures); + + // Paper start - Adventure + /** diff --git a/patches/server/Add-dropLeash-variable-to-EntityUnleashEvent.patch b/patches/server/Add-dropLeash-variable-to-EntityUnleashEvent.patch index 0ac4d68f3e..e3e609c1e1 100644 --- a/patches/server/Add-dropLeash-variable-to-EntityUnleashEvent.patch +++ b/patches/server/Add-dropLeash-variable-to-EntityUnleashEvent.patch @@ -126,7 +126,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java @@ -0,0 +0,0 @@ public class CraftEventFactory { - return itemInHand; + Bukkit.getPluginManager().callEvent(new PlayerRecipeBookSettingsChangeEvent(player.getBukkitEntity(), bukkitType, open, filter)); } - public static PlayerUnleashEntityEvent callPlayerUnleashEntityEvent(Mob entity, net.minecraft.world.entity.player.Player player, InteractionHand enumhand) { diff --git a/patches/server/Adventure.patch b/patches/server/Adventure.patch index c982448901..d4f07d02f1 100644 --- a/patches/server/Adventure.patch +++ b/patches/server/Adventure.patch @@ -4288,8 +4288,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java @@ -0,0 +0,0 @@ public final class CraftItemFactory implements ItemFactory { - - return CraftMagicNumbers.getMaterial(nmsItem); + EnchantmentHelper.enchantItem(source, craft.handle, level, allowTreasures); + return craft; } + + // Paper start - Adventure diff --git a/patches/server/Implement-enchantWithLevels-API.patch b/patches/server/Implement-enchantWithLevels-API.patch index 09afc07924..9b55b45df5 100644 --- a/patches/server/Implement-enchantWithLevels-API.patch +++ b/patches/server/Implement-enchantWithLevels-API.patch @@ -9,9 +9,21 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java @@ -0,0 +0,0 @@ public final class CraftItemFactory implements ItemFactory { + } + + CraftItemStack craft = (CraftItemStack) itemStack; +- EnchantmentHelper.enchantItem(source, craft.handle, level, allowTreasures); +- return craft; ++ return EnchantmentHelper.enchantItem(source, craft.handle, level, allowTreasures).asBukkitCopy(); // Paper - fix broken implementation } // Paper start - Adventure +@@ -0,0 +0,0 @@ public final class CraftItemFactory implements ItemFactory { + return eggItem == null ? null : new net.minecraft.world.item.ItemStack(eggItem).asBukkitMirror(); + } + // Paper end ++ ++ // Paper start - enchantWithLevels API + @Override + public ItemStack enchantWithLevels(ItemStack itemStack, int levels, boolean allowTreasure, java.util.Random random) { + Preconditions.checkArgument(itemStack != null, "Argument 'itemStack' must not be null"); @@ -26,7 +38,5 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + final net.minecraft.world.item.ItemStack enchanted = net.minecraft.world.item.enchantment.EnchantmentHelper.enchantItem(new org.bukkit.craftbukkit.util.RandomSourceWrapper(random), internalStack, levels, allowTreasure); + return CraftItemStack.asCraftMirror(enchanted); + } -+ - @Override - public net.kyori.adventure.text.event.HoverEvent asHoverEvent(final ItemStack item, final java.util.function.UnaryOperator op) { - final net.minecraft.nbt.CompoundTag tag = CraftItemStack.asNMSCopy(item).getTag(); ++ // Paper end - enchantWithLevels API + } diff --git a/patches/server/Use-TerminalConsoleAppender-for-console-improvements.patch b/patches/server/Use-TerminalConsoleAppender-for-console-improvements.patch index 21aad62470..c623043b85 100644 --- a/patches/server/Use-TerminalConsoleAppender-for-console-improvements.patch +++ b/patches/server/Use-TerminalConsoleAppender-for-console-improvements.patch @@ -397,9 +397,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 import java.util.stream.Collectors; import javax.imageio.ImageIO; -import jline.console.ConsoleReader; - import net.minecraft.advancements.Advancement; ++// import jline.console.ConsoleReader; import net.minecraft.advancements.AdvancementHolder; import net.minecraft.commands.CommandSourceStack; + import net.minecraft.commands.Commands; @@ -0,0 +0,0 @@ public final class CraftServer implements Server { return this.logger; } diff --git a/work/Bukkit b/work/Bukkit index 19830133bd..fde5602a24 160000 --- a/work/Bukkit +++ b/work/Bukkit @@ -1 +1 @@ -Subproject commit 19830133bd8e6eab082ebbc24ec58a23f16a6d1f +Subproject commit fde5602a24e30d563009378e8c9b08f693b148e2 diff --git a/work/CraftBukkit b/work/CraftBukkit index 5a72c3c040..c8feb06296 160000 --- a/work/CraftBukkit +++ b/work/CraftBukkit @@ -1 +1 @@ -Subproject commit 5a72c3c040c8570ba6cb2286f3bc2a5de60ee909 +Subproject commit c8feb062965f97a637d2a3aa1f597f82251fcbbb