diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml index a55e7a179b..79ee123c2b 100644 --- a/.idea/codeStyles/codeStyleConfig.xml +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -1,5 +1,5 @@ - \ No newline at end of file diff --git a/src/main/resources/db/migration/V1.17.0__Create_break_preference_table.sql b/src/main/resources/db/migration/V1.17.0__Create_break_preference_table.sql new file mode 100644 index 0000000000..3e2b33c847 --- /dev/null +++ b/src/main/resources/db/migration/V1.17.0__Create_break_preference_table.sql @@ -0,0 +1,9 @@ +USE seichiassist; + +CREATE TABLE player_break_preference( + uuid CHAR(36) NOT NULL, + block_category ENUM('Chest', 'MadeFromNetherQuartz') NOT NULL, + do_break BOOL NOT NULL DEFAULT TRUE, + PRIMARY KEY(uuid, block_category), + INDEX index_player_break_preference_on_uuid (uuid) +); diff --git a/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala b/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala index c4e3375fca..caf7eafff1 100644 --- a/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala +++ b/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala @@ -61,6 +61,7 @@ import com.github.unchama.seichiassist.subsystems._ import com.github.unchama.seichiassist.subsystems.anywhereender.AnywhereEnderChestAPI import com.github.unchama.seichiassist.subsystems.breakcount.{BreakCountAPI, BreakCountReadAPI} import com.github.unchama.seichiassist.subsystems.breakcountbar.BreakCountBarAPI +import com.github.unchama.seichiassist.subsystems.breakskilltargetconfig.BreakSkillTargetConfigAPI import com.github.unchama.seichiassist.subsystems.buildcount.BuildCountAPI import com.github.unchama.seichiassist.subsystems.discordnotification.DiscordNotificationAPI import com.github.unchama.seichiassist.subsystems.donate.DonatePremiumPointAPI @@ -480,6 +481,11 @@ class SeichiAssist extends JavaPlugin() { subsystems.vote.subsystems.fairyspeech.System.wired[IO] } + /* TODO: breakSkillTargetConfigSystemは本来privateであるべきだが、 + BreakUtilで呼び出されているため、やむを得ずpublicになっている */ + lazy val breakSkillTargetConfigSystem: subsystems.breakskilltargetconfig.System[IO, Player] = + subsystems.breakskilltargetconfig.System.wired[IO, SyncIO].unsafeRunSync() + /* TODO: mineStackSystemは本来privateであるべきだが、mineStackにアイテムを格納するAPIが現状の BreakUtilの実装から呼び出されている都合上やむを得ずpublicになっている。*/ lazy val mineStackSystem: subsystems.minestack.System[IO, Player, ItemStack] = @@ -520,7 +526,8 @@ class SeichiAssist extends JavaPlugin() { sharedInventorySystem, mineStackSystem, consumeGachaTicketSystem, - openirontrapdoor.System.wired + openirontrapdoor.System.wired, + breakSkillTargetConfigSystem ) private lazy val buildAssist: BuildAssist = { @@ -695,6 +702,8 @@ class SeichiAssist extends JavaPlugin() { implicit val gachaAPI: GachaDrawAPI[IO, Player] = gachaSystem.api implicit val consumeGachaTicketAPI: ConsumeGachaTicketAPI[IO, Player] = consumeGachaTicketSystem.api + implicit val breakSkillTargetConfigAPI: BreakSkillTargetConfigAPI[IO, Player] = + breakSkillTargetConfigSystem.api val menuRouter = TopLevelRouter.apply import SeichiAssist.Scopes.globalChatInterceptionScope diff --git a/src/main/scala/com/github/unchama/seichiassist/data/player/PlayerData.scala b/src/main/scala/com/github/unchama/seichiassist/data/player/PlayerData.scala index 4ab8d426f0..9227f53e45 100644 --- a/src/main/scala/com/github/unchama/seichiassist/data/player/PlayerData.scala +++ b/src/main/scala/com/github/unchama/seichiassist/data/player/PlayerData.scala @@ -43,26 +43,6 @@ class PlayerData(@Deprecated() val uuid: UUID, val name: String) { // プレイヤー名 val lowercaseName: String = name.toLowerCase() - // チェスト破壊トグル - var chestflag = true - - // ネザー水晶類ブロック破壊トグル - var netherQuartzBlockflag = true - - /** - * チェスト破壊のON/OFFを切り替える[UnfocusedEffect] - */ - val toggleChestBreakFlag: TargetedEffect[Player] = UnfocusedEffect { - chestflag = !chestflag - } - - /** - * ネザー水晶類ブロック破壊のON/OFFを切り替える[UnfocusedEffect] - */ - val toggleNetherQuartzBlockBreakFlag: TargetedEffect[Player] = UnfocusedEffect { - netherQuartzBlockflag = !netherQuartzBlockflag - } - var canCreateRegion = true var unitPerClick = 1 // 投票受け取りボタン連打防止用 diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/TopLevelRouter.scala b/src/main/scala/com/github/unchama/seichiassist/menus/TopLevelRouter.scala index 74397ac4c5..09cf6adcd4 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/TopLevelRouter.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/TopLevelRouter.scala @@ -29,6 +29,7 @@ import com.github.unchama.seichiassist.subsystems.anywhereender.AnywhereEnderChe import com.github.unchama.seichiassist.subsystems.breakcount.BreakCountAPI import com.github.unchama.seichiassist.subsystems.breakcount.domain.SeichiAmountData import com.github.unchama.seichiassist.subsystems.breakcountbar.BreakCountBarAPI +import com.github.unchama.seichiassist.subsystems.breakskilltargetconfig.BreakSkillTargetConfigAPI import com.github.unchama.seichiassist.subsystems.buildcount.domain.playerdata.BuildAmountData import com.github.unchama.seichiassist.subsystems.discordnotification.DiscordNotificationAPI import com.github.unchama.seichiassist.subsystems.donate.DonatePremiumPointAPI @@ -96,7 +97,8 @@ object TopLevelRouter { mineStackAPI: MineStackAPI[IO, Player, ItemStack], gachaDrawAPI: GachaDrawAPI[IO, Player], consumeGachaTicketAPI: ConsumeGachaTicketAPI[IO, Player], - fairySpeechAPI: FairySpeechAPI[IO, Player] + fairySpeechAPI: FairySpeechAPI[IO, Player], + breakSkillTargetConfigAPI: BreakSkillTargetConfigAPI[IO, Player] ): TopLevelRouter[IO] = new TopLevelRouter[IO] { import assortedRankingApi._ diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/skill/PassiveSkillMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/skill/PassiveSkillMenu.scala index f725c54f68..a2034882b7 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/skill/PassiveSkillMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/skill/PassiveSkillMenu.scala @@ -11,6 +11,8 @@ import com.github.unchama.seichiassist.data.MenuInventoryData import com.github.unchama.seichiassist.menus.CommonButtons import com.github.unchama.seichiassist.menus.stickmenu.FirstPage import com.github.unchama.seichiassist.subsystems.breakcount.BreakCountAPI +import com.github.unchama.seichiassist.subsystems.breakskilltargetconfig.BreakSkillTargetConfigAPI +import com.github.unchama.seichiassist.subsystems.breakskilltargetconfig.domain.BreakSkillTargetConfigKey import com.github.unchama.targetedeffect._ import com.github.unchama.targetedeffect.commandsender.MessageEffect import com.github.unchama.targetedeffect.player.FocusedSoundEffect @@ -30,6 +32,7 @@ object PassiveSkillMenu extends Menu { class Environment( implicit val breakCountApi: BreakCountAPI[IO, SyncIO, Player], + implicit val breakSkillTargetConfigAPI: BreakSkillTargetConfigAPI[IO, Player], val ioCanOpenFirstPage: IO CanOpen FirstPage.type ) @@ -141,16 +144,19 @@ object PassiveSkillMenu extends Menu { ) } - val computeToggleChestBreakButton: IO[Button] = RecomputedButton(IO { - val openerData = SeichiAssist.playermap(getUniqueId) + import environment._ + val computeToggleChestBreakButton: IO[Button] = RecomputedButton(for { + originalBreakChestConfig <- breakSkillTargetConfigAPI + .breakSkillTargetConfig(player, BreakSkillTargetConfigKey.Chest) + } yield { val baseLore = List(s"${GREEN}スキルでチェストを破壊するスキル") - val statusLore = if (openerData.chestflag) { + val statusLore = if (originalBreakChestConfig) { List(s"${RED}整地ワールドのみで発動中(デフォルト)", "", s"$DARK_GREEN${UNDERLINE}クリックで切り替え") } else { List(s"${RED}発動しません", "", s"$DARK_GREEN${UNDERLINE}クリックで切り替え") } - val material = if (openerData.chestflag) Material.DIAMOND_AXE else Material.CHEST + val material = if (originalBreakChestConfig) Material.DIAMOND_AXE else Material.CHEST Button( new IconItemStackBuilder(material) @@ -159,9 +165,11 @@ object PassiveSkillMenu extends Menu { .build(), LeftClickButtonEffect { SequentialEffect( - openerData.toggleChestBreakFlag, + breakSkillTargetConfigAPI.toggleBreakSkillTargetConfig( + BreakSkillTargetConfigKey.Chest + ), DeferredEffect(IO { - if (openerData.chestflag) { + if (!originalBreakChestConfig) { SequentialEffect( MessageEffect(s"${GREEN}スキルでのチェスト破壊を有効化しました。"), FocusedSoundEffect(Sound.BLOCK_STONE_BUTTON_CLICK_ON, 1f, 1f) @@ -178,11 +186,12 @@ object PassiveSkillMenu extends Menu { ) }) - val computeToggleNetherQuartzBlockButton: IO[Button] = RecomputedButton(IO { - val openerData = SeichiAssist.playermap(getUniqueId) - + val computeToggleNetherQuartzBlockButton: IO[Button] = RecomputedButton(for { + originalBreakQuartz <- breakSkillTargetConfigAPI + .breakSkillTargetConfig(player, BreakSkillTargetConfigKey.MadeFromNetherQuartz) + } yield { val baseLore = List(s"${YELLOW}スキルでネザー水晶類ブロックを破壊するスキル") - val statusLore = if (openerData.netherQuartzBlockflag) { + val statusLore = if (originalBreakQuartz) { List(s"${GREEN}ON (スキルでネザー水晶類ブロックを破壊します。)", s"${DARK_RED}クリックでOFF") } else { List(s"${RED}OFF (スキルでネザー水晶類ブロックを破壊しません。)", s"${DARK_GREEN}クリックでON") @@ -191,7 +200,7 @@ object PassiveSkillMenu extends Menu { Button( new IconItemStackBuilder(Material.QUARTZ_BLOCK) .tap { builder => - if (openerData.netherQuartzBlockflag) + if (originalBreakQuartz) builder.enchanted() } .title(s"$WHITE$UNDERLINE${BOLD}ネザー水晶類ブロック破壊スキル切り替え") @@ -199,9 +208,11 @@ object PassiveSkillMenu extends Menu { .build(), LeftClickButtonEffect { SequentialEffect( - openerData.toggleNetherQuartzBlockBreakFlag, + breakSkillTargetConfigAPI.toggleBreakSkillTargetConfig( + BreakSkillTargetConfigKey.MadeFromNetherQuartz + ), DeferredEffect(IO { - if (openerData.netherQuartzBlockflag) { + if (!originalBreakQuartz) { SequentialEffect( MessageEffect(s"${GREEN}スキルでのネザー水晶類ブロック破壊を有効化しました。"), FocusedSoundEffect(Sound.BLOCK_STONE_BUTTON_CLICK_ON, 1f, 1f) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/BreakSkillTargetConfigAPI.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/BreakSkillTargetConfigAPI.scala new file mode 100644 index 0000000000..97770a5520 --- /dev/null +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/BreakSkillTargetConfigAPI.scala @@ -0,0 +1,28 @@ +package com.github.unchama.seichiassist.subsystems.breakskilltargetconfig + +import cats.data.Kleisli +import com.github.unchama.seichiassist.subsystems.breakskilltargetconfig.domain.BreakSkillTargetConfigKey + +trait BreakSkillTargetConfigAPI[F[_], Player] { + + /** + * @return 破壊フラグをトグルする作用 + */ + def toggleBreakSkillTargetConfig( + configKey: BreakSkillTargetConfigKey + ): Kleisli[F, Player, Unit] + + /** + * @return 現在の破壊フラグを取得する作用 + */ + def breakSkillTargetConfig(player: Player, configKey: BreakSkillTargetConfigKey): F[Boolean] + +} + +object BreakSkillTargetConfigAPI { + + def apply[F[_], Player]( + implicit ev: BreakSkillTargetConfigAPI[F, Player] + ): BreakSkillTargetConfigAPI[F, Player] = ev + +} diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/System.scala new file mode 100644 index 0000000000..08ded6514f --- /dev/null +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/System.scala @@ -0,0 +1,66 @@ +package com.github.unchama.seichiassist.subsystems.breakskilltargetconfig + +import cats.data.Kleisli +import cats.effect.{Sync, SyncEffect} +import com.github.unchama.datarepository.bukkit.player.BukkitRepositoryControls +import com.github.unchama.generic.ContextCoercion +import com.github.unchama.seichiassist.meta.subsystem.Subsystem +import com.github.unchama.seichiassist.subsystems.breakskilltargetconfig.application.repository.BreakSkillTargetConfigRepositoryDefinition +import com.github.unchama.seichiassist.subsystems.breakskilltargetconfig.domain.{ + BreakSkillTargetConfigKey, + BreakSkillTargetConfigPersistence +} +import com.github.unchama.seichiassist.subsystems.breakskilltargetconfig.persistence.JdbcBreakSkillTargetConfigPersistence +import org.bukkit.entity.Player + +trait System[F[_], Player] extends Subsystem[F] { + val api: BreakSkillTargetConfigAPI[F, Player] +} + +object System { + + import cats.implicits._ + + def wired[F[_]: Sync, G[_]: SyncEffect: ContextCoercion[*[_], F]]: G[System[F, Player]] = { + implicit val breakSkillTargetConfigPersistence: BreakSkillTargetConfigPersistence[G] = + new JdbcBreakSkillTargetConfigPersistence[G] + + for { + breakSkillTargetConfigRepositoryControls <- BukkitRepositoryControls.createHandles( + BreakSkillTargetConfigRepositoryDefinition.withContext[G, Player] + ) + } yield { + val breakSkillTargetConfigRepository = breakSkillTargetConfigRepositoryControls.repository + + new System[F, Player] { + override val api: BreakSkillTargetConfigAPI[F, Player] = + new BreakSkillTargetConfigAPI[F, Player] { + override def toggleBreakSkillTargetConfig( + configKey: BreakSkillTargetConfigKey + ): Kleisli[F, Player, Unit] = + Kleisli { player => + ContextCoercion( + breakSkillTargetConfigRepository(player) + .update(_.toggleBreakSkillTargetConfig(configKey)) + ) + } + + override def breakSkillTargetConfig( + player: Player, + configKey: BreakSkillTargetConfigKey + ): F[Boolean] = + ContextCoercion( + breakSkillTargetConfigRepository(player) + .get + .map(_.breakSkillTargetConfig(configKey)) + ) + } + + override val managedRepositoryControls: Seq[BukkitRepositoryControls[F, _]] = Seq( + breakSkillTargetConfigRepositoryControls.coerceFinalizationContextTo[F] + ) + } + } + } + +} diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/application/repository/BreakSkillTargetConfigRepositoryDefinition.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/application/repository/BreakSkillTargetConfigRepositoryDefinition.scala new file mode 100644 index 0000000000..05d871b5c5 --- /dev/null +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/application/repository/BreakSkillTargetConfigRepositoryDefinition.scala @@ -0,0 +1,23 @@ +package com.github.unchama.seichiassist.subsystems.breakskilltargetconfig.application.repository + +import cats.effect.Sync +import cats.effect.concurrent.Ref +import com.github.unchama.datarepository.definitions.RefDictBackedRepositoryDefinition +import com.github.unchama.datarepository.template.RepositoryDefinition +import com.github.unchama.seichiassist.subsystems.breakskilltargetconfig.domain.{ + BreakSkillTargetConfig, + BreakSkillTargetConfigPersistence +} + +object BreakSkillTargetConfigRepositoryDefinition { + + def withContext[F[_]: Sync, Player]( + implicit persistence: BreakSkillTargetConfigPersistence[F] + ): RepositoryDefinition[F, Player, Ref[F, BreakSkillTargetConfig]] = + RefDictBackedRepositoryDefinition + .usingUuidRefDict[F, Player, BreakSkillTargetConfig](persistence)( + BreakSkillTargetConfig.initial + ) + .toRefRepository + +} diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/domain/BreakSkillTargetConfig.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/domain/BreakSkillTargetConfig.scala new file mode 100644 index 0000000000..ea916a8348 --- /dev/null +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/domain/BreakSkillTargetConfig.scala @@ -0,0 +1,28 @@ +package com.github.unchama.seichiassist.subsystems.breakskilltargetconfig.domain + +case class BreakSkillTargetConfig(config: Map[BreakSkillTargetConfigKey, Boolean]) { + + /** + * @return `configKey`の破壊フラグをトグルする + */ + def toggleBreakSkillTargetConfig( + configKey: BreakSkillTargetConfigKey + ): BreakSkillTargetConfig = + this.copy(this.config + (configKey -> this.config.getOrElse(configKey, false))) + + /** + * @return 現在の破壊フラグを取得する + */ + def breakSkillTargetConfig(configKey: BreakSkillTargetConfigKey): Boolean = + this.config.getOrElse(configKey, false) + +} + +object BreakSkillTargetConfig { + + /** + * [[BreakSkillTargetConfig]]の初期値 + */ + val initial: BreakSkillTargetConfig = BreakSkillTargetConfig(Map.empty) + +} diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/domain/BreakSkillTargetConfigKey.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/domain/BreakSkillTargetConfigKey.scala new file mode 100644 index 0000000000..ea511195c2 --- /dev/null +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/domain/BreakSkillTargetConfigKey.scala @@ -0,0 +1,26 @@ +package com.github.unchama.seichiassist.subsystems.breakskilltargetconfig.domain + +import enumeratum.{Enum, EnumEntry} + +/** + * 予め決められたブロックの集合を表現する。 + * これらの値は整地スキルでブロックを破壊する際に、 + * プレイヤーの設定に応じて一部のブロックを除外する際に使われる。 + */ +sealed trait BreakSkillTargetConfigKey extends EnumEntry + +object BreakSkillTargetConfigKey extends Enum[BreakSkillTargetConfigKey] { + + val values: IndexedSeq[BreakSkillTargetConfigKey] = findValues + + /** + * チェストを破壊するかどうか + */ + case object Chest extends BreakSkillTargetConfigKey + + /** + * ネザークォーツをクラフトしたブロックを破壊するかどうか + */ + case object MadeFromNetherQuartz extends BreakSkillTargetConfigKey + +} diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/domain/BreakSkillTargetConfigPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/domain/BreakSkillTargetConfigPersistence.scala new file mode 100644 index 0000000000..6c91b1a752 --- /dev/null +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/domain/BreakSkillTargetConfigPersistence.scala @@ -0,0 +1,7 @@ +package com.github.unchama.seichiassist.subsystems.breakskilltargetconfig.domain + +import com.github.unchama.generic.RefDict + +import java.util.UUID + +trait BreakSkillTargetConfigPersistence[F[_]] extends RefDict[F, UUID, BreakSkillTargetConfig] diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/persistence/JdbcBreakSkillTargetConfigPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/persistence/JdbcBreakSkillTargetConfigPersistence.scala new file mode 100644 index 0000000000..2ed07fa43d --- /dev/null +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/persistence/JdbcBreakSkillTargetConfigPersistence.scala @@ -0,0 +1,53 @@ +package com.github.unchama.seichiassist.subsystems.breakskilltargetconfig.persistence + +import cats.effect.Sync +import com.github.unchama.seichiassist.subsystems.breakskilltargetconfig.domain.{ + BreakSkillTargetConfig, + BreakSkillTargetConfigKey, + BreakSkillTargetConfigPersistence +} +import scalikejdbc.{DB, scalikejdbcSQLInterpolationImplicitDef} + +import java.util.UUID + +class JdbcBreakSkillTargetConfigPersistence[F[_]: Sync] + extends BreakSkillTargetConfigPersistence[F] { + + override def read(key: UUID): F[Option[BreakSkillTargetConfig]] = Sync[F].delay { + val config = DB.readOnly { implicit session => + sql"SELECT block_category, do_break FROM player_break_preference WHERE uuid = ${key.toString}" + .map { rs => + BreakSkillTargetConfigKey.withNameOption(rs.string("block_category")).map { + flagName => flagName -> rs.boolean("do_break") + } + } + .toList() + .apply() + .flatten + .toMap + } + + Some(BreakSkillTargetConfig(config)) + } + + override def write(key: UUID, value: BreakSkillTargetConfig): F[Unit] = Sync[F].delay { + DB.localTx { implicit session => + val uuid = key.toString + val batchParams = + value + .config + .map { + case (blockCategory, doBreak) => + Seq(uuid, blockCategory.entryName, doBreak) + } + .toSeq + + sql"""INSERT INTO player_break_preference (uuid, block_category, do_break) + | VALUES (?, ?, ?) + | ON DUPLICATE KEY UPDATE + | do_break = VALUE(do_break) + """.stripMargin.batch(batchParams: _*).apply[List]() + } + } + +} diff --git a/src/main/scala/com/github/unchama/seichiassist/util/BreakUtil.scala b/src/main/scala/com/github/unchama/seichiassist/util/BreakUtil.scala index d5dd66c7fb..5ef37e79cc 100644 --- a/src/main/scala/com/github/unchama/seichiassist/util/BreakUtil.scala +++ b/src/main/scala/com/github/unchama/seichiassist/util/BreakUtil.scala @@ -16,6 +16,7 @@ import com.github.unchama.seichiassist.seichiskill.SeichiSkill.{ import com.github.unchama.seichiassist.seichiskill.SeichiSkillUsageMode.{Active, Disabled} import com.github.unchama.seichiassist.subsystems.breakcount.domain.CardinalDirection import com.github.unchama.seichiassist.subsystems.breakcount.domain.level.SeichiExpAmount +import com.github.unchama.seichiassist.subsystems.breakskilltargetconfig.domain.BreakSkillTargetConfigKey import com.github.unchama.targetedeffect.player.ActionBarMessageEffect import com.github.unchama.util.bukkit.ItemStackUtil import com.github.unchama.util.external.ExternalPlugins @@ -126,7 +127,14 @@ object BreakUtil { def isProtectedChest(player: Player, checkTarget: Block): Boolean = { checkTarget.getType match { case Material.CHEST | Material.TRAPPED_CHEST => - if (!SeichiAssist.playermap(player.getUniqueId).chestflag) { + if ( + !SeichiAssist + .instance + .breakSkillTargetConfigSystem + .api + .breakSkillTargetConfig(player, BreakSkillTargetConfigKey.Chest) + .unsafeRunSync() + ) { ActionBarMessageEffect(s"${RED}スキルでのチェスト破壊は無効化されています").run(player).unsafeRunSync() true } else if (!player.getWorld.isSeichi) { @@ -143,7 +151,14 @@ object BreakUtil { checkTarget.getType match { // 鉱石ブロックの方はプロテクトの対象外 case Material.QUARTZ_BLOCK | Material.QUARTZ_STAIRS => - if (!SeichiAssist.playermap(player.getUniqueId).netherQuartzBlockflag) { + if ( + !SeichiAssist + .instance + .breakSkillTargetConfigSystem + .api + .breakSkillTargetConfig(player, BreakSkillTargetConfigKey.MadeFromNetherQuartz) + .unsafeRunSync() + ) { ActionBarMessageEffect(s"${RED}スキルでのネザー水晶類ブロックの破壊は無効化されています") .run(player) .unsafeRunSync()