Fix package for PlayerInventorySlotChangeEvent (#8475)
Co-authored-by: Jakub Zacek <dawon@dawon.eu>
This commit is contained in:
parent
603df98897
commit
ec00f991a4
|
@ -4,13 +4,13 @@ Date: Sun, 24 Apr 2022 22:56:31 +0200
|
||||||
Subject: [PATCH] Add PlayerInventorySlotChangeEvent
|
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
|
new file mode 100644
|
||||||
index 0000000000000000000000000000000000000000..f106d2c6fb349c57ed00f1d7f96efacb1ade3959
|
index 0000000000000000000000000000000000000000..e86443b3b2e17f95be483acc06593212d9eefc03
|
||||||
--- /dev/null
|
--- /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 @@
|
@@ -0,0 +1,84 @@
|
||||||
+package com.destroystokyo.paper.event.player;
|
+package io.papermc.paper.event.player;
|
||||||
+
|
+
|
||||||
+import org.bukkit.entity.Player;
|
+import org.bukkit.entity.Player;
|
||||||
+import org.bukkit.event.Cancellable;
|
+import org.bukkit.event.Cancellable;
|
||||||
|
@ -70,7 +70,7 @@ index 0000000000000000000000000000000000000000..f106d2c6fb349c57ed00f1d7f96efacb
|
||||||
+ *
|
+ *
|
||||||
+ * @return Whether the slot change advancements will be triggered.
|
+ * @return Whether the slot change advancements will be triggered.
|
||||||
+ */
|
+ */
|
||||||
+ public boolean isTriggerAdvancements() {
|
+ public boolean shouldTriggerAdvancements() {
|
||||||
+ return triggerAdvancements;
|
+ return triggerAdvancements;
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
|
@ -79,7 +79,7 @@ index 0000000000000000000000000000000000000000..f106d2c6fb349c57ed00f1d7f96efacb
|
||||||
+ *
|
+ *
|
||||||
+ * @param triggerAdvancements Whether the slot change advancements will be triggered.
|
+ * @param triggerAdvancements Whether the slot change advancements will be triggered.
|
||||||
+ */
|
+ */
|
||||||
+ public void setTriggerAdvancements(boolean triggerAdvancements) {
|
+ public void setShouldTriggerAdvancements(boolean triggerAdvancements) {
|
||||||
+ this.triggerAdvancements = triggerAdvancements;
|
+ this.triggerAdvancements = triggerAdvancements;
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
|
|
|
@ -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
|
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
|
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||||
+++ b/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 {
|
@@ -318,6 +318,25 @@ public class ServerPlayer extends Player {
|
||||||
|
@ -18,13 +18,13 @@ index af7acb628b84539b1ee5ef1934f75f091c4cd91e..e5af7ef4ada68922a70f593ccec555ec
|
||||||
+ Slot slot = handler.getSlot(slotId);
|
+ Slot slot = handler.getSlot(slotId);
|
||||||
+ if (!(slot instanceof ResultSlot)) {
|
+ if (!(slot instanceof ResultSlot)) {
|
||||||
+ if (slot.container == ServerPlayer.this.getInventory()) {
|
+ 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);
|
+ CriteriaTriggers.INVENTORY_CHANGED.trigger(ServerPlayer.this, ServerPlayer.this.getInventory(), stack);
|
||||||
+ return;
|
+ 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();
|
+ event.callEvent();
|
||||||
+ if (event.isTriggerAdvancements()) {
|
+ if (event.shouldTriggerAdvancements()) {
|
||||||
+ CriteriaTriggers.INVENTORY_CHANGED.trigger(ServerPlayer.this, ServerPlayer.this.getInventory(), stack);
|
+ CriteriaTriggers.INVENTORY_CHANGED.trigger(ServerPlayer.this, ServerPlayer.this.getInventory(), stack);
|
||||||
+ }
|
+ }
|
||||||
+ }
|
+ }
|
||||||
|
|
Loading…
Reference in New Issue