From aee3dfd0925a09491738c344b4c0c64afe433d53 Mon Sep 17 00:00:00 2001 From: Bjarne Koll Date: Sun, 15 Sep 2024 21:39:53 +0200 Subject: [PATCH] Updated Upstream (Bukkit/CraftBukkit/Spigot) (#11405) 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: 1fc1020a PR-1049: Add MenuType API 8ae2e3be PR-1055: Expand riptiding API cac68bfb SPIGOT-7890: AttributeModifier#getUniqueId() doesn't match the UUID passed to its constructor 7004fcf2 SPIGOT-7886: Fix mistake in AttributeModifier UUID shim 1ac7f950 PR-1054: Add FireworkMeta#hasPower 4cfb565f SPIGOT-7873: Add powered state for skulls CraftBukkit Changes: bbb30e7a8 SPIGOT-7894: NPE when sending tile entity update ba21e9472 SPIGOT-7895: PlayerItemBreakEvent not firing 0fb24bbe0 SPIGOT-7875: Fix PlayerItemConsumeEvent cancellation causing client-side desync 815066449 SPIGOT-7891: Can't remove second ingredient of MerchantRecipe 45c206f2c PR-1458: Add MenuType API 19c8ef9ae SPIGOT-7867: Merchant instanceof AbstractVillager always returns false 4e006d28f PR-1468: Expand riptiding API bd8aded7d Ignore checks in CraftPlayerProfile for ResolvableProfile used in profile components 8679620b5 SPIGOT-7889: Fix tool component deserialisation without speed and/or correct-for-drops 8d5222691 SPIGOT-7882, PR-1467: Fix conversion of name in Profile Component to empty if it is missing 63f91669a SPIGOT-7887: Remove duplicate ProjectileHitEvent for fireballs 7070de8c8 SPIGOT-7878: Server#getLootTable does not return null on invalid loot table 060ee6cae SPIGOT-7876: Can't kick player or disconnect player in PlayerLoginEvent when checking for cookies 7ccb86cc0 PR-1465: Add FireworkMeta#hasPower 804ad6491 SPIGOT-7873: Add powered state for skulls f9610cdcb Improve minecart movement Spigot Changes: a759b629 Rebuild patches Co-authored-by: Jake Potrebic --- ...gistryAccess-for-managing-registries.patch | 7 +++ patches/api/Add-missing-InventoryType.patch | 4 +- patches/api/Adventure.patch | 60 ++++++++++++++++-- .../Attribute-Modifier-API-improvements.patch | 33 ---------- patches/api/Code-Generation.patch | 2 + .../api/Experimental-annotations-change.patch | 2 +- .../api/Fix-Spigot-annotation-mistakes.patch | 2 +- patches/api/General-ItemMeta-fixes.patch | 25 -------- .../server/Add-EntityDamageItemEvent.patch | 17 ++++- .../server/Add-PlayerKickEvent-causes.patch | 41 ++++++++++-- ...erTradeEvent-and-PlayerPurchaseEvent.patch | 2 +- ...gistryAccess-for-managing-Registries.patch | 8 +++ .../Add-setPlayerProfile-API-for-Skulls.patch | 27 ++++---- patches/server/Adventure.patch | 46 +++++++++++--- patches/server/Basic-PlayerProfile-API.patch | 62 ++++++++++++++----- patches/server/CB-fixes.patch | 19 ------ ...gurable-projectile-relative-velocity.patch | 3 - .../Correctly-call-PlayerItemBreakEvent.patch | 34 ---------- .../Custom-replacement-for-eaten-items.patch | 2 +- patches/server/Fix-BanList-API.patch | 4 +- .../server/Fix-Player-setBlockUpdate.patch | 31 ---------- ...ItemConsumeEvent-cancelling-properly.patch | 4 +- patches/server/General-ItemMeta-fixes.patch | 29 +++------ .../Handle-Item-Meta-Inconsistencies.patch | 10 +-- patches/server/ItemStack-damage-API.patch | 8 +-- ...ipes-should-return-an-immutable-list.patch | 8 +-- patches/server/Missing-effect-cause.patch | 8 +-- .../server/Player.setPlayerProfile-API.patch | 2 +- patches/server/Properly-resend-entities.patch | 40 ++++++++++++ ...ileHitEvent-call-when-fireballs-dead.patch | 21 ------- .../Use-UserCache-for-player-heads.patch | 4 +- patches/server/Villager-resetOffers.patch | 6 +- ...ve-checking-handled-tags-in-itemmeta.patch | 4 +- work/Bukkit | 2 +- work/CraftBukkit | 2 +- work/Spigot | 2 +- 36 files changed, 304 insertions(+), 277 deletions(-) delete mode 100644 patches/server/Correctly-call-PlayerItemBreakEvent.patch delete mode 100644 patches/server/Fix-Player-setBlockUpdate.patch delete mode 100644 patches/server/Remove-ProjectileHitEvent-call-when-fireballs-dead.patch diff --git a/patches/api/Add-RegistryAccess-for-managing-registries.patch b/patches/api/Add-RegistryAccess-for-managing-registries.patch index e2b4e59750..47c7e4fb6c 100644 --- a/patches/api/Add-RegistryAccess-for-managing-registries.patch +++ b/patches/api/Add-RegistryAccess-for-managing-registries.patch @@ -267,6 +267,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 * Default server loot tables. * @@ -0,0 +0,0 @@ public interface Registry extends Iterable { + * @see MenuType + */ + @ApiStatus.Experimental +- Registry MENU = Objects.requireNonNull(Bukkit.getRegistry(MenuType.class), "No registry present for MenuType. This is a bug."); ++ Registry MENU = io.papermc.paper.registry.RegistryAccess.registryAccess().getRegistry(io.papermc.paper.registry.RegistryKey.MENU); // Paper + /** + * Server mob effects. * * @see PotionEffectType */ diff --git a/patches/api/Add-missing-InventoryType.patch b/patches/api/Add-missing-InventoryType.patch index 453eb03c2c..917c7b26c9 100644 --- a/patches/api/Add-missing-InventoryType.patch +++ b/patches/api/Add-missing-InventoryType.patch @@ -12,12 +12,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ public enum InventoryType { * Pseudo jukebox inventory with 1 slot of undefined type. */ - JUKEBOX(1, "Jukebox", false), + JUKEBOX(1, "Jukebox", null, false), + // Paper start - add missing type + /** + * Pseudo decorated pot with 1 slot of undefined type. + */ -+ DECORATED_POT(1, "Decorated Pot", false), ++ DECORATED_POT(1, "Decorated Pot", null, false), + // Paper end - add missing type /** * A crafter inventory, with 9 CRAFTING slots. diff --git a/patches/api/Adventure.patch b/patches/api/Adventure.patch index aa91b1dec6..5d1460cd30 100644 --- a/patches/api/Adventure.patch +++ b/patches/api/Adventure.patch @@ -3348,11 +3348,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +++ b/src/main/java/org/bukkit/event/inventory/InventoryType.java @@ -0,0 +0,0 @@ public enum InventoryType { private final String title; + private final MenuType menuType; private final boolean isCreatable; - + // Paper start + private final net.kyori.adventure.text.Component defaultTitleComponent; -+ + + /** + * Gets the inventory's default title. + * @@ -3362,12 +3362,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + return defaultTitleComponent; + } + // Paper end - private InventoryType(int defaultSize, /*@NotNull*/ String defaultTitle) { - this(defaultSize, defaultTitle, true); + private InventoryType(int defaultSize, /*@NotNull*/ String defaultTitle, @Nullable MenuType type) { + this(defaultSize, defaultTitle, type, true); } @@ -0,0 +0,0 @@ public enum InventoryType { - size = defaultSize; title = defaultTitle; + this.menuType = type; this.isCreatable = isCreatable; + this.defaultTitleComponent = net.kyori.adventure.text.Component.text(defaultTitle); // Paper - Adventure } @@ -4421,6 +4421,56 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + // Paper end } +diff --git a/src/main/java/org/bukkit/inventory/MenuType.java b/src/main/java/org/bukkit/inventory/MenuType.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/inventory/MenuType.java ++++ b/src/main/java/org/bukkit/inventory/MenuType.java +@@ -0,0 +0,0 @@ public interface MenuType extends Keyed { + * @param player the player the view belongs to + * @param title the title of the view + * @return the created {@link InventoryView} ++ * @deprecated Use {@link #create(HumanEntity, net.kyori.adventure.text.Component)} instead. + */ + @NotNull ++ @Deprecated(since = "1.21") // Paper - adventure + V create(@NotNull HumanEntity player, @NotNull String title); ++ ++ // Paper start - adventure ++ /** ++ * Creates a view of the specified menu type. ++ *

++ * The player provided to create this view must be the player the view ++ * is opened for. See {@link HumanEntity#openInventory(InventoryView)} ++ * for more information. ++ * ++ * @param player the player the view belongs to ++ * @param title the title of the view ++ * @return the created {@link InventoryView} ++ */ ++ @NotNull ++ V create(@NotNull HumanEntity player, @NotNull net.kyori.adventure.text.Component title); ++ // Paper end - adventure + } + ++ // Paper start - adventure ++ /** ++ * Creates a view of the specified menu type. ++ *

++ * The player provided to create this view must be the player the view ++ * is opened for. See {@link HumanEntity#openInventory(InventoryView)} ++ * for more information. ++ * ++ * @param player the player the view belongs to ++ * @param title the title of the view ++ * @return the created {@link InventoryView} ++ */ ++ @NotNull ++ InventoryView create(@NotNull HumanEntity player, @NotNull net.kyori.adventure.text.Component title); ++ // Paper end - adventure ++ + /** + * Yields this MenuType as a typed version of itself with a plain + * {@link InventoryView} representing it. diff --git a/src/main/java/org/bukkit/inventory/meta/BookMeta.java b/src/main/java/org/bukkit/inventory/meta/BookMeta.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/inventory/meta/BookMeta.java diff --git a/patches/api/Attribute-Modifier-API-improvements.patch b/patches/api/Attribute-Modifier-API-improvements.patch index 1c13b51260..b0ba3bd6f5 100644 --- a/patches/api/Attribute-Modifier-API-improvements.patch +++ b/patches/api/Attribute-Modifier-API-improvements.patch @@ -74,30 +74,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/attribute/AttributeModifier.java +++ b/src/main/java/org/bukkit/attribute/AttributeModifier.java @@ -0,0 +0,0 @@ public class AttributeModifier implements ConfigurationSerializable, Keyed { - private final Operation operation; - private final EquipmentSlotGroup slot; - -- @Deprecated -+ @Deprecated(forRemoval = true, since = "1.21") - public AttributeModifier(@NotNull String name, double amount, @NotNull Operation operation) { - this(UUID.randomUUID(), name, amount, operation); - } - -- @Deprecated -+ @Deprecated(forRemoval = true, since = "1.21") - public AttributeModifier(@NotNull UUID uuid, @NotNull String name, double amount, @NotNull Operation operation) { - this(uuid, name, amount, operation, (EquipmentSlot) null); - } - -- @Deprecated -+ @Deprecated(forRemoval = true, since = "1.21") - public AttributeModifier(@NotNull UUID uuid, @NotNull String name, double amount, @NotNull Operation operation, @Nullable EquipmentSlot slot) { - this(uuid, name, amount, operation, (slot) == null ? EquipmentSlotGroup.ANY : slot.getGroup()); - } - -- @Deprecated -+ @Deprecated(forRemoval = true, since = "1.21") - public AttributeModifier(@NotNull UUID uuid, @NotNull String name, double amount, @NotNull Operation operation, @NotNull EquipmentSlotGroup slot) { this(NamespacedKey.fromString(uuid.toString()), amount, operation, slot); } @@ -110,12 +86,3 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public AttributeModifier(@NotNull NamespacedKey key, double amount, @NotNull Operation operation, @NotNull EquipmentSlotGroup slot) { Preconditions.checkArgument(key != null, "Key cannot be null"); Preconditions.checkArgument(operation != null, "Operation cannot be null"); -@@ -0,0 +0,0 @@ public class AttributeModifier implements ConfigurationSerializable, Keyed { - * @deprecated attributes are now identified by keys - */ - @NotNull -- @Deprecated -+ @Deprecated(forRemoval = true, since = "1.21") - public UUID getUniqueId() { - return UUID.fromString(getKey().toString()); - } diff --git a/patches/api/Code-Generation.patch b/patches/api/Code-Generation.patch index 70e7343c63..5f7b8e563b 100644 --- a/patches/api/Code-Generation.patch +++ b/patches/api/Code-Generation.patch @@ -114,6 +114,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.generator.structure.Structure; +import org.bukkit.generator.structure.StructureType; +import org.bukkit.inventory.ItemType; ++import org.bukkit.inventory.MenuType; +import org.bukkit.inventory.meta.trim.TrimMaterial; +import org.bukkit.inventory.meta.trim.TrimPattern; +import org.bukkit.map.MapCursor; @@ -235,6 +236,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + RegistryKey FLUID = create("fluid"); + RegistryKey FROG_VARIANT = create("frog_variant"); + RegistryKey MAP_DECORATION_TYPE = create("map_decoration_type"); ++ RegistryKey MENU = create("menu"); +} diff --git a/src/main/java/io/papermc/paper/registry/RegistryKeyImpl.java b/src/main/java/io/papermc/paper/registry/RegistryKeyImpl.java new file mode 100644 diff --git a/patches/api/Experimental-annotations-change.patch b/patches/api/Experimental-annotations-change.patch index 8373838154..2de94fb59e 100644 --- a/patches/api/Experimental-annotations-change.patch +++ b/patches/api/Experimental-annotations-change.patch @@ -170,7 +170,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 * A crafter inventory, with 9 CRAFTING slots. */ - @ApiStatus.Experimental - CRAFTER(9, "Crafter"), + CRAFTER(9, "Crafter", MenuType.CRAFTER_3X3), /** * The new smithing inventory, with 3 CRAFTING slots and 1 RESULT slot. diff --git a/src/main/java/org/bukkit/inventory/CrafterInventory.java b/src/main/java/org/bukkit/inventory/CrafterInventory.java diff --git a/patches/api/Fix-Spigot-annotation-mistakes.patch b/patches/api/Fix-Spigot-annotation-mistakes.patch index b840b7095e..29b2c61c70 100644 --- a/patches/api/Fix-Spigot-annotation-mistakes.patch +++ b/patches/api/Fix-Spigot-annotation-mistakes.patch @@ -1276,7 +1276,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 */ - @Deprecated + @Deprecated(forRemoval = true) // Paper - SMITHING_NEW(4, "Upgrade Gear"), + SMITHING_NEW(4, "Upgrade Gear", MenuType.SMITHING), ; diff --git a/src/main/java/org/bukkit/event/player/PlayerBedLeaveEvent.java b/src/main/java/org/bukkit/event/player/PlayerBedLeaveEvent.java diff --git a/patches/api/General-ItemMeta-fixes.patch b/patches/api/General-ItemMeta-fixes.patch index 57712162f5..2c8d895461 100644 --- a/patches/api/General-ItemMeta-fixes.patch +++ b/patches/api/General-ItemMeta-fixes.patch @@ -132,31 +132,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 /** * Checks to see if this item has a maximum amount of damage. * -diff --git a/src/main/java/org/bukkit/inventory/meta/FireworkMeta.java b/src/main/java/org/bukkit/inventory/meta/FireworkMeta.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/org/bukkit/inventory/meta/FireworkMeta.java -+++ b/src/main/java/org/bukkit/inventory/meta/FireworkMeta.java -@@ -0,0 +0,0 @@ public interface FireworkMeta extends ItemMeta { - */ - boolean hasEffects(); - -+ // Paper start - add hasPower -+ /** -+ * Checks if power is defined on this meta. -+ * -+ * @return true if there is a power specified -+ */ -+ boolean hasPower(); -+ // Paper end - add hasPower -+ - /** - * Gets the approximate height the firework will fly. - * - * @return approximate flight height of the firework. -+ * @see #hasPower() - */ - int getPower(); - diff --git a/src/main/java/org/bukkit/inventory/meta/ItemMeta.java b/src/main/java/org/bukkit/inventory/meta/ItemMeta.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/inventory/meta/ItemMeta.java diff --git a/patches/server/Add-EntityDamageItemEvent.patch b/patches/server/Add-EntityDamageItemEvent.patch index ab7a590c4d..2b81f938b4 100644 --- a/patches/server/Add-EntityDamageItemEvent.patch +++ b/patches/server/Add-EntityDamageItemEvent.patch @@ -52,15 +52,26 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } int j = this.getDamageValue() + amount; +@@ -0,0 +0,0 @@ public final class ItemStack implements DataComponentHolder { + if (j >= this.getMaxDamage()) { + Item item = this.getItem(); + // CraftBukkit start - Check for item breaking +- if (this.count == 1) { +- org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerItemBreakEvent(player, this); ++ if (this.count == 1 && player instanceof final ServerPlayer serverPlayer) { // Paper - Add EntityDamageItemEvent ++ org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerItemBreakEvent(serverPlayer, this); // Paper - Add EntityDamageItemEvent + } + // CraftBukkit end + @@ -0,0 +0,0 @@ public final class ItemStack implements DataComponentHolder { entityplayer = null; } - this.hurtAndBreak(amount, worldserver, entityplayer, (item) -> { + this.hurtAndBreak(amount, worldserver, entity, (item) -> { // Paper - Add EntityDamageItemEvent - // CraftBukkit start - Check for item breaking - if (this.count == 1 && entity instanceof net.minecraft.world.entity.player.Player) { - org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerItemBreakEvent((net.minecraft.world.entity.player.Player) entity, this); + entity.onEquippedItemBroken(item, slot); + }); + } diff --git a/src/main/java/net/minecraft/world/item/enchantment/effects/DamageItem.java b/src/main/java/net/minecraft/world/item/enchantment/effects/DamageItem.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/item/enchantment/effects/DamageItem.java diff --git a/patches/server/Add-PlayerKickEvent-causes.patch b/patches/server/Add-PlayerKickEvent-causes.patch index c4d0896a73..faf7779703 100644 --- a/patches/server/Add-PlayerKickEvent-causes.patch +++ b/patches/server/Add-PlayerKickEvent-causes.patch @@ -98,6 +98,17 @@ diff --git a/src/main/java/net/minecraft/server/network/ServerCommonPacketListen index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java +@@ -0,0 +0,0 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack + } + + @Override +- public void kickPlayer(Component reason) { +- this.disconnect(reason); ++ public void kickPlayer(Component reason, org.bukkit.event.player.PlayerKickEvent.Cause cause) { // Paper - kick event causes ++ this.disconnect(reason, cause); // Paper - kick event causes + } + // CraftBukkit end + private static final Logger LOGGER = LogUtils.getLogger(); @@ -0,0 +0,0 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack } else if (!this.isSingleplayerOwner()) { // Paper start - This needs to be handled on the main thread for plugins @@ -418,6 +429,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } } +diff --git a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java ++++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java +@@ -0,0 +0,0 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, + } + + @Override +- public void kickPlayer(Component reason) { ++ public void kickPlayer(Component reason, org.bukkit.event.player.PlayerKickEvent.Cause cause) { // Paper - kick event causes - during login, no event can be called. + this.disconnect(reason); + } + // CraftBukkit end diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/server/players/PlayerList.java @@ -475,11 +499,20 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -0,0 +0,0 @@ public class CraftPlayer extends CraftHumanEntity implements Player { - org.spigotmc.AsyncCatcher.catchOp("player kick"); // Spigot - if (this.getHandle().connection == null) return; -- this.getHandle().connection.disconnect(CraftChatMessage.fromStringOrEmpty(message, true)); -+ this.getHandle().connection.disconnect(CraftChatMessage.fromStringOrEmpty(message, true), org.bukkit.event.player.PlayerKickEvent.Cause.PLUGIN); // Paper - kick event cause + void sendPacket(Packet packet); + +- void kickPlayer(Component reason); ++ void kickPlayer(Component reason, org.bukkit.event.player.PlayerKickEvent.Cause cause); // Paper - kick event causes + } + + public record CookieFuture(ResourceLocation key, CompletableFuture future) { +@@ -0,0 +0,0 @@ public class CraftPlayer extends CraftHumanEntity implements Player { + @Override + public void kickPlayer(String message) { + org.spigotmc.AsyncCatcher.catchOp("player kick"); // Spigot +- this.getHandle().transferCookieConnection.kickPlayer(CraftChatMessage.fromStringOrEmpty(message, true)); ++ this.getHandle().transferCookieConnection.kickPlayer(CraftChatMessage.fromStringOrEmpty(message, true), org.bukkit.event.player.PlayerKickEvent.Cause.PLUGIN); // Paper - kick event cause } // Paper start diff --git a/patches/server/Add-PlayerTradeEvent-and-PlayerPurchaseEvent.patch b/patches/server/Add-PlayerTradeEvent-and-PlayerPurchaseEvent.patch index 40da395197..eb74781231 100644 --- a/patches/server/Add-PlayerTradeEvent-and-PlayerPurchaseEvent.patch +++ b/patches/server/Add-PlayerTradeEvent-and-PlayerPurchaseEvent.patch @@ -211,7 +211,7 @@ diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantCustom. index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantCustom.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantCustom.java -@@ -0,0 +0,0 @@ public class CraftMerchantCustom extends CraftMerchant { +@@ -0,0 +0,0 @@ public class CraftMerchantCustom implements CraftMerchant { return this.trades; } diff --git a/patches/server/Add-RegistryAccess-for-managing-Registries.patch b/patches/server/Add-RegistryAccess-for-managing-Registries.patch index 156c6b99b6..bde3b899be 100644 --- a/patches/server/Add-RegistryAccess-for-managing-Registries.patch +++ b/patches/server/Add-RegistryAccess-for-managing-Registries.patch @@ -50,6 +50,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.craftbukkit.generator.structure.CraftStructure; +import org.bukkit.craftbukkit.generator.structure.CraftStructureType; +import org.bukkit.craftbukkit.inventory.CraftItemType; ++import org.bukkit.craftbukkit.inventory.CraftMenuType; +import org.bukkit.craftbukkit.inventory.trim.CraftTrimMaterial; +import org.bukkit.craftbukkit.inventory.trim.CraftTrimPattern; +import org.bukkit.craftbukkit.legacy.FieldRename; @@ -64,6 +65,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.entity.memory.MemoryKey; +import org.bukkit.generator.structure.StructureType; +import org.bukkit.inventory.ItemType; ++import org.bukkit.inventory.MenuType; +import org.bukkit.inventory.meta.trim.TrimMaterial; +import org.bukkit.inventory.meta.trim.TrimPattern; +import org.bukkit.map.MapCursor; @@ -95,6 +97,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + entry(Registries.VILLAGER_PROFESSION, RegistryKey.VILLAGER_PROFESSION, Villager.Profession.class, CraftVillager.CraftProfession::new), + entry(Registries.VILLAGER_TYPE, RegistryKey.VILLAGER_TYPE, Villager.Type.class, CraftVillager.CraftType::new), + entry(Registries.MAP_DECORATION_TYPE, RegistryKey.MAP_DECORATION_TYPE, MapCursor.Type.class, CraftMapCursor.CraftType::new), ++ entry(Registries.MENU, RegistryKey.MENU, MenuType.class, CraftMenuType::new), + + // data-drivens + entry(Registries.STRUCTURE, RegistryKey.STRUCTURE, Structure.class, CraftStructure::new).delayed(), @@ -753,6 +756,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - if (bukkitClass == MusicInstrument.class) { - return new CraftRegistry<>(MusicInstrument.class, registryHolder.registryOrThrow(Registries.INSTRUMENT), CraftMusicInstrument::new, FieldRename.NONE); - } +- if (bukkitClass == MenuType.class) { +- return new CraftRegistry<>(MenuType.class, registryHolder.registryOrThrow(Registries.MENU), CraftMenuType::new, FieldRename.NONE); +- } - if (bukkitClass == PotionEffectType.class) { - return new CraftRegistry<>(PotionEffectType.class, registryHolder.registryOrThrow(Registries.MOB_EFFECT), CraftPotionEffectType::new, FieldRename.NONE); - } @@ -1181,6 +1187,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - register(Enchantment.class, Registries.ENCHANTMENT, CraftEnchantment.class, net.minecraft.world.item.enchantment.Enchantment.class); - register(GameEvent.class, Registries.GAME_EVENT, CraftGameEvent.class, net.minecraft.world.level.gameevent.GameEvent.class); - register(MusicInstrument.class, Registries.INSTRUMENT, CraftMusicInstrument.class, Instrument.class); +- register(MenuType.class, Registries.MENU, CraftMenuType.class, net.minecraft.world.inventory.MenuType.class); - register(PotionEffectType.class, Registries.MOB_EFFECT, CraftPotionEffectType.class, MobEffect.class); - register(Structure.class, Registries.STRUCTURE, CraftStructure.class, net.minecraft.world.level.levelgen.structure.Structure.class); - register(StructureType.class, Registries.STRUCTURE_TYPE, CraftStructureType.class, net.minecraft.world.level.levelgen.structure.StructureType.class); @@ -1218,6 +1225,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + register(RegistryKey.CAT_VARIANT, Cat.Type.class, Registries.CAT_VARIANT, CraftCat.CraftType.class, CatVariant.class); + register(RegistryKey.MAP_DECORATION_TYPE, MapCursor.Type.class, Registries.MAP_DECORATION_TYPE, CraftMapCursor.CraftType.class, MapDecorationType.class); + register(RegistryKey.BANNER_PATTERN, PatternType.class, Registries.BANNER_PATTERN, CraftPatternType.class, BannerPattern.class); ++ register(RegistryKey.MENU, MenuType.class, Registries.MENU, CraftMenuType.class, net.minecraft.world.inventory.MenuType.class); } - private static void register(Class bukkit, ResourceKey registry, Class craft, Class minecraft) { diff --git a/patches/server/Add-setPlayerProfile-API-for-Skulls.patch b/patches/server/Add-setPlayerProfile-API-for-Skulls.patch index 507a3a5eae..a95e9a79e2 100644 --- a/patches/server/Add-setPlayerProfile-API-for-Skulls.patch +++ b/patches/server/Add-setPlayerProfile-API-for-Skulls.patch @@ -18,13 +18,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @Override + public void setPlayerProfile(com.destroystokyo.paper.profile.PlayerProfile profile) { + Preconditions.checkNotNull(profile, "profile"); -+ this.profile = com.destroystokyo.paper.profile.CraftPlayerProfile.asAuthlibCopy(profile); ++ this.profile = com.destroystokyo.paper.profile.CraftPlayerProfile.asResolvableProfileCopy(profile); + } + + @javax.annotation.Nullable + @Override + public com.destroystokyo.paper.profile.PlayerProfile getPlayerProfile() { -+ return profile != null ? com.destroystokyo.paper.profile.CraftPlayerProfile.asBukkitCopy(profile) : null; ++ return profile != null ? new com.destroystokyo.paper.profile.CraftPlayerProfile(profile) : null; + } + // Paper end + @@ -42,8 +42,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 if (profile == null) { this.profile = null; } else { -- this.profile = CraftPlayerProfile.validateSkullProfile(((CraftPlayerProfile) profile).buildGameProfile()); -+ this.profile = CraftPlayerProfile.validateSkullProfile(((com.destroystokyo.paper.profile.SharedPlayerProfile) profile).buildGameProfile()); // Paper +- this.profile = new ResolvableProfile(CraftPlayerProfile.validateSkullProfile(((CraftPlayerProfile) profile).buildGameProfile())); ++ this.profile = CraftPlayerProfile.validateSkullProfile(((com.destroystokyo.paper.profile.SharedPlayerProfile) profile).buildResolvableProfile()); // Paper } } @@ -52,19 +52,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java @@ -0,0 +0,0 @@ class CraftMetaSkull extends CraftMetaItem implements SkullMeta { - return this.hasOwner() ? this.profile.getName() : null; + return this.hasOwner() ? this.profile.name().orElse(null) : null; } + // Paper start + @Override + public void setPlayerProfile(@org.jetbrains.annotations.Nullable com.destroystokyo.paper.profile.PlayerProfile profile) { -+ setProfile((profile == null) ? null : com.destroystokyo.paper.profile.CraftPlayerProfile.asAuthlibCopy(profile)); ++ setProfile((profile == null) ? null : com.destroystokyo.paper.profile.CraftPlayerProfile.asResolvableProfileCopy(profile)); + } + + @org.jetbrains.annotations.Nullable + @Override + public com.destroystokyo.paper.profile.PlayerProfile getPlayerProfile() { -+ return profile != null ? com.destroystokyo.paper.profile.CraftPlayerProfile.asBukkitCopy(profile) : null; ++ return profile != null ? new com.destroystokyo.paper.profile.CraftPlayerProfile(profile) : null; + } + // Paper end + @@ -85,18 +85,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @Override + @Deprecated // Paper public void setOwnerProfile(PlayerProfile profile) { - if (profile == null) { - this.setProfile(null); +- if (profile instanceof CraftPlayerProfile craftPlayerProfile) { +- this.setProfile(CraftPlayerProfile.validateSkullProfile(craftPlayerProfile.buildResolvableProfile())); ++ if (profile instanceof final com.destroystokyo.paper.profile.SharedPlayerProfile sharedProfile) { ++ this.setProfile(CraftPlayerProfile.validateSkullProfile(sharedProfile.buildResolvableProfile())); // Paper } else { -- this.setProfile(CraftPlayerProfile.validateSkullProfile(((CraftPlayerProfile) profile).buildGameProfile())); -+ this.setProfile(CraftPlayerProfile.validateSkullProfile(((com.destroystokyo.paper.profile.SharedPlayerProfile) profile).buildGameProfile())); // Paper + this.setProfile(null); } - } - @@ -0,0 +0,0 @@ class CraftMetaSkull extends CraftMetaItem implements SkullMeta { super.serialize(builder); - if (this.profile != null) { + if (this.hasOwner()) { - builder.put(CraftMetaSkull.SKULL_OWNER.BUKKIT, new CraftPlayerProfile(this.profile)); + builder.put(CraftMetaSkull.SKULL_OWNER.BUKKIT, new com.destroystokyo.paper.profile.CraftPlayerProfile(this.profile)); // Paper } diff --git a/patches/server/Adventure.patch b/patches/server/Adventure.patch index 896d5c47c6..4de7e0f593 100644 --- a/patches/server/Adventure.patch +++ b/patches/server/Adventure.patch @@ -3346,13 +3346,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } + // Paper start -+ @Override + @Override + public net.kyori.adventure.text.Component shutdownMessage() { + String msg = getShutdownMessage(); + return msg != null ? net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(msg) : null; + } + // Paper end - @Override ++ @Override + @Deprecated // Paper public String getShutdownMessage() { return this.configuration.getString("settings.shutdown-message"); @@ -3429,12 +3429,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } + // Paper start -+ @Override + @Override + public Merchant createMerchant(net.kyori.adventure.text.Component title) { + return new org.bukkit.craftbukkit.inventory.CraftMerchantCustom(title == null ? InventoryType.MERCHANT.defaultTitle() : title); + } + // Paper end - @Override ++ @Override + @Deprecated // Paper public Merchant createMerchant(String title) { return new CraftMerchantCustom(title == null ? InventoryType.MERCHANT.getDefaultTitle() : title); @@ -4253,7 +4253,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } @@ -0,0 +0,0 @@ public class CraftPlayer extends CraftHumanEntity implements Player { - this.getHandle().connection.disconnect(CraftChatMessage.fromStringOrEmpty(message, true)); + this.getHandle().transferCookieConnection.kickPlayer(CraftChatMessage.fromStringOrEmpty(message, true)); } + // Paper start @@ -4846,29 +4846,55 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + // Paper end - Adventure } +diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMenuType.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMenuType.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMenuType.java ++++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMenuType.java +@@ -0,0 +0,0 @@ public class CraftMenuType implements MenuType.Typed + + @Override + public V create(final HumanEntity player, final String title) { ++ // Paper start - adventure ++ return create(player, net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(title)); ++ } ++ @Override ++ public V create(final HumanEntity player, final net.kyori.adventure.text.Component title) { ++ // Paper end - adventure + Preconditions.checkArgument(player != null, "The given player must not be null"); + Preconditions.checkArgument(title != null, "The given title must not be null"); + Preconditions.checkArgument(player instanceof CraftHumanEntity, "The given player must be a CraftHumanEntity"); +@@ -0,0 +0,0 @@ public class CraftMenuType implements MenuType.Typed + final ServerPlayer serverPlayer = (ServerPlayer) craftHuman.getHandle(); + + final AbstractContainerMenu container = this.typeData.get().menuBuilder().build(serverPlayer, this.handle); +- container.setTitle(CraftChatMessage.fromString(title)[0]); ++ container.setTitle(io.papermc.paper.adventure.PaperAdventure.asVanilla(title)); // Paper - adventure + container.checkReachable = false; + return (V) container.getBukkitView(); + } diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantCustom.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantCustom.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantCustom.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantCustom.java -@@ -0,0 +0,0 @@ import org.bukkit.craftbukkit.util.CraftChatMessage; +@@ -0,0 +0,0 @@ public class CraftMerchantCustom implements CraftMerchant { - public class CraftMerchantCustom extends CraftMerchant { + private MinecraftMerchant merchant; + @Deprecated // Paper - Adventure public CraftMerchantCustom(String title) { - super(new MinecraftMerchant(title)); + this.merchant = new MinecraftMerchant(title); this.getMerchant().craftMerchant = this; } + // Paper start + public CraftMerchantCustom(net.kyori.adventure.text.Component title) { -+ super(new MinecraftMerchant(title)); ++ this.merchant = new MinecraftMerchant(title); + getMerchant().craftMerchant = this; + } + // Paper end @Override public String toString() { -@@ -0,0 +0,0 @@ public class CraftMerchantCustom extends CraftMerchant { +@@ -0,0 +0,0 @@ public class CraftMerchantCustom implements CraftMerchant { private Player tradingPlayer; protected CraftMerchant craftMerchant; diff --git a/patches/server/Basic-PlayerProfile-API.patch b/patches/server/Basic-PlayerProfile-API.patch index 7d561dad2b..8ae62d2813 100644 --- a/patches/server/Basic-PlayerProfile-API.patch +++ b/patches/server/Basic-PlayerProfile-API.patch @@ -34,6 +34,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import net.minecraft.server.MinecraftServer; +import net.minecraft.server.players.GameProfileCache; +import net.minecraft.util.StringUtil; ++import net.minecraft.world.item.component.ResolvableProfile; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.Validate; +import org.bukkit.configuration.serialization.SerializableAs; @@ -52,6 +53,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +@SerializableAs("PlayerProfile") +public class CraftPlayerProfile implements PlayerProfile, SharedPlayerProfile { + ++ private boolean emptyName; ++ private boolean emptyUUID; + private GameProfile profile; + private final PropertySet properties = new PropertySet(); + @@ -61,6 +64,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + public CraftPlayerProfile(UUID id, String name) { + this.profile = createAuthLibProfile(id, name); ++ this.emptyName = name == null; ++ this.emptyUUID = id == null; + } + + public CraftPlayerProfile(GameProfile profile) { @@ -68,6 +73,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + this.profile = profile; + } + ++ public CraftPlayerProfile(ResolvableProfile resolvableProfile) { ++ this(resolvableProfile.id().orElse(null), resolvableProfile.name().orElse(null)); ++ copyProfileProperties(resolvableProfile.gameProfile(), this.profile); ++ } ++ + @Override + public boolean hasProperty(String property) { + return profile.getProperties().containsKey(property); @@ -106,7 +116,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + @Nullable + @Override + public UUID getId() { -+ return profile.getId().equals(Util.NIL_UUID) ? null : profile.getId(); ++ return this.emptyUUID ? null : this.profile.getId(); + } + + @Override @@ -116,6 +126,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + final UUID previousId = this.getId(); + this.profile = createAuthLibProfile(uuid, previousProfile.getName()); + copyProfileProperties(previousProfile, this.profile); ++ this.emptyUUID = uuid == null; + return previousId; + } + @@ -127,7 +138,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + @Nullable + @Override + public String getName() { -+ return profile.getName(); ++ return this.emptyName ? null : this.profile.getName(); + } + + @Override @@ -136,6 +147,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + GameProfile prev = this.profile; + this.profile = createAuthLibProfile(prev.getId(), name); + copyProfileProperties(prev, this.profile); ++ this.emptyName = name == null; + return prev.getName(); + } + @@ -184,6 +196,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + + @Override ++ public @NotNull ResolvableProfile buildResolvableProfile() { ++ if (this.emptyName || this.emptyUUID) { ++ return new ResolvableProfile(this.emptyName ? Optional.empty() : Optional.of(this.profile.getName()), this.emptyUUID ? Optional.empty() : Optional.of(this.profile.getId()), this.profile.getProperties()); ++ } else { ++ return new ResolvableProfile(this.buildGameProfile()); ++ } ++ } ++ ++ @Override + public CraftPlayerProfile clone() { + CraftPlayerProfile clone = new CraftPlayerProfile(this.getId(), this.getName()); + clone.setProperties(getProperties()); @@ -251,6 +272,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + public boolean complete(boolean textures) { + return complete(textures, GlobalConfiguration.get().proxies.isProxyOnlineMode()); + } ++ + public boolean complete(boolean textures, boolean onlineMode) { + if (this.isComplete() && (!textures || hasTextures())) { // Don't do lookup if we already have everything + return true; @@ -328,6 +350,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + return craft.getGameProfile(); + } + ++ public static ResolvableProfile asResolvableProfileCopy(PlayerProfile profile) { ++ return ((SharedPlayerProfile) profile).buildResolvableProfile(); ++ } ++ + @Override + public @NotNull Map serialize() { + Map map = new LinkedHashMap<>(); @@ -368,10 +394,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + + @Override -+ public boolean equals(Object obj) { -+ if (this == obj) return true; -+ if (!(obj instanceof CraftPlayerProfile otherProfile)) return false; -+ return Objects.equals(this.profile, otherProfile.profile); ++ public boolean equals(final Object o) { ++ if (this == o) return true; ++ if (o == null || this.getClass() != o.getClass()) return false; ++ final CraftPlayerProfile that = (CraftPlayerProfile) o; ++ return this.emptyName == that.emptyName && this.emptyUUID == that.emptyUUID && Objects.equals(this.profile, that.profile); ++ } ++ ++ @Override ++ public int hashCode() { ++ return Objects.hash(this.emptyName, this.emptyUUID, this.profile); + } + + @Override @@ -382,11 +414,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + "]"; + } + -+ @Override -+ public int hashCode() { -+ return this.profile.hashCode(); -+ } -+ + private class PropertySet extends AbstractSet { + + @Override @@ -539,6 +566,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + +import com.mojang.authlib.GameProfile; +import com.mojang.authlib.properties.Property; ++import net.minecraft.world.item.component.ResolvableProfile; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + @@ -557,6 +585,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + @Nullable void setProperty(@NotNull String propertyName, @Nullable Property property); + + @NotNull GameProfile buildGameProfile(); ++ ++ @NotNull ResolvableProfile buildResolvableProfile(); +} diff --git a/src/main/java/net/minecraft/server/Main.java b/src/main/java/net/minecraft/server/Main.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 @@ -659,8 +689,8 @@ diff --git a/src/main/java/org/bukkit/craftbukkit/profile/CraftPlayerProfile.jav index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/profile/CraftPlayerProfile.java +++ b/src/main/java/org/bukkit/craftbukkit/profile/CraftPlayerProfile.java -@@ -0,0 +0,0 @@ import org.bukkit.profile.PlayerProfile; - import org.bukkit.profile.PlayerTextures; +@@ -0,0 +0,0 @@ import org.bukkit.profile.PlayerTextures; + import org.jetbrains.annotations.ApiStatus; @SerializableAs("PlayerProfile") -public final class CraftPlayerProfile implements PlayerProfile { @@ -687,10 +717,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public Map serialize() { + // Paper - diff on change Map map = new LinkedHashMap<>(); - if (this.getUniqueId() != null) { - map.put("uniqueId", this.getUniqueId().toString()); + if (this.uniqueId != null) { + map.put("uniqueId", this.uniqueId.toString()); @@ -0,0 +0,0 @@ public final class CraftPlayerProfile implements PlayerProfile { - }); + this.properties.forEach((propertyName, property) -> propertiesData.add(CraftProfileProperty.serialize(property))); map.put("properties", propertiesData); } + // Paper - diff on change diff --git a/patches/server/CB-fixes.patch b/patches/server/CB-fixes.patch index 0a42901f38..29339a5348 100644 --- a/patches/server/CB-fixes.patch +++ b/patches/server/CB-fixes.patch @@ -82,25 +82,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + // Paper end } -diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java -+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -@@ -0,0 +0,0 @@ public final class CraftServer implements Server { - Preconditions.checkArgument(key != null, "NamespacedKey key cannot be null"); - - ReloadableServerRegistries.Holder registry = this.getServer().reloadableRegistries(); -- return new CraftLootTable(key, registry.getLootTable(CraftLootTable.bukkitKeyToMinecraft(key))); -+ // Paper start - honor method contract -+ final ResourceKey lootTableKey = CraftLootTable.bukkitKeyToMinecraft(key); -+ final Optional table = registry.get().lookup(Registries.LOOT_TABLE) -+ .flatMap(registryEntryLookup -> registryEntryLookup.get(lootTableKey)) -+ .map(net.minecraft.core.Holder::value); -+ return table.map(lootTable -> new CraftLootTable(key, lootTable)).orElse(null); -+ // Paper end - } - - @Override diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/Main.java diff --git a/patches/server/Configurable-projectile-relative-velocity.patch b/patches/server/Configurable-projectile-relative-velocity.patch index 63ce2091f6..2018cf7f62 100644 --- a/patches/server/Configurable-projectile-relative-velocity.patch +++ b/patches/server/Configurable-projectile-relative-velocity.patch @@ -34,9 +34,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 Vec3 vec3d = shooter.getKnownMovement(); - + // Paper start - allow disabling relative velocity -+ if (vec3d.lengthSqr() > 4D * 4D) { -+ vec3d = vec3d.normalize().scale(2D); -+ } + if (!shooter.level().paperConfig().misc.disableRelativeProjectileVelocity) { this.setDeltaMovement(this.getDeltaMovement().add(vec3d.x, shooter.onGround() ? 0.0D : vec3d.y, vec3d.z)); + } diff --git a/patches/server/Correctly-call-PlayerItemBreakEvent.patch b/patches/server/Correctly-call-PlayerItemBreakEvent.patch deleted file mode 100644 index 0ed89ad701..0000000000 --- a/patches/server/Correctly-call-PlayerItemBreakEvent.patch +++ /dev/null @@ -1,34 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Bjarne Koll -Date: Fri, 12 Jul 2024 19:09:44 +0200 -Subject: [PATCH] Correctly call PlayerItemBreakEvent - -The minecraft 1.21 update changed the invocation order in -ItemStack#hurtAndBreak, now first shrinking the itemstack to a count of -zero and then invoking the break callback. - -This leads to spigots logic no longer firing at all. This patch now -correctly executes on count of zero and temporarily bumps the count to -one before passing it to event handlers to maintain compatibility with -the event contracts. - -This fix was chosen over invoking the callback prior to shrinking the -stack to not disrupt potential new vanilla changes that might depend on -this behaviour. - -diff --git a/src/main/java/net/minecraft/world/item/ItemStack.java b/src/main/java/net/minecraft/world/item/ItemStack.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/world/item/ItemStack.java -+++ b/src/main/java/net/minecraft/world/item/ItemStack.java -@@ -0,0 +0,0 @@ public final class ItemStack implements DataComponentHolder { - - this.hurtAndBreak(amount, worldserver, entity, (item) -> { // Paper - Add EntityDamageItemEvent - // CraftBukkit start - Check for item breaking -- if (this.count == 1 && entity instanceof net.minecraft.world.entity.player.Player) { -+ if (this.count == 0 && entity instanceof net.minecraft.world.entity.player.Player) { // Paper - correctly call item break event - run if count reached 0 -+ this.setCount(1); // Paper - correctly call item break event - grow to count 1 - org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerItemBreakEvent((net.minecraft.world.entity.player.Player) entity, this); -+ this.setCount(0); // Paper - correctly call item break event - reset to count 0 - } - // CraftBukkit end - if (slot != null) entity.onEquippedItemBroken(item, slot); // Paper - itemstack damage API - do not process entity related callbacks when damaging from API diff --git a/patches/server/Custom-replacement-for-eaten-items.patch b/patches/server/Custom-replacement-for-eaten-items.patch index 754d70a50e..0c7bd0ec3d 100644 --- a/patches/server/Custom-replacement-for-eaten-items.patch +++ b/patches/server/Custom-replacement-for-eaten-items.patch @@ -13,7 +13,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 // CraftBukkit start - fire PlayerItemConsumeEvent ItemStack itemstack; + PlayerItemConsumeEvent event = null; // Paper - if (this instanceof ServerPlayer) { + if (this instanceof ServerPlayer entityPlayer) { org.bukkit.inventory.ItemStack craftItem = CraftItemStack.asBukkitCopy(this.useItem); org.bukkit.inventory.EquipmentSlot hand = org.bukkit.craftbukkit.CraftEquipmentSlot.getHand(enumhand); - PlayerItemConsumeEvent event = new PlayerItemConsumeEvent((Player) this.getBukkitEntity(), craftItem, hand); diff --git a/patches/server/Fix-BanList-API.patch b/patches/server/Fix-BanList-API.patch index b5c73b3e0f..30ab8b4a64 100644 --- a/patches/server/Fix-BanList-API.patch +++ b/patches/server/Fix-BanList-API.patch @@ -259,8 +259,8 @@ diff --git a/src/main/java/org/bukkit/craftbukkit/profile/CraftPlayerProfile.jav index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/profile/CraftPlayerProfile.java +++ b/src/main/java/org/bukkit/craftbukkit/profile/CraftPlayerProfile.java -@@ -0,0 +0,0 @@ import org.bukkit.profile.PlayerProfile; - import org.bukkit.profile.PlayerTextures; +@@ -0,0 +0,0 @@ import org.bukkit.profile.PlayerTextures; + import org.jetbrains.annotations.ApiStatus; @SerializableAs("PlayerProfile") -public final class CraftPlayerProfile implements PlayerProfile, com.destroystokyo.paper.profile.SharedPlayerProfile { // Paper diff --git a/patches/server/Fix-Player-setBlockUpdate.patch b/patches/server/Fix-Player-setBlockUpdate.patch deleted file mode 100644 index 02a6d95d81..0000000000 --- a/patches/server/Fix-Player-setBlockUpdate.patch +++ /dev/null @@ -1,31 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Jake Potrebic -Date: Tue, 4 Jun 2024 19:48:03 -0700 -Subject: [PATCH] Fix Player#setBlockUpdate - -BlockEntity needs its Level set - -diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java -+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java -@@ -0,0 +0,0 @@ public abstract class CraftBlockEntityState extends Craft - @Nullable - public Packet getUpdatePacket(@NotNull Location location) { - T vanillaTileEntitiy = (T) BlockEntity.loadStatic(CraftLocation.toBlockPosition(location), this.getHandle(), this.getSnapshotNBT(), this.getRegistryAccess()); -+ vanillaTileEntitiy.setLevel(((org.bukkit.craftbukkit.CraftWorld) location.getWorld()).getHandle()); // Paper - set level. Required for accessing RegistryAccess - return ClientboundBlockEntityDataPacket.create(vanillaTileEntitiy); - } - -diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -@@ -0,0 +0,0 @@ public class CraftPlayer extends CraftHumanEntity implements Player { - public void sendBlockUpdate(@NotNull Location location, @NotNull TileState tileState) throws IllegalArgumentException { - Preconditions.checkArgument(location != null, "Location can not be null"); - Preconditions.checkArgument(tileState != null, "TileState can not be null"); -+ Preconditions.checkArgument(location.getWorld() != null, "Location must have a world"); // Paper - - if (this.getHandle().connection == null) return; - diff --git a/patches/server/Fix-PlayerItemConsumeEvent-cancelling-properly.patch b/patches/server/Fix-PlayerItemConsumeEvent-cancelling-properly.patch index 17c518cd10..33d2dfacb1 100644 --- a/patches/server/Fix-PlayerItemConsumeEvent-cancelling-properly.patch +++ b/patches/server/Fix-PlayerItemConsumeEvent-cancelling-properly.patch @@ -18,5 +18,5 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 if (event.isCancelled()) { + this.stopUsingItem(); // Paper - event is using an item, clear active item to reset its use // Update client - ((ServerPlayer) this).getBukkitEntity().updateInventory(); - ((ServerPlayer) this).getBukkitEntity().updateScaledHealth(); + if (this.useItem.getItem() instanceof net.minecraft.world.item.SuspiciousStewItem itemSuspiciousStew) { + itemSuspiciousStew.cancelUsingItem(entityPlayer, this.useItem); diff --git a/patches/server/General-ItemMeta-fixes.patch b/patches/server/General-ItemMeta-fixes.patch index ee5c8593ea..23d7f46047 100644 --- a/patches/server/General-ItemMeta-fixes.patch +++ b/patches/server/General-ItemMeta-fixes.patch @@ -48,7 +48,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java @@ -0,0 +0,0 @@ public abstract class CraftBlockEntityState extends Craft - return nbt; + return this.snapshot.getUpdateTag(this.getRegistryAccess()); } + // Paper start - properly save blockentity itemstacks @@ -89,8 +89,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper start - support updating profile after resolving it + final CraftMetaItem.Applicator tag = new CraftMetaItem.Applicator() { + @Override -+ void skullCallback(final com.mojang.authlib.GameProfile gameProfile) { -+ itemStack.set(DataComponents.PROFILE, new net.minecraft.world.item.component.ResolvableProfile(gameProfile)); ++ void skullCallback(final net.minecraft.world.item.component.ResolvableProfile profile) { ++ itemStack.set(DataComponents.PROFILE, profile); + } + }; + // Paper end - support updating profile after resolving it @@ -105,8 +105,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper start - support updating profile after resolving it + CraftMetaItem.Applicator tag = new CraftMetaItem.Applicator() { + @Override -+ void skullCallback(final com.mojang.authlib.GameProfile gameProfile) { -+ item.set(DataComponents.PROFILE, new net.minecraft.world.item.component.ResolvableProfile(gameProfile)); ++ void skullCallback(final net.minecraft.world.item.component.ResolvableProfile resolvableProfile) { ++ item.set(DataComponents.PROFILE, resolvableProfile); + } + }; + // Paper end - support updating profile after resolving it @@ -931,11 +931,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + return !(this.effects != null || this.hasPower()); // Paper - empty effects list should stay on the item } -- boolean hasPower() { -+ public boolean hasPower() { // Paper - add hasPower to API - return this.power != null; - } - + @Override @@ -0,0 +0,0 @@ class CraftMetaFirework extends CraftMetaItem implements FireworkMeta { if (meta instanceof CraftMetaFirework that) { @@ -990,15 +986,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + this.safelyAddEffects(effects, true); // Paper - limit firework effects } - @Override -@@ -0,0 +0,0 @@ class CraftMetaFirework extends CraftMetaItem implements FireworkMeta { - - @Override - public int getPower() { -- return this.hasPower() ? this.power : 1; -+ return this.hasPower() ? this.power : 0; // Paper - 0 is correct - } - @Override diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 @@ -1013,7 +1000,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - private final DataComponentPatch.Builder builder = DataComponentPatch.builder(); + final DataComponentPatch.Builder builder = DataComponentPatch.builder(); // Paper - private -> package-private -+ void skullCallback(com.mojang.authlib.GameProfile gameProfile) {} // Paper - support updating profile after resolving it ++ void skullCallback(net.minecraft.world.item.component.ResolvableProfile resolvableProfile) {} // Paper - support updating profile after resolving it Applicator put(ItemMetaKeyType key, T value) { this.builder.set(key.TYPE, value); @@ -1897,7 +1884,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - ownerProfile.update().thenAccept((filledProfile) -> { + ownerProfile.update().thenAcceptAsync((filledProfile) -> { // Paper - run on main thread this.setOwnerProfile(filledProfile); -- tag.put(CraftMetaSkull.SKULL_PROFILE, new ResolvableProfile(this.profile)); +- tag.put(CraftMetaSkull.SKULL_PROFILE, this.profile); - }); + tag.skullCallback(this.profile); // Paper - actually set profile on itemstack + }, ((org.bukkit.craftbukkit.CraftServer) org.bukkit.Bukkit.getServer()).getServer()); // Paper - run on main thread diff --git a/patches/server/Handle-Item-Meta-Inconsistencies.patch b/patches/server/Handle-Item-Meta-Inconsistencies.patch index 0c92e288a8..a7ff95fcda 100644 --- a/patches/server/Handle-Item-Meta-Inconsistencies.patch +++ b/patches/server/Handle-Item-Meta-Inconsistencies.patch @@ -285,13 +285,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } @@ -0,0 +0,0 @@ public final class CraftPlayerProfile implements PlayerProfile { - - public CraftPlayerProfile(UUID uniqueId, String name) { - Preconditions.checkArgument((uniqueId != null) || !StringUtils.isBlank(name), "uniqueId is null or name is blank"); + if (applyPreconditions) { + Preconditions.checkArgument((uniqueId != null) || !StringUtils.isBlank(name), "uniqueId is null or name is blank"); + } + Preconditions.checkArgument(name == null || name.length() <= 16, "The name of the profile is longer than 16 characters"); // Paper - Validate + Preconditions.checkArgument(name == null || net.minecraft.util.StringUtil.isValidPlayerName(name), "The name of the profile contains invalid characters: %s", name); // Paper - Validate - this.uniqueId = (uniqueId == null) ? Util.NIL_UUID : uniqueId; - this.name = (name == null) ? "" : name; + this.uniqueId = uniqueId; + this.name = name; } @@ -0,0 +0,0 @@ public final class CraftPlayerProfile implements PlayerProfile { // Assert: (property == null) || property.getName().equals(propertyName) diff --git a/patches/server/ItemStack-damage-API.patch b/patches/server/ItemStack-damage-API.patch index 85229f0146..4484eed22c 100644 --- a/patches/server/ItemStack-damage-API.patch +++ b/patches/server/ItemStack-damage-API.patch @@ -42,13 +42,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 if (world instanceof ServerLevel worldserver) { @@ -0,0 +0,0 @@ public final class ItemStack implements DataComponentHolder { - org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerItemBreakEvent((net.minecraft.world.entity.player.Player) entity, this); - } - // CraftBukkit end + } + + this.hurtAndBreak(amount, worldserver, entity, (item) -> { // Paper - Add EntityDamageItemEvent - entity.onEquippedItemBroken(item, slot); - }); + if (slot != null) entity.onEquippedItemBroken(item, slot); // Paper - itemstack damage API - do not process entity related callbacks when damaging from API -+ }, force); // Paper ++ }, force); // Paper - itemstack damage API } } diff --git a/patches/server/Merchant-getRecipes-should-return-an-immutable-list.patch b/patches/server/Merchant-getRecipes-should-return-an-immutable-list.patch index bdb44d9c15..05564b668d 100644 --- a/patches/server/Merchant-getRecipes-should-return-an-immutable-list.patch +++ b/patches/server/Merchant-getRecipes-should-return-an-immutable-list.patch @@ -8,12 +8,12 @@ diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchant.java b index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchant.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchant.java -@@ -0,0 +0,0 @@ public class CraftMerchant implements Merchant { +@@ -0,0 +0,0 @@ public interface CraftMerchant extends Merchant { @Override - public List getRecipes() { -- return Collections.unmodifiableList(Lists.transform(this.merchant.getOffers(), new Function() { -+ return List.copyOf(Lists.transform(this.merchant.getOffers(), new Function() { // Paper - javadoc says 'an immutable list of trades' - not 'an unmodifiable view of a list of trades'. fixes issue with setRecipes(getRecipes()) + default List getRecipes() { +- return Collections.unmodifiableList(Lists.transform(this.getMerchant().getOffers(), new Function() { ++ return List.copyOf(Lists.transform(this.getMerchant().getOffers(), new Function() { // Paper - javadoc says 'an immutable list of trades' - not 'an unmodifiable view of a list of trades'. fixes issue with setRecipes(getRecipes()) @Override public MerchantRecipe apply(net.minecraft.world.item.trading.MerchantOffer recipe) { return recipe.asBukkit(); diff --git a/patches/server/Missing-effect-cause.patch b/patches/server/Missing-effect-cause.patch index d9b0567594..3f932df976 100644 --- a/patches/server/Missing-effect-cause.patch +++ b/patches/server/Missing-effect-cause.patch @@ -48,11 +48,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/world/item/SuspiciousStewItem.java +++ b/src/main/java/net/minecraft/world/item/SuspiciousStewItem.java @@ -0,0 +0,0 @@ public class SuspiciousStewItem extends Item { - SuspiciousStewEffects suspiciousStewEffects = stack.getOrDefault(DataComponents.SUSPICIOUS_STEW_EFFECTS, SuspiciousStewEffects.EMPTY); + while (iterator.hasNext()) { + SuspiciousStewEffects.Entry suspicioussteweffects_a = (SuspiciousStewEffects.Entry) iterator.next(); - for (SuspiciousStewEffects.Entry entry : suspiciousStewEffects.effects()) { -- user.addEffect(entry.createEffectInstance()); -+ user.addEffect(entry.createEffectInstance(), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.FOOD); // Paper - Add missing effect cause +- user.addEffect(suspicioussteweffects_a.createEffectInstance()); ++ user.addEffect(suspicioussteweffects_a.createEffectInstance(), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.FOOD); // Paper - Add missing effect cause } return super.finishUsingItem(stack, world, user); diff --git a/patches/server/Player.setPlayerProfile-API.patch b/patches/server/Player.setPlayerProfile-API.patch index b67ee7dbd9..2e52590300 100644 --- a/patches/server/Player.setPlayerProfile-API.patch +++ b/patches/server/Player.setPlayerProfile-API.patch @@ -72,7 +72,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - public PlayerProfile getPlayerProfile() { - return new CraftPlayerProfile(this.profile); + public com.destroystokyo.paper.profile.PlayerProfile getPlayerProfile() { // Paper -+ return new com.destroystokyo.paper.profile.CraftPlayerProfile(this.profile); // Paper ++ return com.destroystokyo.paper.profile.CraftPlayerProfile.asBukkitCopy(this.profile); // Paper } public Server getServer() { diff --git a/patches/server/Properly-resend-entities.patch b/patches/server/Properly-resend-entities.patch index ba2175913d..d88b1ccffd 100644 --- a/patches/server/Properly-resend-entities.patch +++ b/patches/server/Properly-resend-entities.patch @@ -114,6 +114,25 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 this.sendLevelInfo(player, worldserver1); +@@ -0,0 +0,0 @@ public abstract class PlayerList { + } + + public void sendActiveEffects(LivingEntity entity, ServerGamePacketListenerImpl networkHandler) { ++ // Paper start - collect packets ++ this.sendActiveEffects(entity, networkHandler::send); ++ } ++ public void sendActiveEffects(LivingEntity entity, java.util.function.Consumer> packetConsumer) { ++ // Paper end - collect packets + Iterator iterator = entity.getActiveEffects().iterator(); + + while (iterator.hasNext()) { + MobEffectInstance mobeffect = (MobEffectInstance) iterator.next(); + +- networkHandler.send(new ClientboundUpdateMobEffectPacket(entity.getId(), mobeffect, false)); ++ packetConsumer.accept(new ClientboundUpdateMobEffectPacket(entity.getId(), mobeffect, false)); // Paper - collect packets + } + + } diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java @@ -196,6 +215,27 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 return Optional.of(InteractionResult.FAIL); } entity.playSound(((Bucketable) entity).getPickupSound(), 1.0F, 1.0F); +diff --git a/src/main/java/net/minecraft/world/item/SuspiciousStewItem.java b/src/main/java/net/minecraft/world/item/SuspiciousStewItem.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/world/item/SuspiciousStewItem.java ++++ b/src/main/java/net/minecraft/world/item/SuspiciousStewItem.java +@@ -0,0 +0,0 @@ public class SuspiciousStewItem extends Item { + public void cancelUsingItem(net.minecraft.server.level.ServerPlayer entityplayer, ItemStack itemstack) { + SuspiciousStewEffects suspicioussteweffects = (SuspiciousStewEffects) itemstack.getOrDefault(DataComponents.SUSPICIOUS_STEW_EFFECTS, SuspiciousStewEffects.EMPTY); + ++ final List> packets = new java.util.ArrayList<>(); // Paper - bundlize packets + for (SuspiciousStewEffects.Entry suspicioussteweffects_a : suspicioussteweffects.effects()) { +- entityplayer.connection.send(new net.minecraft.network.protocol.game.ClientboundRemoveMobEffectPacket(entityplayer.getId(), suspicioussteweffects_a.effect())); ++ packets.add(new net.minecraft.network.protocol.game.ClientboundRemoveMobEffectPacket(entityplayer.getId(), suspicioussteweffects_a.effect())); // Paper - bundlize packets + } +- entityplayer.server.getPlayerList().sendActivePlayerEffects(entityplayer); ++ // Paper start - bundlize packets ++ entityplayer.server.getPlayerList().sendActiveEffects(entityplayer, packets::add); ++ entityplayer.connection.send(new net.minecraft.network.protocol.game.ClientboundBundlePacket(packets)); ++ // Paper end - bundlize packets + } + // CraftBukkit end + } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java diff --git a/patches/server/Remove-ProjectileHitEvent-call-when-fireballs-dead.patch b/patches/server/Remove-ProjectileHitEvent-call-when-fireballs-dead.patch deleted file mode 100644 index 3d1ede7e19..0000000000 --- a/patches/server/Remove-ProjectileHitEvent-call-when-fireballs-dead.patch +++ /dev/null @@ -1,21 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Aikar -Date: Sat, 16 Jan 2021 14:30:12 -0500 -Subject: [PATCH] Remove ProjectileHitEvent call when fireballs dead - -The duplicate ProjectileHitEvent in EntityFireball was removed. The -event was always called before the duplicate call. - -diff --git a/src/main/java/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java b/src/main/java/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java -+++ b/src/main/java/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java -@@ -0,0 +0,0 @@ public abstract class AbstractHurtingProjectile extends Projectile { - - // CraftBukkit start - Fire ProjectileHitEvent - if (this.isRemoved()) { -- CraftEventFactory.callProjectileHitEvent(this, movingobjectposition); -+ // CraftEventFactory.callProjectileHitEvent(this, movingobjectposition); // Paper - this is an undesired duplicate event - } - // CraftBukkit end - } diff --git a/patches/server/Use-UserCache-for-player-heads.patch b/patches/server/Use-UserCache-for-player-heads.patch index 783d63b915..b519024a7e 100644 --- a/patches/server/Use-UserCache-for-player-heads.patch +++ b/patches/server/Use-UserCache-for-player-heads.patch @@ -12,13 +12,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 if (name == null) { this.setProfile(null); } else { -- this.setProfile(new GameProfile(Util.NIL_UUID, name)); +- this.setProfile(new ResolvableProfile(new GameProfile(Util.NIL_UUID, name))); + // Paper start - Use Online Players Skull + GameProfile newProfile = null; + net.minecraft.server.level.ServerPlayer player = net.minecraft.server.MinecraftServer.getServer().getPlayerList().getPlayerByName(name); + if (player != null) newProfile = player.getGameProfile(); + if (newProfile == null) newProfile = new GameProfile(Util.NIL_UUID, name); -+ this.setProfile(newProfile); ++ this.setProfile(new ResolvableProfile(newProfile)); + // Paper end } diff --git a/patches/server/Villager-resetOffers.patch b/patches/server/Villager-resetOffers.patch index 8236856ac4..1d0e543abe 100644 --- a/patches/server/Villager-resetOffers.patch +++ b/patches/server/Villager-resetOffers.patch @@ -26,9 +26,9 @@ diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractVillager.j index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractVillager.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractVillager.java -@@ -0,0 +0,0 @@ public class CraftAbstractVillager extends CraftAgeable implements AbstractVilla - public HumanEntity getTrader() { - return this.getMerchant().getTrader(); +@@ -0,0 +0,0 @@ public class CraftAbstractVillager extends CraftAgeable implements CraftMerchant + public Inventory getInventory() { + return new CraftInventory(this.getHandle().getInventory()); } + + // Paper start - Villager#resetOffers diff --git a/patches/server/improve-checking-handled-tags-in-itemmeta.patch b/patches/server/improve-checking-handled-tags-in-itemmeta.patch index b32071c62d..162ac964b4 100644 --- a/patches/server/improve-checking-handled-tags-in-itemmeta.patch +++ b/patches/server/improve-checking-handled-tags-in-itemmeta.patch @@ -741,8 +741,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + CraftMetaSkull(DataComponentPatch tag, java.util.Set> extraHandledDcts) { // Paper + super(tag, extraHandledDcts); // Paper - getOrEmpty(tag, CraftMetaSkull.SKULL_PROFILE).ifPresent((resolvableProfile) -> { - this.setProfile(resolvableProfile.gameProfile()); + getOrEmpty(tag, CraftMetaSkull.SKULL_PROFILE).ifPresent(this::setProfile); + diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSpawnEgg.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSpawnEgg.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSpawnEgg.java diff --git a/work/Bukkit b/work/Bukkit index 4068c6aa92..1fc1020ad0 160000 --- a/work/Bukkit +++ b/work/Bukkit @@ -1 +1 @@ -Subproject commit 4068c6aa92024936b8d21a56d83048784d700864 +Subproject commit 1fc1020ad0d91a1cf6bfaae6f0441c24be701fbf diff --git a/work/CraftBukkit b/work/CraftBukkit index 7548afcf24..bbb30e7a85 160000 --- a/work/CraftBukkit +++ b/work/CraftBukkit @@ -1 +1 @@ -Subproject commit 7548afcf2470885065171982aa1c813196e98b09 +Subproject commit bbb30e7a853eb15c00dfea1bd46715101c777c8b diff --git a/work/Spigot b/work/Spigot index ca581228b6..a759b629cb 160000 --- a/work/Spigot +++ b/work/Spigot @@ -1 +1 @@ -Subproject commit ca581228b6f5c2b4ee8236f604d5ea288f970c24 +Subproject commit a759b629cbf86401aab56b8c3f21a635e9e76c15