From 0bbb6660d3bbc576be351919ed2b5bf6d0ce4d85 Mon Sep 17 00:00:00 2001 From: acrylic-style Date: Mon, 15 Jul 2024 20:42:34 +0900 Subject: [PATCH] feat: add UpdateInventoryOnCloseListener --- build.gradle.kts | 2 +- .../com/github/mori01231/lifecore/LifeCore.kt | 1 + .../listener/UpdateInventoryOnCloseListener.kt | 17 +++++++++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/github/mori01231/lifecore/listener/UpdateInventoryOnCloseListener.kt diff --git a/build.gradle.kts b/build.gradle.kts index 8cd5354..0dcd4a9 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -9,7 +9,7 @@ plugins { } group = "net.azisaba" -version = "6.11.1" +version = "6.11.2" java { toolchain.languageVersion.set(JavaLanguageVersion.of(8)) diff --git a/src/main/java/com/github/mori01231/lifecore/LifeCore.kt b/src/main/java/com/github/mori01231/lifecore/LifeCore.kt index c8e34bf..73795c1 100644 --- a/src/main/java/com/github/mori01231/lifecore/LifeCore.kt +++ b/src/main/java/com/github/mori01231/lifecore/LifeCore.kt @@ -274,6 +274,7 @@ class LifeCore : JavaPlugin() { pm.registerEvents(OverrideTabCompleteListener(), this) pm.registerEvents(KotlinLoveItemListener(this), this) pm.registerEvents(CommandListScreen.EventListener(), this) + pm.registerEvents(UpdateInventoryOnCloseListener(this), this) // Items pm.registerEvents(OreOnlyItemListener(), this) diff --git a/src/main/java/com/github/mori01231/lifecore/listener/UpdateInventoryOnCloseListener.kt b/src/main/java/com/github/mori01231/lifecore/listener/UpdateInventoryOnCloseListener.kt new file mode 100644 index 0000000..2b5130a --- /dev/null +++ b/src/main/java/com/github/mori01231/lifecore/listener/UpdateInventoryOnCloseListener.kt @@ -0,0 +1,17 @@ +package com.github.mori01231.lifecore.listener + +import com.github.mori01231.lifecore.LifeCore +import org.bukkit.Bukkit +import org.bukkit.entity.Player +import org.bukkit.event.EventHandler +import org.bukkit.event.Listener +import org.bukkit.event.inventory.InventoryCloseEvent + +class UpdateInventoryOnCloseListener(private val plugin: LifeCore) : Listener { + @EventHandler + fun onInventoryClose(e: InventoryCloseEvent) { + Bukkit.getScheduler().runTask(plugin, Runnable { + (e.player as Player).updateInventory() + }) + } +} \ No newline at end of file