From f55b057ffb99b8c56be9eec676387633a69982e6 Mon Sep 17 00:00:00 2001 From: Jedediah Smith Date: Sat, 4 Apr 2015 23:17:52 -0400 Subject: [PATCH] Complete resource pack API --- .../ServerCommonPacketListenerImpl.java.patch | 14 +++++++++----- .../org/bukkit/craftbukkit/entity/CraftPlayer.java | 8 ++++++++ 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/paper-server/patches/sources/net/minecraft/server/network/ServerCommonPacketListenerImpl.java.patch b/paper-server/patches/sources/net/minecraft/server/network/ServerCommonPacketListenerImpl.java.patch index 92119eadac..0ba38bc368 100644 --- a/paper-server/patches/sources/net/minecraft/server/network/ServerCommonPacketListenerImpl.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/network/ServerCommonPacketListenerImpl.java.patch @@ -174,7 +174,7 @@ @Override public void handleResourcePackResponse(ServerboundResourcePackPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, (BlockableEventLoop) this.server); -@@ -104,11 +202,30 @@ +@@ -104,11 +202,34 @@ ServerCommonPacketListenerImpl.LOGGER.info("Disconnecting {} due to resource pack {} rejection", this.playerProfile().getName(), packet.id()); this.disconnect((Component) Component.translatable("multiplayer.requiredTexturePrompt.disconnect")); } @@ -190,7 +190,11 @@ + callback.packEventReceived(packet.id(), net.kyori.adventure.resource.ResourcePackStatus.valueOf(packet.action().name()), this.getCraftPlayer()); + } + // Paper end -+ this.cserver.getPluginManager().callEvent(new PlayerResourcePackStatusEvent(this.getCraftPlayer(), packet.id(), PlayerResourcePackStatusEvent.Status.values()[packet.action().ordinal()])); // CraftBukkit ++ // Paper start - store last pack status ++ PlayerResourcePackStatusEvent.Status packStatus = PlayerResourcePackStatusEvent.Status.values()[packet.action().ordinal()]; ++ player.getBukkitEntity().resourcePackStatus = packStatus; ++ this.cserver.getPluginManager().callEvent(new PlayerResourcePackStatusEvent(this.getCraftPlayer(), packet.id(), packStatus)); // CraftBukkit ++ // Paper end - store last pack status } @@ -205,7 +209,7 @@ this.disconnect(ServerCommonPacketListenerImpl.DISCONNECT_UNEXPECTED_QUERY); } -@@ -116,7 +233,7 @@ +@@ -116,7 +237,7 @@ Profiler.get().push("keepAlive"); long i = Util.getMillis(); @@ -214,7 +218,7 @@ if (this.keepAlivePending) { this.disconnect(ServerCommonPacketListenerImpl.TIMEOUT_DISCONNECTION_MESSAGE); } else if (this.checkIfClosed(i)) { -@@ -156,6 +273,14 @@ +@@ -156,6 +277,14 @@ } public void send(Packet packet, @Nullable PacketSendListener callbacks) { @@ -229,7 +233,7 @@ if (packet.isTerminal()) { this.close(); } -@@ -175,20 +300,72 @@ +@@ -175,20 +304,72 @@ } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java index 8fd5aaa16b..dd3072717a 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -213,6 +213,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { private double healthScale = 20; private CraftWorldBorder clientWorldBorder = null; private BorderChangeListener clientWorldBorderListener = this.createWorldBorderListener(); + public org.bukkit.event.player.PlayerResourcePackStatusEvent.Status resourcePackStatus; // Paper - more resource pack API public CraftPlayer(CraftServer server, ServerPlayer entity) { super(server, entity); @@ -2121,6 +2122,13 @@ public class CraftPlayer extends CraftHumanEntity implements Player { } // Paper end - adventure + // Paper start - more resource pack API + @Override + public org.bukkit.event.player.PlayerResourcePackStatusEvent.Status getResourcePackStatus() { + return this.resourcePackStatus; + } + // Paper end - more resource pack API + @Override public void removeResourcePack(UUID id) { Preconditions.checkArgument(id != null, "Resource pack id cannot be null");