2021-06-11 14:02:28 +02:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Aikar <aikar@aikar.co>
|
|
|
|
Date: Tue, 3 Jul 2018 21:52:52 -0400
|
|
|
|
Subject: [PATCH] InventoryCloseEvent Reason API
|
|
|
|
|
|
|
|
Allows you to determine why an inventory was closed, enabling plugin developers
|
|
|
|
to "confirm" things based on if it was player triggered close or not.
|
|
|
|
|
|
|
|
diff --git a/src/main/java/org/bukkit/entity/HumanEntity.java b/src/main/java/org/bukkit/entity/HumanEntity.java
|
2023-06-08 21:35:20 +02:00
|
|
|
index 9e012c3c0671e5d0e55c243fdb4e14057038c153..d44c5a3fda0b159dc541246cb2fca8427cb38243 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/org/bukkit/entity/HumanEntity.java
|
|
|
|
+++ b/src/main/java/org/bukkit/entity/HumanEntity.java
|
2023-02-07 16:55:53 +01:00
|
|
|
@@ -179,6 +179,15 @@ public interface HumanEntity extends LivingEntity, AnimalTamer, InventoryHolder
|
2021-06-11 14:02:28 +02:00
|
|
|
*/
|
|
|
|
public void closeInventory();
|
|
|
|
|
|
|
|
+ // Paper start
|
|
|
|
+ /**
|
|
|
|
+ * Force-closes the currently open inventory view for this player, if any.
|
|
|
|
+ *
|
|
|
|
+ * @param reason why the inventory is closing
|
|
|
|
+ */
|
|
|
|
+ public void closeInventory(@NotNull org.bukkit.event.inventory.InventoryCloseEvent.Reason reason);
|
|
|
|
+ // Paper end
|
|
|
|
+
|
|
|
|
/**
|
|
|
|
* Returns the ItemStack currently in your hand, can be empty.
|
|
|
|
*
|
|
|
|
diff --git a/src/main/java/org/bukkit/event/inventory/InventoryCloseEvent.java b/src/main/java/org/bukkit/event/inventory/InventoryCloseEvent.java
|
2023-09-21 21:54:46 +02:00
|
|
|
index c0cc82d98348e8aae3cb56bafb2fcb590b03094f..4db0a07db156c61867644f50c185e63b695e2462 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/org/bukkit/event/inventory/InventoryCloseEvent.java
|
|
|
|
+++ b/src/main/java/org/bukkit/event/inventory/InventoryCloseEvent.java
|
2023-08-05 21:58:38 +02:00
|
|
|
@@ -30,9 +30,60 @@ import org.jetbrains.annotations.NotNull;
|
2021-06-11 14:02:28 +02:00
|
|
|
*/
|
|
|
|
public class InventoryCloseEvent extends InventoryEvent {
|
|
|
|
private static final HandlerList handlers = new HandlerList();
|
|
|
|
+ // Paper start
|
|
|
|
+ private final Reason reason;
|
|
|
|
+ @NotNull
|
|
|
|
+ public Reason getReason() {
|
|
|
|
+ return reason;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public enum Reason {
|
|
|
|
+ /**
|
|
|
|
+ * Unknown reason
|
|
|
|
+ */
|
|
|
|
+ UNKNOWN,
|
|
|
|
+ /**
|
|
|
|
+ * Player is teleporting
|
|
|
|
+ */
|
|
|
|
+ TELEPORT,
|
|
|
|
+ /**
|
|
|
|
+ * Player is no longer permitted to use this inventory
|
|
|
|
+ */
|
|
|
|
+ CANT_USE,
|
|
|
|
+ /**
|
|
|
|
+ * The chunk the inventory was in was unloaded
|
|
|
|
+ */
|
|
|
|
+ UNLOADED,
|
|
|
|
+ /**
|
|
|
|
+ * Opening new inventory instead
|
|
|
|
+ */
|
|
|
|
+ OPEN_NEW,
|
|
|
|
+ /**
|
|
|
|
+ * Closed
|
|
|
|
+ */
|
|
|
|
+ PLAYER,
|
|
|
|
+ /**
|
|
|
|
+ * Closed due to disconnect
|
|
|
|
+ */
|
|
|
|
+ DISCONNECT,
|
|
|
|
+ /**
|
|
|
|
+ * The player died
|
|
|
|
+ */
|
|
|
|
+ DEATH,
|
|
|
|
+ /**
|
|
|
|
+ * Closed by Bukkit API
|
|
|
|
+ */
|
|
|
|
+ PLUGIN,
|
|
|
|
+ }
|
|
|
|
|
|
|
|
public InventoryCloseEvent(@NotNull InventoryView transaction) {
|
|
|
|
+ this(transaction, Reason.UNKNOWN);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public InventoryCloseEvent(@NotNull InventoryView transaction, @NotNull Reason reason) {
|
|
|
|
super(transaction);
|
|
|
|
+ this.reason = reason;
|
|
|
|
+ // Paper end
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|