Paper/Spigot-Server-Patches/0443-Prevent-opening-inventories-when-frozen.patch
Jake Potrebic 899bc53b79
Updated Upstream (Bukkit/CraftBukkit) (#4779)
Upstream has released updates that appears 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:
f47abd88 SPIGOT-6242: Fix some file line endings
de96535b SPIGOT-6234: enum classes don't serialize properly when implementing ConfigurationSerializable

CraftBukkit Changes:
4475707d SPIGOT-6244: /spawnpoint ignores angle
8b3b096d SPIGOT-6242: Fix some file line endings
4b33c749 SPIGOT-6186: Canceling a CreatureSpawnEvent​ results in a "Unable to summon entity due to duplicate UUIDs" error
2b3ca726 SPIGOT-6236: Vehicle passenger portal cooldown does not change
2020-11-17 22:45:18 -05:00

60 lines
3.8 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Shane Freeder <theboyetronic@gmail.com>
Date: Mon, 13 Apr 2020 07:31:44 +0100
Subject: [PATCH] Prevent opening inventories when frozen
diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java
index dde0e9f1911d34791c7d7396f82cff5f82eec253..5a7a065fdf49c0cfa49afb6c78da7cca81eff708 100644
--- a/src/main/java/net/minecraft/server/EntityPlayer.java
+++ b/src/main/java/net/minecraft/server/EntityPlayer.java
@@ -427,7 +427,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
containerUpdateDelay = world.paperConfig.containerUpdateTickRate;
}
// Paper end
- if (!this.world.isClientSide && !this.activeContainer.canUse(this)) {
+ if (!this.world.isClientSide && this.activeContainer != this.defaultContainer && (isFrozen() || !this.activeContainer.canUse(this))) { // Paper - auto close while frozen
this.closeInventory(org.bukkit.event.inventory.InventoryCloseEvent.Reason.CANT_USE); // Paper
this.activeContainer = this.defaultContainer;
}
@@ -1255,7 +1255,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
} else {
// CraftBukkit start
this.activeContainer = container;
- this.playerConnection.sendPacket(new PacketPlayOutOpenWindow(container.windowId, container.getType(), container.getTitle()));
+ if (!isFrozen()) this.playerConnection.sendPacket(new PacketPlayOutOpenWindow(container.windowId, container.getType(), container.getTitle())); // Paper
// CraftBukkit end
container.addSlotListener(this);
return OptionalInt.of(this.containerCounter);
@@ -2051,7 +2051,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
}
@Override
- protected boolean isFrozen() {
+ public boolean isFrozen() { // Paper - protected > public
return super.isFrozen() || (this.playerConnection != null && this.playerConnection.isDisconnected()); // Paper
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java
index ebcd2d043b3e6cf90b62eda1ea7a2d8c01f1c7a8..c3a51843a58138270bd24e51b5bead2c43e2cbe3 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java
@@ -319,7 +319,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
String title = container.getBukkitView().getTitle();
- player.playerConnection.sendPacket(new PacketPlayOutOpenWindow(container.windowId, windowType, CraftChatMessage.fromString(title)[0]));
+ if (!player.isFrozen()) player.playerConnection.sendPacket(new PacketPlayOutOpenWindow(container.windowId, windowType, CraftChatMessage.fromString(title)[0])); // Paper
getHandle().activeContainer = container;
getHandle().activeContainer.addSlotListener(player);
}
@@ -389,7 +389,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
// Now open the window
Containers<?> windowType = CraftContainer.getNotchInventoryType(inventory.getTopInventory());
String title = inventory.getTitle();
- player.playerConnection.sendPacket(new PacketPlayOutOpenWindow(container.windowId, windowType, CraftChatMessage.fromString(title)[0]));
+ if (!player.isFrozen()) player.playerConnection.sendPacket(new PacketPlayOutOpenWindow(container.windowId, windowType, CraftChatMessage.fromString(title)[0])); // Paper
player.activeContainer = container;
player.activeContainer.addSlotListener(player);
}