Skip to content

Commit

Permalink
feat: parseArmor/parseWeapons on join
Browse files Browse the repository at this point in the history
  • Loading branch information
acrylic-style committed Sep 11, 2023
1 parent 8a1ba3b commit bfe9ead
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ plugins {
}

group = "net.azisaba"
version = "6.6.12"
version = "6.6.13"

java {
toolchain.languageVersion.set(JavaLanguageVersion.of(8))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
})
}
}

0 comments on commit bfe9ead

Please sign in to comment.