From d8d59e0cdeda3f7e9da337b6d489f306fc5e76c9 Mon Sep 17 00:00:00 2001 From: Jake Potrebic Date: Fri, 17 May 2024 14:22:45 -0700 Subject: [PATCH] Fix NPE sending resource pack without prompt Fixes KyoriPowered/adventure#1075 --- patches/server/0010-Adventure.patch | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/patches/server/0010-Adventure.patch b/patches/server/0010-Adventure.patch index f83b3b6f40..8d953d0033 100644 --- a/patches/server/0010-Adventure.patch +++ b/patches/server/0010-Adventure.patch @@ -4098,7 +4098,7 @@ index 55945b83a5426b352bad9507cc9e94afb1278032..9ea1537408ff2d790747b6e5a681d917 public boolean isOp() { return true; diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -index 654d4994bb2e65c5ca6b7190c15d2113eede9e5b..1c1f1db8cb8beff850103d998561d333823fe611 100644 +index 654d4994bb2e65c5ca6b7190c15d2113eede9e5b..4d1e8a9211462444543b4a16cefe369245e71b2f 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -386,14 +386,40 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @@ -4317,7 +4317,7 @@ index 654d4994bb2e65c5ca6b7190c15d2113eede9e5b..1c1f1db8cb8beff850103d998561d333 + final Component prompt = io.papermc.paper.adventure.PaperAdventure.asVanilla(request.prompt()); + for (final java.util.Iterator iter = request.packs().iterator(); iter.hasNext();) { + final net.kyori.adventure.resource.ResourcePackInfo pack = iter.next(); -+ packs.add(new ClientboundResourcePackPushPacket(pack.id(), pack.uri().toASCIIString(), pack.hash(), request.required(), iter.hasNext() ? Optional.empty() : Optional.of(prompt))); ++ packs.add(new ClientboundResourcePackPushPacket(pack.id(), pack.uri().toASCIIString(), pack.hash(), request.required(), iter.hasNext() ? Optional.empty() : Optional.ofNullable(prompt))); + if (request.callback() != net.kyori.adventure.resource.ResourcePackCallback.noOp()) { + this.getHandle().connection.packCallbacks.put(pack.id(), request.callback()); // just override if there is a previously existing callback + } @@ -5552,7 +5552,7 @@ index 64191fb2f238c6dacf894d88a703ced6e75a6054..cb6cc3896e862291a058d21fa9704dd1 boolean hadFormat = false; diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java -index 8a13d8ae4325854acb3be7083d022c08ba094df1..311b4472f955cba658afa763b2f0b31023b53236 100644 +index 951f76eff07e53af20105b29a4e3c81b78ef8b65..cac2bfc711daba11a640e4e776b10c86041b0670 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java +++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java @@ -80,6 +80,43 @@ public final class CraftMagicNumbers implements UnsafeValues {