Skip to content

Commit

Permalink
fix: 全体通知を表示しない設定でもGT大当たり通知が表示される不具合を修正
Browse files Browse the repository at this point in the history
  • Loading branch information
rito528 committed Dec 17, 2023
1 parent 927b3c7 commit 63a1384
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
package com.github.unchama.seichiassist.subsystems.gacha.bukkit.actions

import cats.effect.Sync
import cats.effect.{LiftIO, Sync}
import com.github.unchama.minecraft.actions.{GetConnectedPlayers, OnMinecraftServerThread}
import com.github.unchama.seichiassist.subsystems.gacha.application.actions.{
DrawGacha,
GrantGachaPrize
}
import com.github.unchama.seichiassist.subsystems.gacha.application.actions.{DrawGacha, GrantGachaPrize}
import com.github.unchama.seichiassist.subsystems.gacha.domain.{GrantState, LotteryOfGachaItems}
import com.github.unchama.seichiassist.subsystems.gachaprize.GachaPrizeAPI
import com.github.unchama.seichiassist.subsystems.gachaprize.domain.GachaRarity._
import com.github.unchama.seichiassist.util.SendMessageEffect.sendMessageToEveryoneIgnoringPreferenceM
import com.github.unchama.seichiassist.util.SendMessageEffect.{sendMessageToEveryone, sendMessageToEveryoneIgnoringPreferenceM}
import com.github.unchama.seichiassist.util._
import net.md_5.bungee.api.chat.hover.content.Text
import net.md_5.bungee.api.chat.{HoverEvent, TextComponent}
Expand All @@ -18,7 +15,7 @@ import org.bukkit.Sound
import org.bukkit.entity.Player
import org.bukkit.inventory.ItemStack

class BukkitDrawGacha[F[_]: Sync: OnMinecraftServerThread: GetConnectedPlayers[*[_], Player]](
class BukkitDrawGacha[F[_]: LiftIO: Sync: OnMinecraftServerThread: GetConnectedPlayers[*[_], Player]](
implicit gachaPrizeAPI: GachaPrizeAPI[F, ItemStack, Player],
lotteryOfGachaItems: LotteryOfGachaItems[F, ItemStack],
grantGachaPrize: GrantGachaPrize[F, ItemStack, Player]
Expand Down Expand Up @@ -76,7 +73,7 @@ class BukkitDrawGacha[F[_]: Sync: OnMinecraftServerThread: GetConnectedPlayers[*
Sync[F].delay {
player.sendMessage(s"${RED}おめでとう!!!!!Gigantic☆大当たり!$additionalMessage")
player.spigot().sendMessage(message)
} >> sendMessageToEveryoneIgnoringPreferenceM[TextComponent, F](message) >> Sync[
} >> sendMessageToEveryone[TextComponent, F](message) >> Sync[
F
].delay {
SendSoundEffect.sendEverySoundWithoutIgnore(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package com.github.unchama.seichiassist.util

import cats.Monad
import cats.effect.IO
import cats.effect.{IO, LiftIO}
import com.github.unchama.minecraft.actions.GetConnectedPlayers
import com.github.unchama.minecraft.bukkit.actions.GetConnectedBukkitPlayers
import com.github.unchama.seichiassist.SeichiAssist
import com.github.unchama.seichiassist.concurrent.PluginExecutionContexts.onMainThread
import org.bukkit.entity.Player

Expand All @@ -26,4 +27,24 @@ object SendMessageEffect {
_ <- players.traverse(ev.send(_, content))
} yield ()
}

def sendMessageToEveryone[T, F[_]: Monad: LiftIO: GetConnectedPlayers[*[_], Player]](
content: T
)(implicit ev: PlayerSendable[T, F]): F[Unit] = {
import cats.implicits._

for {
players <- GetConnectedPlayers[F, Player].now
_ <- players.traverse { player =>
for {
playerSettings <- SeichiAssist
.playermap(player.getUniqueId)
.settings
.getBroadcastMutingSettings
.to[F]
_ <- ev.send(player, content).unlessA(playerSettings.shouldMuteMessages)
} yield ()
}
} yield ()
}
}

0 comments on commit 63a1384

Please sign in to comment.