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