From 9b9a43e4726a9908ddd38f68a0019533f2a5e760 Mon Sep 17 00:00:00 2001 From: prplz Date: Tue, 3 Jan 2017 09:16:57 +1100 Subject: [PATCH] Better container checks (#564) --- .../0201-Better-container-checks.patch | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 Spigot-Server-Patches/0201-Better-container-checks.patch diff --git a/Spigot-Server-Patches/0201-Better-container-checks.patch b/Spigot-Server-Patches/0201-Better-container-checks.patch new file mode 100644 index 0000000000..606290696f --- /dev/null +++ b/Spigot-Server-Patches/0201-Better-container-checks.patch @@ -0,0 +1,41 @@ +From 45fbd09f4c64d743fcd64a514bc60e1fa4214be5 Mon Sep 17 00:00:00 2001 +From: Michael Himing +Date: Tue, 3 Jan 2017 08:54:00 +1100 +Subject: [PATCH] Better container checks + + +diff --git a/src/main/java/net/minecraft/server/Container.java b/src/main/java/net/minecraft/server/Container.java +index b826089..704da18 100644 +--- a/src/main/java/net/minecraft/server/Container.java ++++ b/src/main/java/net/minecraft/server/Container.java +@@ -461,6 +461,7 @@ public abstract class Container { + + } + ++ public boolean canPlayerUse(EntityHuman entityhuman) { return a(entityhuman); } // Paper - OBFHELPER + public abstract boolean a(EntityHuman entityhuman); + + protected boolean a(ItemStack itemstack, int i, int j, boolean flag) { +diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java +index e9a8428..a9857d3 100644 +--- a/src/main/java/net/minecraft/server/PlayerConnection.java ++++ b/src/main/java/net/minecraft/server/PlayerConnection.java +@@ -1674,6 +1674,7 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable { + PlayerConnectionUtils.ensureMainThread(packetplayinwindowclick, this, this.player.x()); + if (this.player.isFrozen()) return; // CraftBukkit + this.player.resetIdleTimer(); ++ if (!this.player.activeContainer.canPlayerUse(this.player)) return; // Paper - check if player is able to use this container + if (this.player.activeContainer.windowId == packetplayinwindowclick.a() && this.player.activeContainer.c(this.player)) { + boolean cancelled = this.player.isSpectator(); // CraftBukkit - see below if + if (false/*this.player.isSpectator()*/) { // CraftBukkit +@@ -2079,6 +2080,7 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable { + public void a(PacketPlayInTransaction packetplayintransaction) { + PlayerConnectionUtils.ensureMainThread(packetplayintransaction, this, this.player.x()); + if (this.player.isFrozen()) return; // CraftBukkit ++ if (!this.player.activeContainer.canPlayerUse(this.player)) return; // Paper - check if player is able to use this container + Short oshort = (Short) this.k.get(this.player.activeContainer.windowId); + + if (oshort != null && packetplayintransaction.b() == oshort.shortValue() && this.player.activeContainer.windowId == packetplayintransaction.a() && !this.player.activeContainer.c(this.player) && !this.player.isSpectator()) { +-- +2.9.2.windows.1 +