2018-10-02 12:01:56 +02:00
|
|
|
From c0fe423e87026d3311fa8cfb5cd1e07e97c420b3 Mon Sep 17 00:00:00 2001
|
2018-07-04 03:57:33 +02:00
|
|
|
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
|
2018-10-02 12:01:56 +02:00
|
|
|
index 3590149a8..972c8f970 100644
|
2018-07-04 03:57:33 +02:00
|
|
|
--- a/src/main/java/org/bukkit/entity/HumanEntity.java
|
|
|
|
+++ b/src/main/java/org/bukkit/entity/HumanEntity.java
|
2018-10-02 12:01:56 +02:00
|
|
|
@@ -139,6 +139,15 @@ public interface HumanEntity extends LivingEntity, AnimalTamer, Permissible, Inv
|
2018-07-04 03:57:33 +02:00
|
|
|
*/
|
|
|
|
public void closeInventory();
|
|
|
|
|
|
|
|
+ // Paper start
|
|
|
|
+ /**
|
|
|
|
+ * Force-closes the currently open inventory view for this player, if any.
|
2018-08-16 13:20:58 +02:00
|
|
|
+ *
|
|
|
|
+ * @param reason why the inventory is closing
|
2018-07-04 03:57:33 +02:00
|
|
|
+ */
|
|
|
|
+ public void closeInventory(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
|
2018-08-16 13:20:58 +02:00
|
|
|
index 19889b278..e6e45b936 100644
|
2018-07-04 03:57:33 +02:00
|
|
|
--- a/src/main/java/org/bukkit/event/inventory/InventoryCloseEvent.java
|
|
|
|
+++ b/src/main/java/org/bukkit/event/inventory/InventoryCloseEvent.java
|
|
|
|
@@ -11,8 +11,58 @@ import org.bukkit.inventory.InventoryView;
|
|
|
|
public class InventoryCloseEvent extends InventoryEvent {
|
|
|
|
private static final HandlerList handlers = new HandlerList();
|
|
|
|
|
|
|
|
+ // Paper start
|
|
|
|
+ private final Reason reason;
|
|
|
|
+ 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(InventoryView transaction) {
|
|
|
|
+ this(transaction, Reason.UNKNOWN);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public InventoryCloseEvent(InventoryView transaction, Reason reason) {
|
|
|
|
super(transaction);
|
|
|
|
+ this.reason = reason;
|
|
|
|
+ // Paper end
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
--
|
2018-10-02 12:01:56 +02:00
|
|
|
2.19.0
|
2018-07-04 03:57:33 +02:00
|
|
|
|