Fix unregistering the wrong GUI on InventoryCloseEvent (#69)

* fix unregistering the wrong gui

* removed unused import

* fix indentation

(cherry picked from commit 35c4c77869)
This commit is contained in:
Leander Riefel
2024-08-08 16:01:13 +02:00
committed by Starmism
parent 4e7c6af1ed
commit f8ff18c19b
2 changed files with 3 additions and 2 deletions

View File

@@ -3,7 +3,6 @@ package net.axay.kspigot.chat;
import net.kyori.adventure.text.format.TextColor;
import net.kyori.adventure.text.format.TextDecoration;
import java.lang.reflect.Field;
import java.util.*;
import java.util.stream.Collectors;

View File

@@ -99,7 +99,9 @@ class GUIIndividual<T : ForInventory>(
init {
if (resetOnClose || data.onClose != null) {
listen<InventoryCloseEvent> {
if (data.onClose != null && playerInstances[it.player]?.bukkitInventory == it.inventory) {
if (playerInstances[it.player]?.bukkitInventory != it.inventory) return@listen
if (data.onClose != null) {
data.onClose.invoke(GUICloseEvent(it, playerInstances[it.player]!!, it.player as Player))
}