From bfe9ead70a9159ab00ef5d3dec09cbee19d8bcbe Mon Sep 17 00:00:00 2001 From: acrylic-style Date: Mon, 11 Sep 2023 18:25:06 +0900 Subject: [PATCH] feat: parseArmor/parseWeapons on join --- build.gradle.kts | 2 +- .../lifecore/listener/FixMythicItemListener.kt | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 913c100..cd3cf2f 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -9,7 +9,7 @@ plugins { } group = "net.azisaba" -version = "6.6.12" +version = "6.6.13" java { toolchain.languageVersion.set(JavaLanguageVersion.of(8)) diff --git a/src/main/java/com/github/mori01231/lifecore/listener/FixMythicItemListener.kt b/src/main/java/com/github/mori01231/lifecore/listener/FixMythicItemListener.kt index 9ef528c..0da1c20 100644 --- a/src/main/java/com/github/mori01231/lifecore/listener/FixMythicItemListener.kt +++ b/src/main/java/com/github/mori01231/lifecore/listener/FixMythicItemListener.kt @@ -6,6 +6,7 @@ import org.bukkit.event.EventHandler import org.bukkit.event.Listener import org.bukkit.event.inventory.ClickType import org.bukkit.event.inventory.InventoryClickEvent +import org.bukkit.event.player.PlayerJoinEvent import xyz.acrylicstyle.util.expression.RuntimeData import xyz.acrylicstyle.util.expression.instruction.InstInvokeVirtual import xyz.acrylicstyle.util.expression.instruction.InstLoadVariable @@ -35,16 +36,25 @@ object FixMythicItemListener : Listener { if (e.click != ClickType.NUMBER_KEY) { return } + scheduleFix(e.whoClicked as Player) + } + + @EventHandler + fun onJoin(e: PlayerJoinEvent) { + scheduleFix(e.player) + } + + private fun scheduleFix(player: Player) { val plugin = Bukkit.getPluginManager().getPlugin("MythicCrucible") ?: return Bukkit.getScheduler().runTask(plugin, Runnable { val runtimeData = RuntimeData.builder() .allowPrivate(false) - .addVariable("player", e.whoClicked) + .addVariable("player", player) .addVariable("plugin", plugin) .build() parseWeapon.execute(runtimeData) parseArmor.execute(runtimeData) - (e.whoClicked as Player).updateInventory() + player.updateInventory() }) } }