From d3087536e9f12a9f62ef70b0ddaf14aca7ff915b Mon Sep 17 00:00:00 2001 From: Jake Potrebic Date: Wed, 16 Mar 2022 08:57:51 -0700 Subject: [PATCH] Updated Upstream (Bukkit/CraftBukkit) (#7604) 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: 33a2b476 PR-734: Make PlayerInventory#getItem Nullable CraftBukkit Changes: 953d3ddc SPIGOT-3034: PlayerKickEvent.setLeaveMessage(String) doesn't actually do anything 2c47af0c SPIGOT-6963: CraftMetaBlockState#getBlockState applied TileEntity ids without the minecraft namespace prefix. --- .../api/Fix-Spigot-annotation-mistakes.patch | 12 ++++++++ patches/api/Fix-upstream-javadocs.patch | 13 --------- patches/server/Adventure.patch | 4 +-- ...g-Broken-behavior-of-PlayerJoinEvent.patch | 2 +- ...k-event-leave-message-not-being-sent.patch | 20 +++++++++++++ ...Load-Chunks-for-Login-Asynchronously.patch | 2 +- patches/server/MC-Utils.patch | 2 +- .../server/Make-some-itemstacks-nonnull.patch | 28 +++++++++++++++++++ .../PlayerNaturallySpawnCreaturesEvent.patch | 2 +- scripts/upstreamCommit.sh | 2 +- work/Bukkit | 2 +- work/CraftBukkit | 2 +- 12 files changed, 69 insertions(+), 22 deletions(-) create mode 100644 patches/server/Make-some-itemstacks-nonnull.patch diff --git a/patches/api/Fix-Spigot-annotation-mistakes.patch b/patches/api/Fix-Spigot-annotation-mistakes.patch index ce5eb13f76..39e7361a37 100644 --- a/patches/api/Fix-Spigot-annotation-mistakes.patch +++ b/patches/api/Fix-Spigot-annotation-mistakes.patch @@ -235,6 +235,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 /** * Return the ItemStack from the helmet slot +@@ -0,0 +0,0 @@ public interface PlayerInventory extends Inventory { + * + * @param slot the slot to get the ItemStack + * +- * @return the ItemStack in the given slot or null if there is not one ++ * @return the ItemStack in the given slot + */ +- @Nullable ++ @NotNull // Paper + public ItemStack getItem(@NotNull EquipmentSlot slot); + + /** 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/api/Fix-upstream-javadocs.patch b/patches/api/Fix-upstream-javadocs.patch index fe7812e65e..fd128d9ec7 100644 --- a/patches/api/Fix-upstream-javadocs.patch +++ b/patches/api/Fix-upstream-javadocs.patch @@ -122,16 +122,3 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public Location getTo() { return to; } -diff --git a/src/main/java/org/bukkit/inventory/PlayerInventory.java b/src/main/java/org/bukkit/inventory/PlayerInventory.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/org/bukkit/inventory/PlayerInventory.java -+++ b/src/main/java/org/bukkit/inventory/PlayerInventory.java -@@ -0,0 +0,0 @@ public interface PlayerInventory extends Inventory { - * - * @return the ItemStack in the given slot - */ -- @NotNull -+ @Nullable - public ItemStack getItem(@NotNull EquipmentSlot slot); - - /** diff --git a/patches/server/Adventure.patch b/patches/server/Adventure.patch index 07595130e2..2d5adcd866 100644 --- a/patches/server/Adventure.patch +++ b/patches/server/Adventure.patch @@ -1283,8 +1283,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 if (this.cserver.getServer().isRunning()) { this.cserver.getPluginManager().callEvent(event); @@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser - return; } + this.player.kickLeaveMessage = event.getLeaveMessage(); // CraftBukkit - SPIGOT-3034: Forward leave message to PlayerQuitEvent // Send the possibly modified leave message - s = event.getReason(); - final Component ichatbasecomponent = CraftChatMessage.fromString(s, true)[0]; @@ -1468,7 +1468,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 entityplayer.closeContainer(); } -- PlayerQuitEvent playerQuitEvent = new PlayerQuitEvent(entityplayer.getBukkitEntity(), "\u00A7e" + entityplayer.getScoreboardName() + " left the game"); +- PlayerQuitEvent playerQuitEvent = new PlayerQuitEvent(entityplayer.getBukkitEntity(), entityplayer.kickLeaveMessage != null ? entityplayer.kickLeaveMessage : "\u00A7e" + entityplayer.getScoreboardName() + " left the game"); + PlayerQuitEvent playerQuitEvent = new PlayerQuitEvent(entityplayer.getBukkitEntity(), net.kyori.adventure.text.Component.translatable("multiplayer.player.left", net.kyori.adventure.text.format.NamedTextColor.YELLOW, com.destroystokyo.paper.PaperConfig.useDisplayNameInQuit ? entityplayer.getBukkitEntity().displayName() : net.kyori.adventure.text.Component.text(entityplayer.getScoreboardName()))); this.cserver.getPluginManager().callEvent(playerQuitEvent); entityplayer.getBukkitEntity().disconnect(playerQuitEvent.getQuitMessage()); diff --git a/patches/server/Fix-Longstanding-Broken-behavior-of-PlayerJoinEvent.patch b/patches/server/Fix-Longstanding-Broken-behavior-of-PlayerJoinEvent.patch index 07f4670261..6d9248a36a 100644 --- a/patches/server/Fix-Longstanding-Broken-behavior-of-PlayerJoinEvent.patch +++ b/patches/server/Fix-Longstanding-Broken-behavior-of-PlayerJoinEvent.patch @@ -49,8 +49,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public boolean sentListPacket = false; + public boolean supressTrackerForLogin = false; // Paper public Integer clientViewDistance; + public String kickLeaveMessage = null; // SPIGOT-3034: Forward leave message to PlayerQuitEvent // CraftBukkit end - public PlayerNaturallySpawnCreaturesEvent playerNaturallySpawnedEvent; // Paper 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 diff --git a/patches/server/Fixes-kick-event-leave-message-not-being-sent.patch b/patches/server/Fixes-kick-event-leave-message-not-being-sent.patch index 54567f9b52..d48294681c 100644 --- a/patches/server/Fixes-kick-event-leave-message-not-being-sent.patch +++ b/patches/server/Fixes-kick-event-leave-message-not-being-sent.patch @@ -4,10 +4,30 @@ Date: Wed, 7 Jul 2021 16:19:41 -0700 Subject: [PATCH] Fixes kick event leave message not being sent +diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java ++++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java +@@ -0,0 +0,0 @@ public class ServerPlayer extends Player { + public boolean supressTrackerForLogin = false; // Paper + public boolean didPlayerJoinEvent = false; // Paper + public Integer clientViewDistance; +- public String kickLeaveMessage = null; // SPIGOT-3034: Forward leave message to PlayerQuitEvent + // CraftBukkit end + public PlayerNaturallySpawnCreaturesEvent playerNaturallySpawnedEvent; // Paper + diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser + // Do not kick the player + return; + } +- this.player.kickLeaveMessage = event.getLeaveMessage(); // CraftBukkit - SPIGOT-3034: Forward leave message to PlayerQuitEvent + // Send the possibly modified leave message + final Component ichatbasecomponent = PaperAdventure.asVanilla(event.reason()); // Paper - Adventure + // CraftBukkit end @@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser this.connection.send(new ClientboundDisconnectPacket(ichatbasecomponent), (future) -> { this.connection.disconnect(ichatbasecomponent); diff --git a/patches/server/Load-Chunks-for-Login-Asynchronously.patch b/patches/server/Load-Chunks-for-Login-Asynchronously.patch index 786150edb4..b918659e2f 100644 --- a/patches/server/Load-Chunks-for-Login-Asynchronously.patch +++ b/patches/server/Load-Chunks-for-Login-Asynchronously.patch @@ -22,8 +22,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public boolean supressTrackerForLogin = false; // Paper + public boolean didPlayerJoinEvent = false; // Paper public Integer clientViewDistance; + public String kickLeaveMessage = null; // SPIGOT-3034: Forward leave message to PlayerQuitEvent // CraftBukkit end - public PlayerNaturallySpawnCreaturesEvent playerNaturallySpawnedEvent; // Paper diff --git a/src/main/java/net/minecraft/server/level/TicketType.java b/src/main/java/net/minecraft/server/level/TicketType.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/server/level/TicketType.java diff --git a/patches/server/MC-Utils.patch b/patches/server/MC-Utils.patch index 63b58de932..6d459d54b0 100644 --- a/patches/server/MC-Utils.patch +++ b/patches/server/MC-Utils.patch @@ -6006,7 +6006,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/server/level/ServerPlayer.java +++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java @@ -0,0 +0,0 @@ public class ServerPlayer extends Player { - public Integer clientViewDistance; + public String kickLeaveMessage = null; // SPIGOT-3034: Forward leave message to PlayerQuitEvent // CraftBukkit end + public final com.destroystokyo.paper.util.misc.PooledLinkedHashSets.PooledObjectLinkedOpenHashSet cachedSingleHashSet; // Paper diff --git a/patches/server/Make-some-itemstacks-nonnull.patch b/patches/server/Make-some-itemstacks-nonnull.patch new file mode 100644 index 0000000000..4ef873eaef --- /dev/null +++ b/patches/server/Make-some-itemstacks-nonnull.patch @@ -0,0 +1,28 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Jake Potrebic +Date: Tue, 15 Mar 2022 01:38:15 -0700 +Subject: [PATCH] Make some itemstacks nonnull + + +diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryPlayer.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryPlayer.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryPlayer.java ++++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryPlayer.java +@@ -0,0 +0,0 @@ public class CraftInventoryPlayer extends CraftInventory implements org.bukkit.i + case OFF_HAND: + return this.getItemInOffHand(); + case FEET: +- return this.getBoots(); ++ return java.util.Objects.requireNonNullElseGet(this.getBoots(), () -> new ItemStack(org.bukkit.Material.AIR)); // Paper - make nonnull + case LEGS: +- return this.getLeggings(); ++ return java.util.Objects.requireNonNullElseGet(this.getLeggings(), () -> new ItemStack(org.bukkit.Material.AIR)); // Paper - make nonnull + case CHEST: +- return this.getChestplate(); ++ return java.util.Objects.requireNonNullElseGet(this.getChestplate(), () -> new ItemStack(org.bukkit.Material.AIR)); // Paper - make nonnull + case HEAD: +- return this.getHelmet(); ++ return java.util.Objects.requireNonNullElseGet(this.getHelmet(), () -> new ItemStack(org.bukkit.Material.AIR)); // Paper - make nonnull + default: + throw new IllegalArgumentException("Not implemented. This is a bug"); + } diff --git a/patches/server/PlayerNaturallySpawnCreaturesEvent.patch b/patches/server/PlayerNaturallySpawnCreaturesEvent.patch index 00d671a433..d87fb99002 100644 --- a/patches/server/PlayerNaturallySpawnCreaturesEvent.patch +++ b/patches/server/PlayerNaturallySpawnCreaturesEvent.patch @@ -71,8 +71,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 import com.mojang.authlib.GameProfile; import com.mojang.datafixers.util.Either; @@ -0,0 +0,0 @@ public class ServerPlayer extends Player { - public boolean sentListPacket = false; public Integer clientViewDistance; + public String kickLeaveMessage = null; // SPIGOT-3034: Forward leave message to PlayerQuitEvent // CraftBukkit end + public PlayerNaturallySpawnCreaturesEvent playerNaturallySpawnedEvent; // Paper diff --git a/scripts/upstreamCommit.sh b/scripts/upstreamCommit.sh index d806055bdc..fbf791c34e 100755 --- a/scripts/upstreamCommit.sh +++ b/scripts/upstreamCommit.sh @@ -5,7 +5,7 @@ PS1="$" function changelog() { base=$(git ls-tree HEAD $1 | cut -d' ' -f3 | cut -f1) - cd $1 && git log --oneline ${base}...HEAD | sed 's/\(^[0-9a-f]\{8,\}\s\|Revert\s"\)#\([0-9]\+\)/\1PR-\2/' + cd $1 && git log --oneline ${base}...HEAD | sed -E 's/(^[0-9a-f]{8,} |Revert ")#([0-9]+)/\1PR-\2/' } bukkit=$(changelog work/Bukkit) cb=$(changelog work/CraftBukkit) diff --git a/work/Bukkit b/work/Bukkit index 881e06e5db..33a2b476bb 160000 --- a/work/Bukkit +++ b/work/Bukkit @@ -1 +1 @@ -Subproject commit 881e06e5db821ef829b41e372bbcafa1df9670ab +Subproject commit 33a2b476bbde7c2c0c45e644dc99b10d65736d40 diff --git a/work/CraftBukkit b/work/CraftBukkit index 9ed7e4fbe4..953d3ddc67 160000 --- a/work/CraftBukkit +++ b/work/CraftBukkit @@ -1 +1 @@ -Subproject commit 9ed7e4fbe4c0cd2076a52d65a9ea8ae810d0e176 +Subproject commit 953d3ddc674e5fc3ef04588f9fdcc35643653463