aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0756-Add-PlayerInventorySlotChangeEvent.patch
diff options
context:
space:
mode:
authorNassim Jahnke <[email protected]>2024-06-16 12:56:00 +0200
committerNassim Jahnke <[email protected]>2024-06-16 12:56:00 +0200
commitdc684c60d16f66ea84467ec8e253f2a36a17a7c8 (patch)
treee516f1bd4bfbdb37a5aeee42384aade111eca3e1 /patches/server/0756-Add-PlayerInventorySlotChangeEvent.patch
parent752f957e12e4ceb8b7d2043a4a7dbce786b7b98f (diff)
downloadPaper-dc684c60d16f66ea84467ec8e253f2a36a17a7c8.tar.gz
Paper-dc684c60d16f66ea84467ec8e253f2a36a17a7c8.zip
Remove bad server.scheduleOnMain disconnect calls from old patches
The new behavior of disconnect to block the current thread until the disconnect succeeded is better than throwing it off to happen at some point
Diffstat (limited to 'patches/server/0756-Add-PlayerInventorySlotChangeEvent.patch')
-rw-r--r--patches/server/0756-Add-PlayerInventorySlotChangeEvent.patch65
1 files changed, 65 insertions, 0 deletions
diff --git a/patches/server/0756-Add-PlayerInventorySlotChangeEvent.patch b/patches/server/0756-Add-PlayerInventorySlotChangeEvent.patch
new file mode 100644
index 0000000000..ddeaac02da
--- /dev/null
+++ b/patches/server/0756-Add-PlayerInventorySlotChangeEvent.patch
@@ -0,0 +1,65 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Jakub Zacek <[email protected]>
+Date: Sun, 24 Apr 2022 22:56:59 +0200
+Subject: [PATCH] Add PlayerInventorySlotChangeEvent
+
+
+diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
+index cb244eccf64c285d56e824131171da5ad1eec0c8..118a6b58947417d107f8b0b4c0622d69332eee95 100644
+--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
++++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
+@@ -352,6 +352,25 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player {
+
+ }
+ }
++ // Paper start - Add PlayerInventorySlotChangeEvent
++ @Override
++ public void slotChanged(AbstractContainerMenu handler, int slotId, ItemStack oldStack, ItemStack stack) {
++ Slot slot = handler.getSlot(slotId);
++ if (!(slot instanceof ResultSlot)) {
++ if (slot.container == ServerPlayer.this.getInventory()) {
++ if (io.papermc.paper.event.player.PlayerInventorySlotChangeEvent.getHandlerList().getRegisteredListeners().length == 0) {
++ CriteriaTriggers.INVENTORY_CHANGED.trigger(ServerPlayer.this, ServerPlayer.this.getInventory(), stack);
++ return;
++ }
++ io.papermc.paper.event.player.PlayerInventorySlotChangeEvent event = new io.papermc.paper.event.player.PlayerInventorySlotChangeEvent(ServerPlayer.this.getBukkitEntity(), slotId, CraftItemStack.asBukkitCopy(oldStack), CraftItemStack.asBukkitCopy(stack));
++ event.callEvent();
++ if (event.shouldTriggerAdvancements()) {
++ CriteriaTriggers.INVENTORY_CHANGED.trigger(ServerPlayer.this, ServerPlayer.this.getInventory(), stack);
++ }
++ }
++ }
++ }
++ // Paper end - Add PlayerInventorySlotChangeEvent
+
+ @Override
+ public void dataChanged(AbstractContainerMenu handler, int property, int value) {}
+diff --git a/src/main/java/net/minecraft/world/inventory/AbstractContainerMenu.java b/src/main/java/net/minecraft/world/inventory/AbstractContainerMenu.java
+index 00031a013d8e1e9f40bc1ef9491da6df3b061d5f..ea84d4549815ddfd2829cb2fd3885ddd1114bfa8 100644
+--- a/src/main/java/net/minecraft/world/inventory/AbstractContainerMenu.java
++++ b/src/main/java/net/minecraft/world/inventory/AbstractContainerMenu.java
+@@ -302,7 +302,7 @@ public abstract class AbstractContainerMenu {
+ while (iterator.hasNext()) {
+ ContainerListener icrafting = (ContainerListener) iterator.next();
+
+- icrafting.slotChanged(this, slot, itemstack2);
++ icrafting.slotChanged(this, slot, itemstack1, itemstack2); // Paper - Add PlayerInventorySlotChangeEvent
+ }
+ }
+
+diff --git a/src/main/java/net/minecraft/world/inventory/ContainerListener.java b/src/main/java/net/minecraft/world/inventory/ContainerListener.java
+index 0e19cc55646625bf32a354d3df2dc2d6bcff96f4..eba024c9aadef8902aacccea1584ffbee6c04e44 100644
+--- a/src/main/java/net/minecraft/world/inventory/ContainerListener.java
++++ b/src/main/java/net/minecraft/world/inventory/ContainerListener.java
+@@ -5,5 +5,11 @@ import net.minecraft.world.item.ItemStack;
+ public interface ContainerListener {
+ void slotChanged(AbstractContainerMenu handler, int slotId, ItemStack stack);
+
++ // Paper start - Add PlayerInventorySlotChangeEvent
++ default void slotChanged(AbstractContainerMenu handler, int slotId, ItemStack oldStack, ItemStack stack) {
++ slotChanged(handler, slotId, stack);
++ }
++ // Paper end - Add PlayerInventorySlotChangeEvent
++
+ void dataChanged(AbstractContainerMenu handler, int property, int value);
+ }