Fix package for PlayerInventorySlotChangeEvent (#8475)

Co-authored-by: Jakub Zacek <dawon@dawon.eu>
This commit is contained in:
Jakub Žáček 2022-10-16 09:49:47 +02:00 committed by GitHub
parent 603df98897
commit ec00f991a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 10 deletions

View File

@ -4,13 +4,13 @@ Date: Sun, 24 Apr 2022 22:56:31 +0200
Subject: [PATCH] Add PlayerInventorySlotChangeEvent
diff --git a/src/main/java/com/destroystokyo/paper/event/player/PlayerInventorySlotChangeEvent.java b/src/main/java/com/destroystokyo/paper/event/player/PlayerInventorySlotChangeEvent.java
diff --git a/src/main/java/io/papermc/paper/event/player/PlayerInventorySlotChangeEvent.java b/src/main/java/io/papermc/paper/event/player/PlayerInventorySlotChangeEvent.java
new file mode 100644
index 0000000000000000000000000000000000000000..f106d2c6fb349c57ed00f1d7f96efacb1ade3959
index 0000000000000000000000000000000000000000..e86443b3b2e17f95be483acc06593212d9eefc03
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/player/PlayerInventorySlotChangeEvent.java
+++ b/src/main/java/io/papermc/paper/event/player/PlayerInventorySlotChangeEvent.java
@@ -0,0 +1,84 @@
+package com.destroystokyo.paper.event.player;
+package io.papermc.paper.event.player;
+
+import org.bukkit.entity.Player;
+import org.bukkit.event.Cancellable;
@ -70,7 +70,7 @@ index 0000000000000000000000000000000000000000..f106d2c6fb349c57ed00f1d7f96efacb
+ *
+ * @return Whether the slot change advancements will be triggered.
+ */
+ public boolean isTriggerAdvancements() {
+ public boolean shouldTriggerAdvancements() {
+ return triggerAdvancements;
+ }
+
@ -79,7 +79,7 @@ index 0000000000000000000000000000000000000000..f106d2c6fb349c57ed00f1d7f96efacb
+ *
+ * @param triggerAdvancements Whether the slot change advancements will be triggered.
+ */
+ public void setTriggerAdvancements(boolean triggerAdvancements) {
+ public void setShouldTriggerAdvancements(boolean triggerAdvancements) {
+ this.triggerAdvancements = triggerAdvancements;
+ }
+

View File

@ -5,7 +5,7 @@ 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 af7acb628b84539b1ee5ef1934f75f091c4cd91e..e5af7ef4ada68922a70f593ccec555ecb50627a9 100644
index af7acb628b84539b1ee5ef1934f75f091c4cd91e..961d25bbf868438bf5e5257bad745c8208a01171 100644
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
@@ -318,6 +318,25 @@ public class ServerPlayer extends Player {
@ -18,13 +18,13 @@ index af7acb628b84539b1ee5ef1934f75f091c4cd91e..e5af7ef4ada68922a70f593ccec555ec
+ Slot slot = handler.getSlot(slotId);
+ if (!(slot instanceof ResultSlot)) {
+ if (slot.container == ServerPlayer.this.getInventory()) {
+ if (com.destroystokyo.paper.event.player.PlayerInventorySlotChangeEvent.getHandlerList().getRegisteredListeners().length == 0) {
+ if (io.papermc.paper.event.player.PlayerInventorySlotChangeEvent.getHandlerList().getRegisteredListeners().length == 0) {
+ CriteriaTriggers.INVENTORY_CHANGED.trigger(ServerPlayer.this, ServerPlayer.this.getInventory(), stack);
+ return;
+ }
+ com.destroystokyo.paper.event.player.PlayerInventorySlotChangeEvent event = new com.destroystokyo.paper.event.player.PlayerInventorySlotChangeEvent(ServerPlayer.this.getBukkitEntity(), slotId, CraftItemStack.asBukkitCopy(oldStack), CraftItemStack.asBukkitCopy(stack));
+ 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.isTriggerAdvancements()) {
+ if (event.shouldTriggerAdvancements()) {
+ CriteriaTriggers.INVENTORY_CHANGED.trigger(ServerPlayer.this, ServerPlayer.this.getInventory(), stack);
+ }
+ }