13
0
geforkt von Mirrors/Paper

Updated Upstream (Bukkit/CraftBukkit) (#9922)

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:
fde5602a PR-927: Add PlayerRecipeBookSettingsChangeEvent
949ff217 PR-930: Add methods to get/set evoker fang attack delay
f6f7c79d SPIGOT-7514, PR-929: Add "Enchantment Roll" API to enchant items according to Minecraft mechanics
d40e22da PR-712: Add API to get full result of crafting items

CraftBukkit Changes:
c8feb0629 PR-1291: Improve precondition message in Entity#playEffect
482c56a00 PR-1285: Add PlayerRecipeBookSettingsChangeEvent
cdf798800 PR-1290: Add methods to get/set evoker fang attack delay
2c1b5f78f SPIGOT-7514, PR-1289: Add "Enchantment Roll" API to enchant items according to Minecraft mechanics
6aa644ae9 PR-992: Add API to get full result of crafting items
ffb1319bc PR-1287: Fix scoreboards not updating in Player#setStatistic
Dieser Commit ist enthalten in:
Jake Potrebic 2023-11-11 12:25:45 -08:00
Ursprung 316e921c18
Commit aa933b773e
8 geänderte Dateien mit 66 neuen und 17 gelöschten Zeilen

Datei anzeigen

@ -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

Datei anzeigen

@ -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
+ /**

Datei anzeigen

@ -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) {

Datei anzeigen

@ -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

Datei anzeigen

@ -11,7 +11,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@@ -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<net.kyori.adventure.text.event.HoverEvent.ShowItem> asHoverEvent(final ItemStack item, final java.util.function.UnaryOperator<net.kyori.adventure.text.event.HoverEvent.ShowItem> op) {
final net.minecraft.nbt.CompoundTag tag = CraftItemStack.asNMSCopy(item).getTag();
+ // Paper end - enchantWithLevels API
}

Datei anzeigen

@ -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;
}

@ -1 +1 @@
Subproject commit 19830133bd8e6eab082ebbc24ec58a23f16a6d1f
Subproject commit fde5602a24e30d563009378e8c9b08f693b148e2

@ -1 +1 @@
Subproject commit 5a72c3c040c8570ba6cb2286f3bc2a5de60ee909
Subproject commit c8feb062965f97a637d2a3aa1f597f82251fcbbb