diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/listeners/PlayerDataCreator.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/listeners/PlayerDataCreator.scala index 0755e987b9..91ec918ba0 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/listeners/PlayerDataCreator.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/listeners/PlayerDataCreator.scala @@ -3,15 +3,15 @@ package com.github.unchama.seichiassist.subsystems.vote.bukkit.listeners import cats.effect.ConcurrentEffect import cats.effect.ConcurrentEffect.ops.toAllConcurrentEffectOps import com.github.unchama.seichiassist.subsystems.vote.domain.VotePersistence -import org.bukkit.event.player.PlayerJoinEvent -import org.bukkit.event.{EventHandler, Listener} +import org.bukkit.event.player.AsyncPlayerPreLoginEvent +import org.bukkit.event.{EventHandler, EventPriority, Listener} class PlayerDataCreator[F[_]: ConcurrentEffect](implicit votePersistence: VotePersistence[F]) extends Listener { - @EventHandler - def onJoin(e: PlayerJoinEvent): Unit = { - votePersistence.createPlayerData(e.getPlayer.getUniqueId).toIO.unsafeRunSync() + @EventHandler(priority = EventPriority.HIGHEST) + def onPlayerPreLoginEvent(e: AsyncPlayerPreLoginEvent): Unit = { + votePersistence.createPlayerData(e.getUniqueId).toIO.unsafeRunAsyncAndForget() } } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcVotePersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcVotePersistence.scala index d1005d150f..35d8b6644a 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcVotePersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcVotePersistence.scala @@ -11,7 +11,7 @@ class JdbcVotePersistence[F[_]: Sync] extends VotePersistence[F] { // NOTE: 連続投票日数許容幅を変更する場合はここを変更してください。 private val consecutiveVoteStreakDaysThreshold = 1 - def createPlayerData(uuid: UUID): F[Unit] = Sync[F].delay { + override def createPlayerData(uuid: UUID): F[Unit] = Sync[F].delay { DB.localTx { implicit session => sql"""INSERT IGNORE INTO vote | (uuid, vote_number, chain_vote_number, effect_point, given_effect_point, last_vote)