From ee0482a6140106dee3ee2b9d0fb4cd08866f5598 Mon Sep 17 00:00:00 2001
From: Gameoholic <viner.atmic@gmail.com>
Date: Sat, 5 Aug 2023 22:58:38 +0300
Subject: [PATCH] [ci skip] Fix inventorycloseevent javadocs (#9533)

* Add InventoryCloseEvent safety doc comment, similar to InventoryClickEvent

* Fix inventorycloseevent javadocs

* Fix InventoryCloseEvent and InventoryClickEvent javadocs

* remove extra +

---------

Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com>
---
 patches/api/Fix-upstream-javadocs.patch | 47 ++++++++++++++++++++++++-
 1 file changed, 46 insertions(+), 1 deletion(-)

diff --git a/patches/api/Fix-upstream-javadocs.patch b/patches/api/Fix-upstream-javadocs.patch
index a84bdc1b47..ca40c123e5 100644
--- a/patches/api/Fix-upstream-javadocs.patch
+++ b/patches/api/Fix-upstream-javadocs.patch
@@ -3,7 +3,6 @@ From: Zach Brown <1254957+zachbr@users.noreply.github.com>
 Date: Sat, 10 Jun 2017 16:59:40 -0500
 Subject: [PATCH] Fix upstream javadocs
 
-Upstream still refuses to use Java 8 with the API so they are likely unaware these are even issues.
 
 diff --git a/src/main/java/org/bukkit/BanList.java b/src/main/java/org/bukkit/BanList.java
 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
@@ -683,6 +682,20 @@ diff --git a/src/main/java/org/bukkit/event/inventory/InventoryClickEvent.java b
 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
 --- a/src/main/java/org/bukkit/event/inventory/InventoryClickEvent.java
 +++ b/src/main/java/org/bukkit/event/inventory/InventoryClickEvent.java
+@@ -0,0 +0,0 @@ import org.jetbrains.annotations.Nullable;
+  * Because InventoryClickEvent occurs within a modification of the Inventory,
+  * not all Inventory related methods are safe to use.
+  * <p>
+- * The following should never be invoked by an EventHandler for
+- * InventoryClickEvent using the HumanEntity or InventoryView associated with
+- * this event:
++ * Methods that change the view a player is looking at should never be invoked
++ * by an EventHandler for InventoryClickEvent using the HumanEntity or
++ * InventoryView associated with this event.
++ * Examples of these include:
+  * <ul>
+  * <li>{@link HumanEntity#closeInventory()}
+  * <li>{@link HumanEntity#openInventory(Inventory)}
 @@ -0,0 +0,0 @@ public class InventoryClickEvent extends InventoryInteractEvent {
      /**
       * Gets the ItemStack currently in the clicked slot.
@@ -692,6 +705,38 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
       */
      @Nullable
      public ItemStack getCurrentItem() {
+diff --git a/src/main/java/org/bukkit/event/inventory/InventoryCloseEvent.java b/src/main/java/org/bukkit/event/inventory/InventoryCloseEvent.java
+index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
+--- a/src/main/java/org/bukkit/event/inventory/InventoryCloseEvent.java
++++ b/src/main/java/org/bukkit/event/inventory/InventoryCloseEvent.java
+@@ -0,0 +0,0 @@ import org.bukkit.inventory.InventoryView;
+ import org.jetbrains.annotations.NotNull;
+ 
+ /**
+- * Represents a player related inventory event
++ * This event is called when a player closes an inventory.
++ * <p>
++ * Because InventoryCloseEvent occurs within a modification of the Inventory,
++ * not all Inventory related methods are safe to use.
++ * <p>
++ * Methods that change the view a player is looking at should never be invoked
++ * by an EventHandler for InventoryCloseEvent using the HumanEntity or
++ * InventoryView associated with this event.
++ * Examples of these include:
++ * <ul>
++ * <li>{@link HumanEntity#closeInventory()}
++ * <li>{@link HumanEntity#openInventory(org.bukkit.inventory.Inventory)}
++ * <li>{@link HumanEntity#openWorkbench(org.bukkit.Location, boolean)}
++ * <li>{@link HumanEntity#openEnchanting(org.bukkit.Location, boolean)}
++ * <li>{@link InventoryView#close()}
++ * </ul>
++ * To invoke one of these methods, schedule a task using
++ * {@link org.bukkit.scheduler.BukkitScheduler#runTask(org.bukkit.plugin.Plugin, Runnable)}, which will run the task
++ * on the next tick. Also be aware that this is not an exhaustive list, and
++ * other methods could potentially create issues as well.
+  */
+ public class InventoryCloseEvent extends InventoryEvent {
+     private static final HandlerList handlers = new HandlerList();
 diff --git a/src/main/java/org/bukkit/event/inventory/InventoryOpenEvent.java b/src/main/java/org/bukkit/event/inventory/InventoryOpenEvent.java
 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
 --- a/src/main/java/org/bukkit/event/inventory/InventoryOpenEvent.java