From f630236af22b7c04293c07c66a44fcc4206e6325 Mon Sep 17 00:00:00 2001 From: acrylic-style Date: Fri, 9 Feb 2024 15:06:47 +0900 Subject: [PATCH] change: set cooldown for dice1 item --- build.gradle.kts | 2 +- .../lifecore/listener/item/Dice1ItemListener.kt | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index e756466..e1cd392 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -9,7 +9,7 @@ plugins { } group = "net.azisaba" -version = "6.9.4" +version = "6.9.5" java { toolchain.languageVersion.set(JavaLanguageVersion.of(8)) diff --git a/src/main/java/com/github/mori01231/lifecore/listener/item/Dice1ItemListener.kt b/src/main/java/com/github/mori01231/lifecore/listener/item/Dice1ItemListener.kt index b7655c9..99cd5db 100644 --- a/src/main/java/com/github/mori01231/lifecore/listener/item/Dice1ItemListener.kt +++ b/src/main/java/com/github/mori01231/lifecore/listener/item/Dice1ItemListener.kt @@ -10,11 +10,13 @@ import org.bukkit.event.Listener import org.bukkit.event.block.Action import org.bukkit.event.player.PlayerInteractEvent import java.security.SecureRandom +import java.util.UUID class Dice1ItemListener(val plugin: LifeCore) : Listener { private val random = SecureRandom() private val itemId = "b46ed137-a581-4ee8-b714-c1e136d141f2" private val prefix = "§f§l【§6§l抽選§f§l】" + private val cooldown = mutableSetOf() @EventHandler fun onPlayerInteract(e: PlayerInteractEvent) { @@ -25,6 +27,13 @@ class Dice1ItemListener(val plugin: LifeCore) : Listener { // wrong item return } + if (cooldown.contains(e.player.uniqueId)) { + return + } + cooldown.add(e.player.uniqueId) + Bukkit.getScheduler().runTaskLater(plugin, Runnable { + cooldown.remove(e.player.uniqueId) + }, 20 * 5) fun rollNow() { val randomPlayer = e.player