From 13442cd5c90c3e3aa1e3d4d1321d43be1ed5ff73 Mon Sep 17 00:00:00 2001 From: Jake Potrebic Date: Sun, 30 Oct 2022 19:44:25 -0700 Subject: [PATCH] Updated Upstream (Bukkit/CraftBukkit/Spigot) (#8515) 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: 9a4de097 SPIGOT-7171: Ability to get the IP/hostname players are requesting status of CraftBukkit Changes: f43634ae4 SPIGOT-7170: Cannot set slots in custom smithing inventory 48f3a2258 SPIGOT-7171: Ability to get the IP/hostname players are requesting status of 30e31b4d1 SPIGOT-7177: Certain blocks don't call BlockCanBuildEvent 982364797 SPIGOT-7174: Avoid adding air to CraftMetaBundle Spigot Changes: 6198b5ae PR-122: Add missing parentheses to pumpkin and melon growth modifier 1aec3fc1 Rebuild patches --- patches/api/Adventure.patch | 37 +++++++++++++++---- .../Add-Velocity-IP-Forwarding-Support.patch | 2 +- ...Hostname-to-AsyncPlayerPreLoginEvent.patch | 2 +- patches/server/Adventure.patch | 4 +- patches/server/Fix-MC-158900.patch | 2 +- .../server/Fix-Spigot-growth-modifiers.patch | 15 -------- patches/server/Rewrite-chunk-system.patch | 2 +- patches/server/Validate-usernames.patch | 2 +- work/Bukkit | 2 +- work/CraftBukkit | 2 +- work/Spigot | 2 +- 11 files changed, 39 insertions(+), 33 deletions(-) diff --git a/patches/api/Adventure.patch b/patches/api/Adventure.patch index 34cc439060..5960fc458c 100644 --- a/patches/api/Adventure.patch +++ b/patches/api/Adventure.patch @@ -3439,7 +3439,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/event/server/ServerListPingEvent.java +++ b/src/main/java/org/bukkit/event/server/ServerListPingEvent.java @@ -0,0 +0,0 @@ public class ServerListPingEvent extends ServerEvent implements Iterable - private static final HandlerList handlers = new HandlerList(); + private final String hostname; private final InetAddress address; private final boolean shouldSendChatPreviews; - private String motd; @@ -3447,10 +3447,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 private final int numPlayers; private int maxPlayers; -+ @Deprecated // Paper - public ServerListPingEvent(@NotNull final InetAddress address, @NotNull final String motd, final boolean shouldSendChatPreviews, final int numPlayers, final int maxPlayers) { - super(true); +@@ -0,0 +0,0 @@ public class ServerListPingEvent extends ServerEvent implements Iterable Preconditions.checkArgument(numPlayers >= 0, "Cannot have negative number of players online", numPlayers); + this.hostname = hostname; this.address = address; - this.motd = motd; + this.motd = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(motd); // Paper @@ -3461,21 +3460,27 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 * @param motd the message of the day * @param shouldSendChatPreviews if the server should send chat previews * @param maxPlayers the max number of players -+ * @deprecated in favour of {@link #ServerListPingEvent(java.net.InetAddress, net.kyori.adventure.text.Component, boolean, int)} ++ * @deprecated in favour of {@link #ServerListPingEvent(String, java.net.InetAddress, net.kyori.adventure.text.Component, boolean, int)} */ + @Deprecated // Paper - protected ServerListPingEvent(@NotNull final InetAddress address, @NotNull final String motd, boolean shouldSendChatPreviews, final int maxPlayers) { + protected ServerListPingEvent(@NotNull final String hostname, @NotNull final InetAddress address, @NotNull final String motd, boolean shouldSendChatPreviews, final int maxPlayers) { super(true); this.numPlayers = MAGIC_PLAYER_COUNT; + this.hostname = hostname; this.address = address; + this.motd = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(motd); // Paper + this.shouldSendChatPreviews = shouldSendChatPreviews; + this.maxPlayers = maxPlayers; + } + // Paper start ++ @Deprecated + public ServerListPingEvent(@NotNull final InetAddress address, @NotNull final net.kyori.adventure.text.Component motd, boolean shouldSendChatPreviews, final int numPlayers, final int maxPlayers) { ++ this("", address, motd, shouldSendChatPreviews, numPlayers, maxPlayers); ++ } ++ public ServerListPingEvent(@NotNull final String hostname, @NotNull final InetAddress address, @NotNull final net.kyori.adventure.text.Component motd, boolean shouldSendChatPreviews, final int numPlayers, final int maxPlayers) { + super(true); + Preconditions.checkArgument(numPlayers >= 0, "Cannot have negative number of players online (%s)", numPlayers); ++ this.hostname = hostname; + this.address = address; this.motd = motd; this.shouldSendChatPreviews = shouldSendChatPreviews; @@ -3490,10 +3495,26 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @param address the address of the pinger + * @param motd the message of the day + * @param maxPlayers the max number of players ++ * @deprecated in favour of {@link #ServerListPingEvent(String, java.net.InetAddress, net.kyori.adventure.text.Component, boolean, int)} + */ ++ @Deprecated + protected ServerListPingEvent(@NotNull final InetAddress address, @NotNull final net.kyori.adventure.text.Component motd, boolean shouldSendChatPreviews, final int maxPlayers) { -+ super(true); ++ this("", address, motd, shouldSendChatPreviews, maxPlayers); ++ } ++ ++ /** ++ * This constructor is intended for implementations that provide the ++ * {@link #iterator()} method, thus provided the {@link #getNumPlayers()} ++ * count. ++ * ++ * @param hostname The hostname that was used to connect to the server ++ * @param address the address of the pinger ++ * @param motd the message of the day ++ * @param maxPlayers the max number of players ++ */ ++ protected ServerListPingEvent(final @NotNull String hostname, final @NotNull InetAddress address, final @NotNull net.kyori.adventure.text.Component motd, final boolean shouldSendChatPreviews, final int maxPlayers) { + this.numPlayers = MAGIC_PLAYER_COUNT; ++ this.hostname = hostname; + this.address = address; + this.motd = motd; + this.shouldSendChatPreviews = shouldSendChatPreviews; @@ -3518,7 +3539,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper end /** - * Get the address the ping is coming from. + * Gets the hostname that the player used to connect to the server, or @@ -0,0 +0,0 @@ public class ServerListPingEvent extends ServerEvent implements Iterable * Get the message of the day message. * diff --git a/patches/server/Add-Velocity-IP-Forwarding-Support.patch b/patches/server/Add-Velocity-IP-Forwarding-Support.patch index ff73dcaeb7..975d55a587 100644 --- a/patches/server/Add-Velocity-IP-Forwarding-Support.patch +++ b/patches/server/Add-Velocity-IP-Forwarding-Support.patch @@ -98,8 +98,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- 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 TickablePacketListener, Se + @Nullable private ProfilePublicKey.Data profilePublicKeyData; - public String hostname = ""; // CraftBukkit - add field public boolean iKnowThisMayNotBeTheBestIdeaButPleaseDisableUsernameValidation = false; // Paper - username validation overriding + private int velocityLoginMessageId = -1; // Paper - Velocity support diff --git a/patches/server/Added-getHostname-to-AsyncPlayerPreLoginEvent.patch b/patches/server/Added-getHostname-to-AsyncPlayerPreLoginEvent.patch index 8af1fe4d60..c7b958bb43 100644 --- a/patches/server/Added-getHostname-to-AsyncPlayerPreLoginEvent.patch +++ b/patches/server/Added-getHostname-to-AsyncPlayerPreLoginEvent.patch @@ -13,7 +13,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 // Paper start com.destroystokyo.paper.profile.PlayerProfile profile = com.destroystokyo.paper.profile.CraftPlayerProfile.asBukkitMirror(ServerLoginPacketListenerImpl.this.gameProfile); - AsyncPlayerPreLoginEvent asyncEvent = new AsyncPlayerPreLoginEvent(playerName, address, rawAddress, uniqueId, profile); // Paper - add rawAddress -+ AsyncPlayerPreLoginEvent asyncEvent = new AsyncPlayerPreLoginEvent(playerName, address, rawAddress, uniqueId, profile, ServerLoginPacketListenerImpl.this.hostname); // Paper - add rawAddress & hostname ++ AsyncPlayerPreLoginEvent asyncEvent = new AsyncPlayerPreLoginEvent(playerName, address, rawAddress, uniqueId, profile, ServerLoginPacketListenerImpl.this.connection.hostname); // Paper - add rawAddress & hostname server.getPluginManager().callEvent(asyncEvent); profile = asyncEvent.getPlayerProfile(); profile.complete(true); // Paper - setPlayerProfileAPI diff --git a/patches/server/Adventure.patch b/patches/server/Adventure.patch index c67f01d886..ef581ebaed 100644 --- a/patches/server/Adventure.patch +++ b/patches/server/Adventure.patch @@ -2272,8 +2272,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 CraftIconCache icon = server.server.getServerIcon(); ServerListPingEvent() { -- super(((InetSocketAddress) ServerStatusPacketListenerImpl.this.connection.getRemoteAddress()).getAddress(), ServerStatusPacketListenerImpl.this.server.getMotd(), ServerStatusPacketListenerImpl.this.server.previewsChat(), ServerStatusPacketListenerImpl.this.server.getPlayerList().getMaxPlayers()); -+ super(((InetSocketAddress) ServerStatusPacketListenerImpl.this.connection.getRemoteAddress()).getAddress(), ServerStatusPacketListenerImpl.this.server.server.getMotd(), ServerStatusPacketListenerImpl.this.server.previewsChat(), ServerStatusPacketListenerImpl.this.server.getPlayerList().getMaxPlayers()); // Paper - Adventure +- super(connection.hostname, ((InetSocketAddress) ServerStatusPacketListenerImpl.this.connection.getRemoteAddress()).getAddress(), ServerStatusPacketListenerImpl.this.server.getMotd(), ServerStatusPacketListenerImpl.this.server.previewsChat(), ServerStatusPacketListenerImpl.this.server.getPlayerList().getMaxPlayers()); ++ super(connection.hostname, ((InetSocketAddress) ServerStatusPacketListenerImpl.this.connection.getRemoteAddress()).getAddress(), ServerStatusPacketListenerImpl.this.server.server.motd(), ServerStatusPacketListenerImpl.this.server.previewsChat(), ServerStatusPacketListenerImpl.this.server.getPlayerList().getMaxPlayers()); // Paper - Adventure } @Override diff --git a/patches/server/Fix-MC-158900.patch b/patches/server/Fix-MC-158900.patch index f6d0c55b48..9477150e33 100644 --- a/patches/server/Fix-MC-158900.patch +++ b/patches/server/Fix-MC-158900.patch @@ -12,7 +12,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +++ b/src/main/java/net/minecraft/server/players/PlayerList.java @@ -0,0 +0,0 @@ public abstract class PlayerList { Player player = entity.getBukkitEntity(); - PlayerLoginEvent event = new PlayerLoginEvent(player, hostname, ((java.net.InetSocketAddress) socketaddress).getAddress(), ((java.net.InetSocketAddress) loginlistener.connection.getRawAddress()).getAddress()); + PlayerLoginEvent event = new PlayerLoginEvent(player, loginlistener.connection.hostname, ((java.net.InetSocketAddress) socketaddress).getAddress(), ((java.net.InetSocketAddress) loginlistener.connection.getRawAddress()).getAddress()); - if (this.getBans().isBanned(gameprofile) && !this.getBans().get(gameprofile).hasExpired()) { - UserBanListEntry gameprofilebanentry = (UserBanListEntry) this.bans.get(gameprofile); diff --git a/patches/server/Fix-Spigot-growth-modifiers.patch b/patches/server/Fix-Spigot-growth-modifiers.patch index 3d09c0193c..706ff5e558 100644 --- a/patches/server/Fix-Spigot-growth-modifiers.patch +++ b/patches/server/Fix-Spigot-growth-modifiers.patch @@ -7,8 +7,6 @@ Fixes kelp modifier changing growth for other crops Also add growth modifiers for glow berries Also fix above-mentioned modifiers from having the reverse effect -Fixes an issue with the pumpkin speed modifier not being applied correctly - Co-authored-by: Jake Potrebic Co-authored-by: Noah van der Aa @@ -59,19 +57,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 protected BlockState getGrowIntoState(BlockState state, RandomSource random) { return (BlockState) state.cycle(GrowingPlantHeadBlock.AGE); } -diff --git a/src/main/java/net/minecraft/world/level/block/StemBlock.java b/src/main/java/net/minecraft/world/level/block/StemBlock.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/world/level/block/StemBlock.java -+++ b/src/main/java/net/minecraft/world/level/block/StemBlock.java -@@ -0,0 +0,0 @@ public class StemBlock extends BushBlock implements BonemealableBlock { - if (world.getRawBrightness(pos, 0) >= 9) { - float f = CropBlock.getGrowthSpeed(this, world, pos); - -- if (random.nextFloat() < (this == Blocks.PUMPKIN_STEM ? world.spigotConfig.pumpkinModifier : world.spigotConfig.melonModifier / (100.0f * (Math.floor((25.0F / f) + 1))))) { // Spigot - SPIGOT-7159: Better modifier resolution -+ if (random.nextFloat() < ((this == Blocks.PUMPKIN_STEM ? world.spigotConfig.pumpkinModifier : world.spigotConfig.melonModifier) / (100.0f * (Math.floor((25.0F / f) + 1))))) { // Spigot - SPIGOT-7159: Better modifier resolution // Paper - int i = (Integer) state.getValue(StemBlock.AGE); - - if (i < 7) { diff --git a/src/main/java/org/spigotmc/SpigotWorldConfig.java b/src/main/java/org/spigotmc/SpigotWorldConfig.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/spigotmc/SpigotWorldConfig.java diff --git a/patches/server/Rewrite-chunk-system.patch b/patches/server/Rewrite-chunk-system.patch index 312681cd12..187aa1dfce 100644 --- a/patches/server/Rewrite-chunk-system.patch +++ b/patches/server/Rewrite-chunk-system.patch @@ -12649,9 +12649,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/network/Connection.java +++ b/src/main/java/net/minecraft/network/Connection.java @@ -0,0 +0,0 @@ public class Connection extends SimpleChannelInboundHandler> { - private float averageSentPackets; private int tickCount; private boolean handlingFault; + public String hostname = ""; // CraftBukkit - add field + // Paper start - add pending task queue + private final Queue pendingTasks = new java.util.concurrent.ConcurrentLinkedQueue<>(); + public void execute(final Runnable run) { diff --git a/patches/server/Validate-usernames.patch b/patches/server/Validate-usernames.patch index 77dd7161d5..bd84bb2ee2 100644 --- a/patches/server/Validate-usernames.patch +++ b/patches/server/Validate-usernames.patch @@ -9,9 +9,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- 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 TickablePacketListener, Se + private ServerPlayer delayedAcceptPlayer; @Nullable private ProfilePublicKey.Data profilePublicKeyData; - public String hostname = ""; // CraftBukkit - add field + public boolean iKnowThisMayNotBeTheBestIdeaButPleaseDisableUsernameValidation = false; // Paper - username validation overriding public ServerLoginPacketListenerImpl(MinecraftServer server, Connection connection) { diff --git a/work/Bukkit b/work/Bukkit index 006049902d..9a4de09769 160000 --- a/work/Bukkit +++ b/work/Bukkit @@ -1 +1 @@ -Subproject commit 006049902d41e91d01844126dd968ca92fb99c8a +Subproject commit 9a4de0976907a81c4089cf5e8434155e77960145 diff --git a/work/CraftBukkit b/work/CraftBukkit index aaf484f6fd..f43634ae43 160000 --- a/work/CraftBukkit +++ b/work/CraftBukkit @@ -1 +1 @@ -Subproject commit aaf484f6fdb052306f7612bc0e721fa440d1b841 +Subproject commit f43634ae431d1ba7ee959627ee295417fe08b067 diff --git a/work/Spigot b/work/Spigot index 89741d3e9f..6198b5ae88 160000 --- a/work/Spigot +++ b/work/Spigot @@ -1 +1 @@ -Subproject commit 89741d3e9ff89cb2aa3b2e34a714a3a073b60d95 +Subproject commit 6198b5ae88da3f3650123abc22e6363a7543faa9