From f8aff4754c5140b61a76703cb3f89bcb8e6b5c82 Mon Sep 17 00:00:00 2001 From: Kisaragi <48310258+KisaragiEffective@users.noreply.github.com> Date: Mon, 29 May 2023 00:21:13 +0900 Subject: [PATCH 01/59] =?UTF-8?q?fix(ci):=20scalafix=E3=81=8Cpush=E3=81=A7?= =?UTF-8?q?=E8=90=BD=E3=81=A1=E3=82=8B=E6=80=AA=E7=8F=BE=E8=B1=A1=E3=82=92?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build_and_deploy.yml | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build_and_deploy.yml b/.github/workflows/build_and_deploy.yml index 12465687dd..de51297062 100644 --- a/.github/workflows/build_and_deploy.yml +++ b/.github/workflows/build_and_deploy.yml @@ -107,13 +107,10 @@ jobs: reviewdog-name: scalafmt github-token: ${{ secrets.GITHUB_TOKEN }} - - name: Check lint with Scalafix on push - if: ${{ (github.event_name == 'push')}} + - name: Run scalafix check + # cf. https://scalacenter.github.io/scalafix/docs/users/installation.html#enforce-in-ci run: sbt "scalafix --check" - - name: Run lint with Scalafix on PR - if: ${{ (github.event_name == 'pull_request')}} - run: sbt scalafixAll - - name: Run reviewdog for Scalafix + - name: Annotate scalafix diagnostics with reviewdog uses: ./.github/actions/run-reviewdog if: ${{ (github.event_name == 'pull_request') && failure() }} with: From 4fb090017cf5e59d4d5342e7a4b5c612a60d5af8 Mon Sep 17 00:00:00 2001 From: rito528 Date: Wed, 31 May 2023 09:29:25 +0900 Subject: [PATCH 02/59] =?UTF-8?q?feat:=20BreakFalg=E3=82=92=E5=AE=9A?= =?UTF-8?q?=E7=BE=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../breakflags/domain/BreakFlag.scala | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/domain/BreakFlag.scala diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/domain/BreakFlag.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/domain/BreakFlag.scala new file mode 100644 index 0000000000..6450f37f2a --- /dev/null +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/domain/BreakFlag.scala @@ -0,0 +1,20 @@ +package com.github.unchama.seichiassist.subsystems.breakflags.domain + +/** + * 定義されたブロックを破壊するかしないかを表すためのFlagのEnum + */ +sealed trait BreakFlag + +object BreakFlag { + + /** + * Chestブロックを破壊するかを示すEnum + */ + case object Chest extends BreakFlag + + /** + * ネザークォーツ系ブロックを破壊するかを示すEnum + */ + case object NetherQuartz extends BreakFlag + +} From e1595ec0b267ed7c9b5595621764323c9c46b897 Mon Sep 17 00:00:00 2001 From: rito528 Date: Wed, 31 May 2023 09:35:44 +0900 Subject: [PATCH 03/59] =?UTF-8?q?feat:=20BreakFlagPersistence=E3=82=92?= =?UTF-8?q?=E5=AE=9A=E7=BE=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../breakflags/domain/BreakFlagPersistence.scala | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/domain/BreakFlagPersistence.scala diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/domain/BreakFlagPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/domain/BreakFlagPersistence.scala new file mode 100644 index 0000000000..e90b8e978a --- /dev/null +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/domain/BreakFlagPersistence.scala @@ -0,0 +1,7 @@ +package com.github.unchama.seichiassist.subsystems.breakflags.domain + +import com.github.unchama.generic.RefDict + +import java.util.UUID + +trait BreakFlagPersistence[F[_]] extends RefDict[F, UUID, BreakFlag] From 1f526092ec57cd99d6e8de65ca21e560a3d9af45 Mon Sep 17 00:00:00 2001 From: rito528 Date: Wed, 31 May 2023 17:26:17 +0900 Subject: [PATCH 04/59] =?UTF-8?q?feat:=20BreakFlag=E3=81=AE=E6=B0=B8?= =?UTF-8?q?=E7=B6=9A=E5=8C=96=E5=B1=A4=E3=82=92=E5=AE=9F=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../breakflags/domain/BreakFlag.scala | 19 +------- .../breakflags/domain/BreakFlagName.scala | 24 ++++++++++ .../domain/BreakFlagPersistence.scala | 2 +- .../JdbcBreakFlagPersistence.scala | 46 +++++++++++++++++++ 4 files changed, 72 insertions(+), 19 deletions(-) create mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/domain/BreakFlagName.scala create mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/persistence/JdbcBreakFlagPersistence.scala diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/domain/BreakFlag.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/domain/BreakFlag.scala index 6450f37f2a..cc86666143 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/domain/BreakFlag.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/domain/BreakFlag.scala @@ -1,20 +1,3 @@ package com.github.unchama.seichiassist.subsystems.breakflags.domain -/** - * 定義されたブロックを破壊するかしないかを表すためのFlagのEnum - */ -sealed trait BreakFlag - -object BreakFlag { - - /** - * Chestブロックを破壊するかを示すEnum - */ - case object Chest extends BreakFlag - - /** - * ネザークォーツ系ブロックを破壊するかを示すEnum - */ - case object NetherQuartz extends BreakFlag - -} +case class BreakFlag(flagName: BreakFlagName, flag: Boolean) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/domain/BreakFlagName.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/domain/BreakFlagName.scala new file mode 100644 index 0000000000..cba4e1fe68 --- /dev/null +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/domain/BreakFlagName.scala @@ -0,0 +1,24 @@ +package com.github.unchama.seichiassist.subsystems.breakflags.domain + +import enumeratum.{Enum, EnumEntry} + +/** + * 定義されたブロックを破壊するかしないかを表すためのフラグの名前を集めたEnum + */ +sealed trait BreakFlagName extends EnumEntry + +object BreakFlagName extends Enum[BreakFlagName] { + + val values: IndexedSeq[BreakFlagName] = findValues + + /** + * Chestブロックを破壊するかを示すフラグ名 + */ + case object Chest extends BreakFlagName + + /** + * ネザークォーツ系ブロックを破壊するかを示すフラグ名 + */ + case object NetherQuartz extends BreakFlagName + +} diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/domain/BreakFlagPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/domain/BreakFlagPersistence.scala index e90b8e978a..5ede21796d 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/domain/BreakFlagPersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/domain/BreakFlagPersistence.scala @@ -4,4 +4,4 @@ import com.github.unchama.generic.RefDict import java.util.UUID -trait BreakFlagPersistence[F[_]] extends RefDict[F, UUID, BreakFlag] +trait BreakFlagPersistence[F[_]] extends RefDict[F, UUID, List[BreakFlag]] diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/persistence/JdbcBreakFlagPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/persistence/JdbcBreakFlagPersistence.scala new file mode 100644 index 0000000000..9801a6383f --- /dev/null +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/persistence/JdbcBreakFlagPersistence.scala @@ -0,0 +1,46 @@ +package com.github.unchama.seichiassist.subsystems.breakflags.persistence + +import cats.effect.Sync +import com.github.unchama.seichiassist.subsystems.breakflags.domain.{BreakFlag, BreakFlagName, BreakFlagPersistence} +import scalikejdbc.{DB, scalikejdbcSQLInterpolationImplicitDef} + +import java.util.UUID + +class JdbcBreakFlagPersistence[F[_]: Sync] extends BreakFlagPersistence[F] { + override def read(key: UUID): F[Option[List[BreakFlag]]] = Sync[F].delay { + DB.readOnly { implicit session => + val breakFlags = sql"SELECT flag_name, can_break FROM break_flags WHERE uuid = ${key.toString}" + .map { rs => + BreakFlagName.withNameOption(rs.string("flag_name")).map { flagName => + BreakFlag(flagName, rs.boolean("can_break")) + } + } + .toList() + .apply() + .collect { + case Some(flag) => flag + } + + Some(breakFlags) + } + } + + override def write(key: UUID, value: List[BreakFlag]): F[Unit] = Sync[F].delay { + DB.localTx { implicit session => + val uuid = key.toString + val batchParams = value.map { flag => + Seq(uuid, flag.flagName.entryName, flag.flag) + } + + sql"""INSERT INTO break_flags (uuid, flag_name, can_break) + | VALUES (?, ?, ?) + | ON DUPLICATE KEY UPDATE + | can_break = VALUE(can_break) + """ + .stripMargin + .batch(batchParams: _*) + .apply[List] + } + } + +} From df680d9ed395264140496872a5fea1d5e8380ae1 Mon Sep 17 00:00:00 2001 From: rito528 Date: Wed, 31 May 2023 22:16:44 +0900 Subject: [PATCH 05/59] =?UTF-8?q?feat:=20break=5Fflags=E3=82=92=E4=BD=9C?= =?UTF-8?q?=E6=88=90=E3=81=99=E3=82=8B=E3=83=9E=E3=82=A4=E3=82=B0=E3=83=AC?= =?UTF-8?q?=E3=83=BC=E3=82=B7=E3=83=A7=E3=83=B3=E3=81=AE=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../db/migration/V1.17.0__Create_break_flag_table.sql | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 src/main/resources/db/migration/V1.17.0__Create_break_flag_table.sql diff --git a/src/main/resources/db/migration/V1.17.0__Create_break_flag_table.sql b/src/main/resources/db/migration/V1.17.0__Create_break_flag_table.sql new file mode 100644 index 0000000000..e48fbc6788 --- /dev/null +++ b/src/main/resources/db/migration/V1.17.0__Create_break_flag_table.sql @@ -0,0 +1,7 @@ +use SeichiAssist; + +CREATE TABLE break_flags( + uuid CHAR(36) NOT NULL PRIMARY KEY, + flag_name VARCHAR(20) NOT NULL, + can_break BOOL NOT NULL DEFAULT TRUE +); From b4ccb7937494b093a321b28884c5530910cbc3d3 Mon Sep 17 00:00:00 2001 From: rito528 Date: Wed, 31 May 2023 22:43:16 +0900 Subject: [PATCH 06/59] =?UTF-8?q?feat:=20BreakFlagRepository=E3=82=92?= =?UTF-8?q?=E5=AE=9A=E7=BE=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BreakFlagRepositoryDefinition.scala | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/application/repository/BreakFlagRepositoryDefinition.scala diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/application/repository/BreakFlagRepositoryDefinition.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/application/repository/BreakFlagRepositoryDefinition.scala new file mode 100644 index 0000000000..5994ab6945 --- /dev/null +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/application/repository/BreakFlagRepositoryDefinition.scala @@ -0,0 +1,18 @@ +package com.github.unchama.seichiassist.subsystems.breakflags.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.breakflags.domain.{BreakFlag, BreakFlagPersistence} + +object BreakFlagRepositoryDefinition { + + def withContext[F[_]: Sync, Player]( + persistence: BreakFlagPersistence[F] + ): RepositoryDefinition[F, Player, Ref[F, List[BreakFlag]]] = + RefDictBackedRepositoryDefinition + .usingUuidRefDict[F, Player, List[BreakFlag]](persistence)(List.empty) + .toRefRepository + +} From ca2f90be25cbf90543f25078d701ac2217dd1f48 Mon Sep 17 00:00:00 2001 From: rito528 Date: Wed, 31 May 2023 23:25:23 +0900 Subject: [PATCH 07/59] =?UTF-8?q?feat:=20BreakFlagAPI=E3=82=92=E5=AE=9A?= =?UTF-8?q?=E7=BE=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../subsystems/breakflags/BreakFlagAPI.scala | 30 ++++++++++++++++++ .../subsystems/breakflags/System.scala | 31 +++++++++++++++++++ .../BreakFlagRepositoryDefinition.scala | 2 +- 3 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/BreakFlagAPI.scala create mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/System.scala diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/BreakFlagAPI.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/BreakFlagAPI.scala new file mode 100644 index 0000000000..d19c6d4702 --- /dev/null +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/BreakFlagAPI.scala @@ -0,0 +1,30 @@ +package com.github.unchama.seichiassist.subsystems.breakflags + +import com.github.unchama.seichiassist.subsystems.breakflags.domain.BreakFlag + +import java.util.UUID + +trait BreakFlagAPI[F[_]] { + + /** + * @return 破壊フラグを有効にする作用 + */ + def turnOnBreakFlag(player: UUID, breakFlag: BreakFlag): F[Unit] + + /** + * @return 破壊フラグを無効にする作用 + */ + def turnOffBreakFlag(player: UUID, breakFlag: BreakFlag): F[Unit] + + /** + * @return 現在の破壊フラグを取得する作用 + */ + def breakFlag(player: UUID): F[BreakFlag] + +} + +object BreakFlagAPI { + + def apply[F[_]](implicit ev: BreakFlagAPI[F]): BreakFlagAPI[F] = ev + +} diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/System.scala new file mode 100644 index 0000000000..48c2e5bb42 --- /dev/null +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/System.scala @@ -0,0 +1,31 @@ +package com.github.unchama.seichiassist.subsystems.breakflags + +import cats.effect.{Sync, SyncEffect} +import com.github.unchama.datarepository.bukkit.player.BukkitRepositoryControls +import com.github.unchama.seichiassist.meta.subsystem.Subsystem +import com.github.unchama.seichiassist.subsystems.breakflags.application.repository.BreakFlagRepositoryDefinition +import com.github.unchama.seichiassist.subsystems.breakflags.domain.BreakFlagPersistence +import com.github.unchama.seichiassist.subsystems.breakflags.persistence.JdbcBreakFlagPersistence + +trait System[F[_]] extends Subsystem[F] { + +} + +object System { + + import cats.implicits._ + + def wired[F[_]: SyncEffect]: F[System[F]] = { + implicit val breakFlagPersistence: BreakFlagPersistence[F] = new JdbcBreakFlagPersistence[F] + + for { + breakFlagRepositoryControls <- BukkitRepositoryControls.createHandles( + BreakFlagRepositoryDefinition.withContext + ) + } yield { + val breakFlagRepository = breakFlagRepositoryControls.repository + + } + } + +} diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/application/repository/BreakFlagRepositoryDefinition.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/application/repository/BreakFlagRepositoryDefinition.scala index 5994ab6945..e540b766c8 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/application/repository/BreakFlagRepositoryDefinition.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/application/repository/BreakFlagRepositoryDefinition.scala @@ -9,7 +9,7 @@ import com.github.unchama.seichiassist.subsystems.breakflags.domain.{BreakFlag, object BreakFlagRepositoryDefinition { def withContext[F[_]: Sync, Player]( - persistence: BreakFlagPersistence[F] + implicit persistence: BreakFlagPersistence[F] ): RepositoryDefinition[F, Player, Ref[F, List[BreakFlag]]] = RefDictBackedRepositoryDefinition .usingUuidRefDict[F, Player, List[BreakFlag]](persistence)(List.empty) From ac85894ecd2cd91a227c8be06f50741df06b5755 Mon Sep 17 00:00:00 2001 From: rito528 Date: Wed, 31 May 2023 23:35:04 +0900 Subject: [PATCH 08/59] =?UTF-8?q?feat:=20System=E3=81=AE=E5=AE=9A=E7=BE=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../subsystems/breakflags/BreakFlagAPI.scala | 14 ++++---- .../subsystems/breakflags/System.scala | 33 ++++++++++++++++--- 2 files changed, 34 insertions(+), 13 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/BreakFlagAPI.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/BreakFlagAPI.scala index d19c6d4702..34893812fb 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/BreakFlagAPI.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/BreakFlagAPI.scala @@ -1,30 +1,28 @@ package com.github.unchama.seichiassist.subsystems.breakflags -import com.github.unchama.seichiassist.subsystems.breakflags.domain.BreakFlag +import com.github.unchama.seichiassist.subsystems.breakflags.domain.{BreakFlag, BreakFlagName} -import java.util.UUID - -trait BreakFlagAPI[F[_]] { +trait BreakFlagAPI[F[_], Player] { /** * @return 破壊フラグを有効にする作用 */ - def turnOnBreakFlag(player: UUID, breakFlag: BreakFlag): F[Unit] + def turnOnBreakFlag(player: Player, breakFlagName: BreakFlagName): F[Unit] /** * @return 破壊フラグを無効にする作用 */ - def turnOffBreakFlag(player: UUID, breakFlag: BreakFlag): F[Unit] + def turnOffBreakFlag(player: Player, breakFlagName: BreakFlagName): F[Unit] /** * @return 現在の破壊フラグを取得する作用 */ - def breakFlag(player: UUID): F[BreakFlag] + def breakFlag(player: Player, breakFlagName: BreakFlagName): F[Boolean] } object BreakFlagAPI { - def apply[F[_]](implicit ev: BreakFlagAPI[F]): BreakFlagAPI[F] = ev + def apply[F[_], Player](implicit ev: BreakFlagAPI[F, Player]): BreakFlagAPI[F, Player] = ev } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/System.scala index 48c2e5bb42..5801af26f8 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/System.scala @@ -1,21 +1,22 @@ package com.github.unchama.seichiassist.subsystems.breakflags -import cats.effect.{Sync, SyncEffect} +import cats.effect.SyncEffect import com.github.unchama.datarepository.bukkit.player.BukkitRepositoryControls import com.github.unchama.seichiassist.meta.subsystem.Subsystem import com.github.unchama.seichiassist.subsystems.breakflags.application.repository.BreakFlagRepositoryDefinition -import com.github.unchama.seichiassist.subsystems.breakflags.domain.BreakFlagPersistence +import com.github.unchama.seichiassist.subsystems.breakflags.domain.{BreakFlag, BreakFlagName, BreakFlagPersistence} import com.github.unchama.seichiassist.subsystems.breakflags.persistence.JdbcBreakFlagPersistence +import org.bukkit.entity.Player -trait System[F[_]] extends Subsystem[F] { - +trait System[F[_], Player] extends Subsystem[F] { + val api: BreakFlagAPI[F, Player] } object System { import cats.implicits._ - def wired[F[_]: SyncEffect]: F[System[F]] = { + def wired[F[_]: SyncEffect]: F[System[F, Player]] = { implicit val breakFlagPersistence: BreakFlagPersistence[F] = new JdbcBreakFlagPersistence[F] for { @@ -25,6 +26,28 @@ object System { } yield { val breakFlagRepository = breakFlagRepositoryControls.repository + new System[F, Player] { + override val api: BreakFlagAPI[F, Player] = new BreakFlagAPI[F, Player] { + override def turnOnBreakFlag(player: Player, breakFlagName: BreakFlagName): F[Unit] = + breakFlagRepository(player).update { breakFlags => + breakFlags.filterNot(_.flagName == breakFlagName) :+ BreakFlag(breakFlagName, flag = true) + } + + override def turnOffBreakFlag(player: Player, breakFlagName: BreakFlagName): F[Unit] = + breakFlagRepository(player).update { breakFlags => + breakFlags.filterNot(_.flagName == breakFlagName) :+ BreakFlag(breakFlagName, flag = false) + } + + override def breakFlag(player: Player, breakFlagName: BreakFlagName): F[Boolean] = for { + flags <- breakFlagRepository(player).get + } yield { + flags.find(_.flagName == breakFlagName) match { + case Some(value) => value.flag + case None => true // 破壊フラグのデフォルト値はtrue(破壊する) + } + } + } + } } } From df225ab853f6052f195db98f96559ba718a04d9a Mon Sep 17 00:00:00 2001 From: rito528 Date: Wed, 31 May 2023 23:43:03 +0900 Subject: [PATCH 09/59] =?UTF-8?q?feat:=20System=E3=82=92SeichiAssist?= =?UTF-8?q?=E5=81=B4=E3=81=AB=E5=AE=9A=E7=BE=A9=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../unchama/seichiassist/SeichiAssist.scala | 6 +++++- .../subsystems/breakflags/System.scala | 19 ++++++++++--------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala b/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala index c4e3375fca..84420ae754 100644 --- a/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala +++ b/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala @@ -480,6 +480,9 @@ class SeichiAssist extends JavaPlugin() { subsystems.vote.subsystems.fairyspeech.System.wired[IO] } + private lazy val breakFlagSystem: subsystems.breakflags.System[IO, Player] = + subsystems.breakflags.System.wired[IO, SyncIO].unsafeRunSync() + /* TODO: mineStackSystemは本来privateであるべきだが、mineStackにアイテムを格納するAPIが現状の BreakUtilの実装から呼び出されている都合上やむを得ずpublicになっている。*/ lazy val mineStackSystem: subsystems.minestack.System[IO, Player, ItemStack] = @@ -520,7 +523,8 @@ class SeichiAssist extends JavaPlugin() { sharedInventorySystem, mineStackSystem, consumeGachaTicketSystem, - openirontrapdoor.System.wired + openirontrapdoor.System.wired, + breakFlagSystem ) private lazy val buildAssist: BuildAssist = { diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/System.scala index 5801af26f8..fe0874704d 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/System.scala @@ -2,6 +2,7 @@ package com.github.unchama.seichiassist.subsystems.breakflags import cats.effect.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.breakflags.application.repository.BreakFlagRepositoryDefinition import com.github.unchama.seichiassist.subsystems.breakflags.domain.{BreakFlag, BreakFlagName, BreakFlagPersistence} @@ -16,12 +17,12 @@ object System { import cats.implicits._ - def wired[F[_]: SyncEffect]: F[System[F, Player]] = { - implicit val breakFlagPersistence: BreakFlagPersistence[F] = new JdbcBreakFlagPersistence[F] + def wired[F[_], G[_]: SyncEffect: ContextCoercion[*[_], F]]: G[System[F, Player]] = { + implicit val breakFlagPersistence: BreakFlagPersistence[G] = new JdbcBreakFlagPersistence[G] for { breakFlagRepositoryControls <- BukkitRepositoryControls.createHandles( - BreakFlagRepositoryDefinition.withContext + BreakFlagRepositoryDefinition.withContext[G, Player] ) } yield { val breakFlagRepository = breakFlagRepositoryControls.repository @@ -29,23 +30,23 @@ object System { new System[F, Player] { override val api: BreakFlagAPI[F, Player] = new BreakFlagAPI[F, Player] { override def turnOnBreakFlag(player: Player, breakFlagName: BreakFlagName): F[Unit] = - breakFlagRepository(player).update { breakFlags => + ContextCoercion(breakFlagRepository(player).update { breakFlags => breakFlags.filterNot(_.flagName == breakFlagName) :+ BreakFlag(breakFlagName, flag = true) - } + }) override def turnOffBreakFlag(player: Player, breakFlagName: BreakFlagName): F[Unit] = - breakFlagRepository(player).update { breakFlags => + ContextCoercion(breakFlagRepository(player).update { breakFlags => breakFlags.filterNot(_.flagName == breakFlagName) :+ BreakFlag(breakFlagName, flag = false) - } + }) - override def breakFlag(player: Player, breakFlagName: BreakFlagName): F[Boolean] = for { + override def breakFlag(player: Player, breakFlagName: BreakFlagName): F[Boolean] = ContextCoercion(for { flags <- breakFlagRepository(player).get } yield { flags.find(_.flagName == breakFlagName) match { case Some(value) => value.flag case None => true // 破壊フラグのデフォルト値はtrue(破壊する) } - } + }) } } } From 69dd416824a3bea8169ceeb0bcbdeb260a4b9f48 Mon Sep 17 00:00:00 2001 From: rito528 Date: Wed, 31 May 2023 23:46:58 +0900 Subject: [PATCH 10/59] style: apply scalafmt and scalafix --- .../subsystems/breakflags/BreakFlagAPI.scala | 2 +- .../subsystems/breakflags/System.scala | 31 +++++++++++------ .../BreakFlagRepositoryDefinition.scala | 5 ++- .../JdbcBreakFlagPersistence.scala | 34 +++++++++---------- 4 files changed, 41 insertions(+), 31 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/BreakFlagAPI.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/BreakFlagAPI.scala index 34893812fb..7e817c5644 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/BreakFlagAPI.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/BreakFlagAPI.scala @@ -1,6 +1,6 @@ package com.github.unchama.seichiassist.subsystems.breakflags -import com.github.unchama.seichiassist.subsystems.breakflags.domain.{BreakFlag, BreakFlagName} +import com.github.unchama.seichiassist.subsystems.breakflags.domain.BreakFlagName trait BreakFlagAPI[F[_], Player] { diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/System.scala index fe0874704d..8da0982493 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/System.scala @@ -5,7 +5,11 @@ 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.breakflags.application.repository.BreakFlagRepositoryDefinition -import com.github.unchama.seichiassist.subsystems.breakflags.domain.{BreakFlag, BreakFlagName, BreakFlagPersistence} +import com.github.unchama.seichiassist.subsystems.breakflags.domain.{ + BreakFlag, + BreakFlagName, + BreakFlagPersistence +} import com.github.unchama.seichiassist.subsystems.breakflags.persistence.JdbcBreakFlagPersistence import org.bukkit.entity.Player @@ -31,22 +35,27 @@ object System { override val api: BreakFlagAPI[F, Player] = new BreakFlagAPI[F, Player] { override def turnOnBreakFlag(player: Player, breakFlagName: BreakFlagName): F[Unit] = ContextCoercion(breakFlagRepository(player).update { breakFlags => - breakFlags.filterNot(_.flagName == breakFlagName) :+ BreakFlag(breakFlagName, flag = true) + breakFlags + .filterNot(_.flagName == breakFlagName) :+ BreakFlag(breakFlagName, flag = true) }) override def turnOffBreakFlag(player: Player, breakFlagName: BreakFlagName): F[Unit] = ContextCoercion(breakFlagRepository(player).update { breakFlags => - breakFlags.filterNot(_.flagName == breakFlagName) :+ BreakFlag(breakFlagName, flag = false) + breakFlags.filterNot(_.flagName == breakFlagName) :+ BreakFlag( + breakFlagName, + flag = false + ) }) - override def breakFlag(player: Player, breakFlagName: BreakFlagName): F[Boolean] = ContextCoercion(for { - flags <- breakFlagRepository(player).get - } yield { - flags.find(_.flagName == breakFlagName) match { - case Some(value) => value.flag - case None => true // 破壊フラグのデフォルト値はtrue(破壊する) - } - }) + override def breakFlag(player: Player, breakFlagName: BreakFlagName): F[Boolean] = + ContextCoercion(for { + flags <- breakFlagRepository(player).get + } yield { + flags.find(_.flagName == breakFlagName) match { + case Some(value) => value.flag + case None => true // 破壊フラグのデフォルト値はtrue(破壊する) + } + }) } } } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/application/repository/BreakFlagRepositoryDefinition.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/application/repository/BreakFlagRepositoryDefinition.scala index e540b766c8..384868125f 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/application/repository/BreakFlagRepositoryDefinition.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/application/repository/BreakFlagRepositoryDefinition.scala @@ -4,7 +4,10 @@ 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.breakflags.domain.{BreakFlag, BreakFlagPersistence} +import com.github.unchama.seichiassist.subsystems.breakflags.domain.{ + BreakFlag, + BreakFlagPersistence +} object BreakFlagRepositoryDefinition { diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/persistence/JdbcBreakFlagPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/persistence/JdbcBreakFlagPersistence.scala index 9801a6383f..394f6fbbbf 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/persistence/JdbcBreakFlagPersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/persistence/JdbcBreakFlagPersistence.scala @@ -1,7 +1,11 @@ package com.github.unchama.seichiassist.subsystems.breakflags.persistence import cats.effect.Sync -import com.github.unchama.seichiassist.subsystems.breakflags.domain.{BreakFlag, BreakFlagName, BreakFlagPersistence} +import com.github.unchama.seichiassist.subsystems.breakflags.domain.{ + BreakFlag, + BreakFlagName, + BreakFlagPersistence +} import scalikejdbc.{DB, scalikejdbcSQLInterpolationImplicitDef} import java.util.UUID @@ -9,17 +13,16 @@ import java.util.UUID class JdbcBreakFlagPersistence[F[_]: Sync] extends BreakFlagPersistence[F] { override def read(key: UUID): F[Option[List[BreakFlag]]] = Sync[F].delay { DB.readOnly { implicit session => - val breakFlags = sql"SELECT flag_name, can_break FROM break_flags WHERE uuid = ${key.toString}" - .map { rs => - BreakFlagName.withNameOption(rs.string("flag_name")).map { flagName => - BreakFlag(flagName, rs.boolean("can_break")) + val breakFlags = + sql"SELECT flag_name, can_break FROM break_flags WHERE uuid = ${key.toString}" + .map { rs => + BreakFlagName.withNameOption(rs.string("flag_name")).map { flagName => + BreakFlag(flagName, rs.boolean("can_break")) + } } - } - .toList() - .apply() - .collect { - case Some(flag) => flag - } + .toList() + .apply() + .collect { case Some(flag) => flag } Some(breakFlags) } @@ -28,18 +31,13 @@ class JdbcBreakFlagPersistence[F[_]: Sync] extends BreakFlagPersistence[F] { override def write(key: UUID, value: List[BreakFlag]): F[Unit] = Sync[F].delay { DB.localTx { implicit session => val uuid = key.toString - val batchParams = value.map { flag => - Seq(uuid, flag.flagName.entryName, flag.flag) - } + val batchParams = value.map { flag => Seq(uuid, flag.flagName.entryName, flag.flag) } sql"""INSERT INTO break_flags (uuid, flag_name, can_break) | VALUES (?, ?, ?) | ON DUPLICATE KEY UPDATE | can_break = VALUE(can_break) - """ - .stripMargin - .batch(batchParams: _*) - .apply[List] + """.stripMargin.batch(batchParams: _*).apply[List] } } From 209f20bd4346c810db41e77e4d03bfa2408f4a8a Mon Sep 17 00:00:00 2001 From: rito528 Date: Wed, 31 May 2023 23:57:07 +0900 Subject: [PATCH 11/59] =?UTF-8?q?feat:=20BreakFlagAPI=E3=81=ABtoggle?= =?UTF-8?q?=E7=94=A8=E9=96=A2=E6=95=B0=E3=82=92=E7=94=A8=E6=84=8F=E3=81=99?= =?UTF-8?q?=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../subsystems/breakflags/BreakFlagAPI.scala | 9 ++----- .../subsystems/breakflags/System.scala | 27 +++++++++---------- 2 files changed, 14 insertions(+), 22 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/BreakFlagAPI.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/BreakFlagAPI.scala index 7e817c5644..cd37e5ba4e 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/BreakFlagAPI.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/BreakFlagAPI.scala @@ -5,14 +5,9 @@ import com.github.unchama.seichiassist.subsystems.breakflags.domain.BreakFlagNam trait BreakFlagAPI[F[_], Player] { /** - * @return 破壊フラグを有効にする作用 + * @return 破壊フラグをトグルする作用 */ - def turnOnBreakFlag(player: Player, breakFlagName: BreakFlagName): F[Unit] - - /** - * @return 破壊フラグを無効にする作用 - */ - def turnOffBreakFlag(player: Player, breakFlagName: BreakFlagName): F[Unit] + def toggleBreakFlag(player: Player, breakFlagName: BreakFlagName): F[Unit] /** * @return 現在の破壊フラグを取得する作用 diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/System.scala index 8da0982493..6b8cbb3a2d 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/System.scala @@ -1,6 +1,6 @@ package com.github.unchama.seichiassist.subsystems.breakflags -import cats.effect.SyncEffect +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 @@ -21,7 +21,7 @@ object System { import cats.implicits._ - def wired[F[_], G[_]: SyncEffect: ContextCoercion[*[_], F]]: G[System[F, Player]] = { + def wired[F[_]: Sync, G[_]: SyncEffect: ContextCoercion[*[_], F]]: G[System[F, Player]] = { implicit val breakFlagPersistence: BreakFlagPersistence[G] = new JdbcBreakFlagPersistence[G] for { @@ -33,19 +33,16 @@ object System { new System[F, Player] { override val api: BreakFlagAPI[F, Player] = new BreakFlagAPI[F, Player] { - override def turnOnBreakFlag(player: Player, breakFlagName: BreakFlagName): F[Unit] = - ContextCoercion(breakFlagRepository(player).update { breakFlags => - breakFlags - .filterNot(_.flagName == breakFlagName) :+ BreakFlag(breakFlagName, flag = true) - }) - - override def turnOffBreakFlag(player: Player, breakFlagName: BreakFlagName): F[Unit] = - ContextCoercion(breakFlagRepository(player).update { breakFlags => - breakFlags.filterNot(_.flagName == breakFlagName) :+ BreakFlag( - breakFlagName, - flag = false - ) - }) + override def toggleBreakFlag(player: Player, breakFlagName: BreakFlagName): F[Unit] = + for { + breakFlag <- breakFlag(player, breakFlagName) + _ <- ContextCoercion(breakFlagRepository(player).update { breakFlags => + breakFlags.filterNot(_.flagName == breakFlagName) :+ BreakFlag( + breakFlagName, + flag = !breakFlag + ) + }) + } yield () override def breakFlag(player: Player, breakFlagName: BreakFlagName): F[Boolean] = ContextCoercion(for { From 38cf6318dc82cf8369726423b6e364dd0b71a688 Mon Sep 17 00:00:00 2001 From: rito528 Date: Thu, 1 Jun 2023 00:36:50 +0900 Subject: [PATCH 12/59] =?UTF-8?q?refactor:=20=E5=8F=A4=E3=81=84=E3=83=95?= =?UTF-8?q?=E3=83=A9=E3=82=B0=E3=82=92=E6=96=B0=E3=82=B7=E3=82=B9=E3=83=86?= =?UTF-8?q?=E3=83=A0=E3=81=AB=E7=BD=AE=E3=81=8D=E6=8F=9B=E3=81=88=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../unchama/seichiassist/SeichiAssist.scala | 4 ++- .../seichiassist/data/player/PlayerData.scala | 20 ------------ .../menus/skill/PassiveSkillMenu.scala | 32 +++++++++++-------- .../subsystems/breakflags/BreakFlagAPI.scala | 3 +- .../subsystems/breakflags/System.scala | 10 +++--- .../unchama/seichiassist/util/BreakUtil.scala | 11 +++---- 6 files changed, 32 insertions(+), 48 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala b/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala index 84420ae754..c69886971d 100644 --- a/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala +++ b/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala @@ -480,7 +480,9 @@ class SeichiAssist extends JavaPlugin() { subsystems.vote.subsystems.fairyspeech.System.wired[IO] } - private lazy val breakFlagSystem: subsystems.breakflags.System[IO, Player] = + /* TODO: breakFlagSystemは本来privateであるべきだが、 + BreakUtilで呼び出されているため、やむを得ずpublicになっている */ + lazy val breakFlagSystem: subsystems.breakflags.System[IO, Player] = subsystems.breakflags.System.wired[IO, SyncIO].unsafeRunSync() /* TODO: mineStackSystemは本来privateであるべきだが、mineStackにアイテムを格納するAPIが現状の 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/skill/PassiveSkillMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/skill/PassiveSkillMenu.scala index f725c54f68..d273f4ea33 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.breakflags.BreakFlagAPI +import com.github.unchama.seichiassist.subsystems.breakflags.domain.BreakFlagName 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 breakFlagAPI: BreakFlagAPI[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 { + chestFlag <- breakFlagAPI.breakFlag(player, BreakFlagName.Chest) + } yield { val baseLore = List(s"${GREEN}スキルでチェストを破壊するスキル") - val statusLore = if (openerData.chestflag) { + val statusLore = if (chestFlag) { 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 (chestFlag) Material.DIAMOND_AXE else Material.CHEST Button( new IconItemStackBuilder(material) @@ -159,9 +165,9 @@ object PassiveSkillMenu extends Menu { .build(), LeftClickButtonEffect { SequentialEffect( - openerData.toggleChestBreakFlag, + DeferredEffect(IO(breakFlagAPI.toggleBreakFlag(BreakFlagName.Chest))), DeferredEffect(IO { - if (openerData.chestflag) { + if (chestFlag) { SequentialEffect( MessageEffect(s"${GREEN}スキルでのチェスト破壊を有効化しました。"), FocusedSoundEffect(Sound.BLOCK_STONE_BUTTON_CLICK_ON, 1f, 1f) @@ -178,11 +184,11 @@ object PassiveSkillMenu extends Menu { ) }) - val computeToggleNetherQuartzBlockButton: IO[Button] = RecomputedButton(IO { - val openerData = SeichiAssist.playermap(getUniqueId) - + val computeToggleNetherQuartzBlockButton: IO[Button] = RecomputedButton(for { + quartzBreakFlag <- breakFlagAPI.breakFlag(player, BreakFlagName.NetherQuartz) + } yield { val baseLore = List(s"${YELLOW}スキルでネザー水晶類ブロックを破壊するスキル") - val statusLore = if (openerData.netherQuartzBlockflag) { + val statusLore = if (quartzBreakFlag) { List(s"${GREEN}ON (スキルでネザー水晶類ブロックを破壊します。)", s"${DARK_RED}クリックでOFF") } else { List(s"${RED}OFF (スキルでネザー水晶類ブロックを破壊しません。)", s"${DARK_GREEN}クリックでON") @@ -191,7 +197,7 @@ object PassiveSkillMenu extends Menu { Button( new IconItemStackBuilder(Material.QUARTZ_BLOCK) .tap { builder => - if (openerData.netherQuartzBlockflag) + if (quartzBreakFlag) builder.enchanted() } .title(s"$WHITE$UNDERLINE${BOLD}ネザー水晶類ブロック破壊スキル切り替え") @@ -199,9 +205,9 @@ object PassiveSkillMenu extends Menu { .build(), LeftClickButtonEffect { SequentialEffect( - openerData.toggleNetherQuartzBlockBreakFlag, + DeferredEffect(IO(breakFlagAPI.toggleBreakFlag(BreakFlagName.NetherQuartz))), DeferredEffect(IO { - if (openerData.netherQuartzBlockflag) { + if (quartzBreakFlag) { SequentialEffect( MessageEffect(s"${GREEN}スキルでのネザー水晶類ブロック破壊を有効化しました。"), FocusedSoundEffect(Sound.BLOCK_STONE_BUTTON_CLICK_ON, 1f, 1f) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/BreakFlagAPI.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/BreakFlagAPI.scala index cd37e5ba4e..ef1bd9cc8e 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/BreakFlagAPI.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/BreakFlagAPI.scala @@ -1,5 +1,6 @@ package com.github.unchama.seichiassist.subsystems.breakflags +import cats.data.Kleisli import com.github.unchama.seichiassist.subsystems.breakflags.domain.BreakFlagName trait BreakFlagAPI[F[_], Player] { @@ -7,7 +8,7 @@ trait BreakFlagAPI[F[_], Player] { /** * @return 破壊フラグをトグルする作用 */ - def toggleBreakFlag(player: Player, breakFlagName: BreakFlagName): F[Unit] + def toggleBreakFlag(breakFlagName: BreakFlagName): Kleisli[F, Player, Unit] /** * @return 現在の破壊フラグを取得する作用 diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/System.scala index 6b8cbb3a2d..e313d23b89 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/System.scala @@ -1,15 +1,12 @@ package com.github.unchama.seichiassist.subsystems.breakflags +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.breakflags.application.repository.BreakFlagRepositoryDefinition -import com.github.unchama.seichiassist.subsystems.breakflags.domain.{ - BreakFlag, - BreakFlagName, - BreakFlagPersistence -} +import com.github.unchama.seichiassist.subsystems.breakflags.domain.{BreakFlag, BreakFlagName, BreakFlagPersistence} import com.github.unchama.seichiassist.subsystems.breakflags.persistence.JdbcBreakFlagPersistence import org.bukkit.entity.Player @@ -33,7 +30,7 @@ object System { new System[F, Player] { override val api: BreakFlagAPI[F, Player] = new BreakFlagAPI[F, Player] { - override def toggleBreakFlag(player: Player, breakFlagName: BreakFlagName): F[Unit] = + override def toggleBreakFlag(breakFlagName: BreakFlagName): Kleisli[F, Player, Unit] = Kleisli { player => for { breakFlag <- breakFlag(player, breakFlagName) _ <- ContextCoercion(breakFlagRepository(player).update { breakFlags => @@ -43,6 +40,7 @@ object System { ) }) } yield () + } override def breakFlag(player: Player, breakFlagName: BreakFlagName): F[Boolean] = ContextCoercion(for { 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..838628fcaa 100644 --- a/src/main/scala/com/github/unchama/seichiassist/util/BreakUtil.scala +++ b/src/main/scala/com/github/unchama/seichiassist/util/BreakUtil.scala @@ -8,14 +8,11 @@ import com.github.unchama.seichiassist.MaterialSets.{BlockBreakableBySkill, Brea import com.github.unchama.seichiassist._ import com.github.unchama.seichiassist.concurrent.PluginExecutionContexts import com.github.unchama.seichiassist.seichiskill.ActiveSkillRange._ -import com.github.unchama.seichiassist.seichiskill.SeichiSkill.{ - AssaultArmor, - DualBreak, - TrialBreak -} +import com.github.unchama.seichiassist.seichiskill.SeichiSkill.{AssaultArmor, DualBreak, TrialBreak} 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.breakflags.domain.BreakFlagName import com.github.unchama.targetedeffect.player.ActionBarMessageEffect import com.github.unchama.util.bukkit.ItemStackUtil import com.github.unchama.util.external.ExternalPlugins @@ -126,7 +123,7 @@ 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.breakFlagSystem.api.breakFlag(player, BreakFlagName.Chest).unsafeRunSync()) { ActionBarMessageEffect(s"${RED}スキルでのチェスト破壊は無効化されています").run(player).unsafeRunSync() true } else if (!player.getWorld.isSeichi) { @@ -143,7 +140,7 @@ object BreakUtil { checkTarget.getType match { // 鉱石ブロックの方はプロテクトの対象外 case Material.QUARTZ_BLOCK | Material.QUARTZ_STAIRS => - if (!SeichiAssist.playermap(player.getUniqueId).netherQuartzBlockflag) { + if (!SeichiAssist.instance.breakFlagSystem.api.breakFlag(player, BreakFlagName.NetherQuartz).unsafeRunSync()) { ActionBarMessageEffect(s"${RED}スキルでのネザー水晶類ブロックの破壊は無効化されています") .run(player) .unsafeRunSync() From 52fd5dc21c642d9b9bba1027eb341ca83fdc3df4 Mon Sep 17 00:00:00 2001 From: rito528 Date: Thu, 1 Jun 2023 00:41:38 +0900 Subject: [PATCH 13/59] =?UTF-8?q?fix:=20TopLevelRouter=E3=81=ABbreakFlagSy?= =?UTF-8?q?stemAPI=E3=82=92=E6=B8=A1=E3=81=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../unchama/seichiassist/SeichiAssist.scala | 2 ++ .../seichiassist/menus/TopLevelRouter.scala | 4 ++- .../menus/skill/PassiveSkillMenu.scala | 7 ++--- .../subsystems/breakflags/System.scala | 29 +++++++++++-------- .../unchama/seichiassist/util/BreakUtil.scala | 24 +++++++++++++-- 5 files changed, 46 insertions(+), 20 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala b/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala index c69886971d..8c5f89a3a8 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.breakflags.BreakFlagAPI import com.github.unchama.seichiassist.subsystems.buildcount.BuildCountAPI import com.github.unchama.seichiassist.subsystems.discordnotification.DiscordNotificationAPI import com.github.unchama.seichiassist.subsystems.donate.DonatePremiumPointAPI @@ -701,6 +702,7 @@ class SeichiAssist extends JavaPlugin() { implicit val gachaAPI: GachaDrawAPI[IO, Player] = gachaSystem.api implicit val consumeGachaTicketAPI: ConsumeGachaTicketAPI[IO, Player] = consumeGachaTicketSystem.api + implicit val breakFlagAPI: BreakFlagAPI[IO, Player] = breakFlagSystem.api val menuRouter = TopLevelRouter.apply import SeichiAssist.Scopes.globalChatInterceptionScope 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..ffd8c1febf 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.breakflags.BreakFlagAPI 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], + breakFlagAPI: BreakFlagAPI[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 d273f4ea33..aa15884d55 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 @@ -146,10 +146,9 @@ object PassiveSkillMenu extends Menu { import environment._ - val computeToggleChestBreakButton: IO[Button] = RecomputedButton( - for { - chestFlag <- breakFlagAPI.breakFlag(player, BreakFlagName.Chest) - } yield { + val computeToggleChestBreakButton: IO[Button] = RecomputedButton(for { + chestFlag <- breakFlagAPI.breakFlag(player, BreakFlagName.Chest) + } yield { val baseLore = List(s"${GREEN}スキルでチェストを破壊するスキル") val statusLore = if (chestFlag) { List(s"${RED}整地ワールドのみで発動中(デフォルト)", "", s"$DARK_GREEN${UNDERLINE}クリックで切り替え") diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/System.scala index e313d23b89..19cb575881 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/System.scala @@ -6,7 +6,11 @@ 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.breakflags.application.repository.BreakFlagRepositoryDefinition -import com.github.unchama.seichiassist.subsystems.breakflags.domain.{BreakFlag, BreakFlagName, BreakFlagPersistence} +import com.github.unchama.seichiassist.subsystems.breakflags.domain.{ + BreakFlag, + BreakFlagName, + BreakFlagPersistence +} import com.github.unchama.seichiassist.subsystems.breakflags.persistence.JdbcBreakFlagPersistence import org.bukkit.entity.Player @@ -30,17 +34,18 @@ object System { new System[F, Player] { override val api: BreakFlagAPI[F, Player] = new BreakFlagAPI[F, Player] { - override def toggleBreakFlag(breakFlagName: BreakFlagName): Kleisli[F, Player, Unit] = Kleisli { player => - for { - breakFlag <- breakFlag(player, breakFlagName) - _ <- ContextCoercion(breakFlagRepository(player).update { breakFlags => - breakFlags.filterNot(_.flagName == breakFlagName) :+ BreakFlag( - breakFlagName, - flag = !breakFlag - ) - }) - } yield () - } + override def toggleBreakFlag(breakFlagName: BreakFlagName): Kleisli[F, Player, Unit] = + Kleisli { player => + for { + breakFlag <- breakFlag(player, breakFlagName) + _ <- ContextCoercion(breakFlagRepository(player).update { breakFlags => + breakFlags.filterNot(_.flagName == breakFlagName) :+ BreakFlag( + breakFlagName, + flag = !breakFlag + ) + }) + } yield () + } override def breakFlag(player: Player, breakFlagName: BreakFlagName): F[Boolean] = ContextCoercion(for { 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 838628fcaa..cafe8f61bc 100644 --- a/src/main/scala/com/github/unchama/seichiassist/util/BreakUtil.scala +++ b/src/main/scala/com/github/unchama/seichiassist/util/BreakUtil.scala @@ -8,7 +8,11 @@ import com.github.unchama.seichiassist.MaterialSets.{BlockBreakableBySkill, Brea import com.github.unchama.seichiassist._ import com.github.unchama.seichiassist.concurrent.PluginExecutionContexts import com.github.unchama.seichiassist.seichiskill.ActiveSkillRange._ -import com.github.unchama.seichiassist.seichiskill.SeichiSkill.{AssaultArmor, DualBreak, TrialBreak} +import com.github.unchama.seichiassist.seichiskill.SeichiSkill.{ + AssaultArmor, + DualBreak, + TrialBreak +} 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 @@ -123,7 +127,14 @@ object BreakUtil { def isProtectedChest(player: Player, checkTarget: Block): Boolean = { checkTarget.getType match { case Material.CHEST | Material.TRAPPED_CHEST => - if (!SeichiAssist.instance.breakFlagSystem.api.breakFlag(player, BreakFlagName.Chest).unsafeRunSync()) { + if ( + !SeichiAssist + .instance + .breakFlagSystem + .api + .breakFlag(player, BreakFlagName.Chest) + .unsafeRunSync() + ) { ActionBarMessageEffect(s"${RED}スキルでのチェスト破壊は無効化されています").run(player).unsafeRunSync() true } else if (!player.getWorld.isSeichi) { @@ -140,7 +151,14 @@ object BreakUtil { checkTarget.getType match { // 鉱石ブロックの方はプロテクトの対象外 case Material.QUARTZ_BLOCK | Material.QUARTZ_STAIRS => - if (!SeichiAssist.instance.breakFlagSystem.api.breakFlag(player, BreakFlagName.NetherQuartz).unsafeRunSync()) { + if ( + !SeichiAssist + .instance + .breakFlagSystem + .api + .breakFlag(player, BreakFlagName.NetherQuartz) + .unsafeRunSync() + ) { ActionBarMessageEffect(s"${RED}スキルでのネザー水晶類ブロックの破壊は無効化されています") .run(player) .unsafeRunSync() From 87c74b1595809e57b2fdb5c390aafe6c6fa68913 Mon Sep 17 00:00:00 2001 From: rito528 Date: Thu, 1 Jun 2023 13:52:11 +0900 Subject: [PATCH 14/59] =?UTF-8?q?style:=20subsystem=E5=90=8D=E3=82=92break?= =?UTF-8?q?skilltargetconfig=E3=81=AB=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/github/unchama/seichiassist/SeichiAssist.scala | 6 +++--- .../unchama/seichiassist/menus/TopLevelRouter.scala | 2 +- .../seichiassist/menus/skill/PassiveSkillMenu.scala | 4 ++-- .../subsystems/breakflags/domain/BreakFlag.scala | 3 --- .../BreakFlagAPI.scala | 4 ++-- .../{breakflags => breakskilltargetconfig}/System.scala | 8 ++++---- .../repository/BreakFlagRepositoryDefinition.scala | 4 ++-- .../breakskilltargetconfig/domain/BreakFlag.scala | 3 +++ .../domain/BreakFlagName.scala | 2 +- .../domain/BreakFlagPersistence.scala | 2 +- .../persistence/JdbcBreakFlagPersistence.scala | 4 ++-- .../com/github/unchama/seichiassist/util/BreakUtil.scala | 2 +- 12 files changed, 22 insertions(+), 22 deletions(-) delete mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/domain/BreakFlag.scala rename src/main/scala/com/github/unchama/seichiassist/subsystems/{breakflags => breakskilltargetconfig}/BreakFlagAPI.scala (73%) rename src/main/scala/com/github/unchama/seichiassist/subsystems/{breakflags => breakskilltargetconfig}/System.scala (83%) rename src/main/scala/com/github/unchama/seichiassist/subsystems/{breakflags => breakskilltargetconfig}/application/repository/BreakFlagRepositoryDefinition.scala (76%) create mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/domain/BreakFlag.scala rename src/main/scala/com/github/unchama/seichiassist/subsystems/{breakflags => breakskilltargetconfig}/domain/BreakFlagName.scala (87%) rename src/main/scala/com/github/unchama/seichiassist/subsystems/{breakflags => breakskilltargetconfig}/domain/BreakFlagPersistence.scala (63%) rename src/main/scala/com/github/unchama/seichiassist/subsystems/{breakflags => breakskilltargetconfig}/persistence/JdbcBreakFlagPersistence.scala (88%) diff --git a/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala b/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala index 8c5f89a3a8..3855f0785d 100644 --- a/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala +++ b/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala @@ -61,7 +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.breakflags.BreakFlagAPI +import com.github.unchama.seichiassist.subsystems.breakskilltargetconfig.BreakFlagAPI import com.github.unchama.seichiassist.subsystems.buildcount.BuildCountAPI import com.github.unchama.seichiassist.subsystems.discordnotification.DiscordNotificationAPI import com.github.unchama.seichiassist.subsystems.donate.DonatePremiumPointAPI @@ -483,8 +483,8 @@ class SeichiAssist extends JavaPlugin() { /* TODO: breakFlagSystemは本来privateであるべきだが、 BreakUtilで呼び出されているため、やむを得ずpublicになっている */ - lazy val breakFlagSystem: subsystems.breakflags.System[IO, Player] = - subsystems.breakflags.System.wired[IO, SyncIO].unsafeRunSync() + lazy val breakFlagSystem: subsystems.breakskilltargetconfig.System[IO, Player] = + subsystems.breakskilltargetconfig.System.wired[IO, SyncIO].unsafeRunSync() /* TODO: mineStackSystemは本来privateであるべきだが、mineStackにアイテムを格納するAPIが現状の BreakUtilの実装から呼び出されている都合上やむを得ずpublicになっている。*/ 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 ffd8c1febf..960d53195d 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/TopLevelRouter.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/TopLevelRouter.scala @@ -29,7 +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.breakflags.BreakFlagAPI +import com.github.unchama.seichiassist.subsystems.breakskilltargetconfig.BreakFlagAPI 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 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 aa15884d55..73dbf5182d 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,8 +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.breakflags.BreakFlagAPI -import com.github.unchama.seichiassist.subsystems.breakflags.domain.BreakFlagName +import com.github.unchama.seichiassist.subsystems.breakskilltargetconfig.BreakFlagAPI +import com.github.unchama.seichiassist.subsystems.breakskilltargetconfig.domain.BreakFlagName import com.github.unchama.targetedeffect._ import com.github.unchama.targetedeffect.commandsender.MessageEffect import com.github.unchama.targetedeffect.player.FocusedSoundEffect diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/domain/BreakFlag.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/domain/BreakFlag.scala deleted file mode 100644 index cc86666143..0000000000 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/domain/BreakFlag.scala +++ /dev/null @@ -1,3 +0,0 @@ -package com.github.unchama.seichiassist.subsystems.breakflags.domain - -case class BreakFlag(flagName: BreakFlagName, flag: Boolean) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/BreakFlagAPI.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/BreakFlagAPI.scala similarity index 73% rename from src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/BreakFlagAPI.scala rename to src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/BreakFlagAPI.scala index ef1bd9cc8e..ff45976146 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/BreakFlagAPI.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/BreakFlagAPI.scala @@ -1,7 +1,7 @@ -package com.github.unchama.seichiassist.subsystems.breakflags +package com.github.unchama.seichiassist.subsystems.breakskilltargetconfig import cats.data.Kleisli -import com.github.unchama.seichiassist.subsystems.breakflags.domain.BreakFlagName +import com.github.unchama.seichiassist.subsystems.breakskilltargetconfig.domain.BreakFlagName trait BreakFlagAPI[F[_], Player] { diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/System.scala similarity index 83% rename from src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/System.scala rename to src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/System.scala index 19cb575881..d7b5f684c8 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/System.scala @@ -1,17 +1,17 @@ -package com.github.unchama.seichiassist.subsystems.breakflags +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.breakflags.application.repository.BreakFlagRepositoryDefinition -import com.github.unchama.seichiassist.subsystems.breakflags.domain.{ +import com.github.unchama.seichiassist.subsystems.breakskilltargetconfig.application.repository.BreakFlagRepositoryDefinition +import com.github.unchama.seichiassist.subsystems.breakskilltargetconfig.domain.{ BreakFlag, BreakFlagName, BreakFlagPersistence } -import com.github.unchama.seichiassist.subsystems.breakflags.persistence.JdbcBreakFlagPersistence +import com.github.unchama.seichiassist.subsystems.breakskilltargetconfig.persistence.JdbcBreakFlagPersistence import org.bukkit.entity.Player trait System[F[_], Player] extends Subsystem[F] { diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/application/repository/BreakFlagRepositoryDefinition.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/application/repository/BreakFlagRepositoryDefinition.scala similarity index 76% rename from src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/application/repository/BreakFlagRepositoryDefinition.scala rename to src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/application/repository/BreakFlagRepositoryDefinition.scala index 384868125f..b6c1fff3b3 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/application/repository/BreakFlagRepositoryDefinition.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/application/repository/BreakFlagRepositoryDefinition.scala @@ -1,10 +1,10 @@ -package com.github.unchama.seichiassist.subsystems.breakflags.application.repository +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.breakflags.domain.{ +import com.github.unchama.seichiassist.subsystems.breakskilltargetconfig.domain.{ BreakFlag, BreakFlagPersistence } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/domain/BreakFlag.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/domain/BreakFlag.scala new file mode 100644 index 0000000000..cddae03a0c --- /dev/null +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/domain/BreakFlag.scala @@ -0,0 +1,3 @@ +package com.github.unchama.seichiassist.subsystems.breakskilltargetconfig.domain + +case class BreakFlag(flagName: BreakFlagName, flag: Boolean) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/domain/BreakFlagName.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/domain/BreakFlagName.scala similarity index 87% rename from src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/domain/BreakFlagName.scala rename to src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/domain/BreakFlagName.scala index cba4e1fe68..3c3c5eb6f1 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/domain/BreakFlagName.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/domain/BreakFlagName.scala @@ -1,4 +1,4 @@ -package com.github.unchama.seichiassist.subsystems.breakflags.domain +package com.github.unchama.seichiassist.subsystems.breakskilltargetconfig.domain import enumeratum.{Enum, EnumEntry} diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/domain/BreakFlagPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/domain/BreakFlagPersistence.scala similarity index 63% rename from src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/domain/BreakFlagPersistence.scala rename to src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/domain/BreakFlagPersistence.scala index 5ede21796d..d26a3eb50a 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/domain/BreakFlagPersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/domain/BreakFlagPersistence.scala @@ -1,4 +1,4 @@ -package com.github.unchama.seichiassist.subsystems.breakflags.domain +package com.github.unchama.seichiassist.subsystems.breakskilltargetconfig.domain import com.github.unchama.generic.RefDict diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/persistence/JdbcBreakFlagPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/persistence/JdbcBreakFlagPersistence.scala similarity index 88% rename from src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/persistence/JdbcBreakFlagPersistence.scala rename to src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/persistence/JdbcBreakFlagPersistence.scala index 394f6fbbbf..dc5e759200 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakflags/persistence/JdbcBreakFlagPersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/persistence/JdbcBreakFlagPersistence.scala @@ -1,7 +1,7 @@ -package com.github.unchama.seichiassist.subsystems.breakflags.persistence +package com.github.unchama.seichiassist.subsystems.breakskilltargetconfig.persistence import cats.effect.Sync -import com.github.unchama.seichiassist.subsystems.breakflags.domain.{ +import com.github.unchama.seichiassist.subsystems.breakskilltargetconfig.domain.{ BreakFlag, BreakFlagName, BreakFlagPersistence 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 cafe8f61bc..b94ee9022d 100644 --- a/src/main/scala/com/github/unchama/seichiassist/util/BreakUtil.scala +++ b/src/main/scala/com/github/unchama/seichiassist/util/BreakUtil.scala @@ -16,7 +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.breakflags.domain.BreakFlagName +import com.github.unchama.seichiassist.subsystems.breakskilltargetconfig.domain.BreakFlagName import com.github.unchama.targetedeffect.player.ActionBarMessageEffect import com.github.unchama.util.bukkit.ItemStackUtil import com.github.unchama.util.external.ExternalPlugins From 5287c8729df825252245245db865159563d91bca Mon Sep 17 00:00:00 2001 From: rito528 Date: Thu, 1 Jun 2023 13:54:13 +0900 Subject: [PATCH 15/59] =?UTF-8?q?style:=20BreakFlagName=E3=82=92BreakSkill?= =?UTF-8?q?TargetConfigKey=E3=81=AB=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../seichiassist/menus/skill/PassiveSkillMenu.scala | 10 +++++----- .../breakskilltargetconfig/BreakFlagAPI.scala | 6 +++--- .../subsystems/breakskilltargetconfig/System.scala | 6 +++--- .../breakskilltargetconfig/domain/BreakFlag.scala | 2 +- ...kFlagName.scala => BreakSkillTargetConfigKey.scala} | 10 +++++----- .../persistence/JdbcBreakFlagPersistence.scala | 4 ++-- .../github/unchama/seichiassist/util/BreakUtil.scala | 6 +++--- 7 files changed, 22 insertions(+), 22 deletions(-) rename src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/domain/{BreakFlagName.scala => BreakSkillTargetConfigKey.scala} (57%) 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 73dbf5182d..da97507ea3 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 @@ -12,7 +12,7 @@ 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.BreakFlagAPI -import com.github.unchama.seichiassist.subsystems.breakskilltargetconfig.domain.BreakFlagName +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 @@ -147,7 +147,7 @@ object PassiveSkillMenu extends Menu { import environment._ val computeToggleChestBreakButton: IO[Button] = RecomputedButton(for { - chestFlag <- breakFlagAPI.breakFlag(player, BreakFlagName.Chest) + chestFlag <- breakFlagAPI.breakFlag(player, BreakSkillTargetConfigKey.Chest) } yield { val baseLore = List(s"${GREEN}スキルでチェストを破壊するスキル") val statusLore = if (chestFlag) { @@ -164,7 +164,7 @@ object PassiveSkillMenu extends Menu { .build(), LeftClickButtonEffect { SequentialEffect( - DeferredEffect(IO(breakFlagAPI.toggleBreakFlag(BreakFlagName.Chest))), + DeferredEffect(IO(breakFlagAPI.toggleBreakFlag(BreakSkillTargetConfigKey.Chest))), DeferredEffect(IO { if (chestFlag) { SequentialEffect( @@ -184,7 +184,7 @@ object PassiveSkillMenu extends Menu { }) val computeToggleNetherQuartzBlockButton: IO[Button] = RecomputedButton(for { - quartzBreakFlag <- breakFlagAPI.breakFlag(player, BreakFlagName.NetherQuartz) + quartzBreakFlag <- breakFlagAPI.breakFlag(player, BreakSkillTargetConfigKey.NetherQuartz) } yield { val baseLore = List(s"${YELLOW}スキルでネザー水晶類ブロックを破壊するスキル") val statusLore = if (quartzBreakFlag) { @@ -204,7 +204,7 @@ object PassiveSkillMenu extends Menu { .build(), LeftClickButtonEffect { SequentialEffect( - DeferredEffect(IO(breakFlagAPI.toggleBreakFlag(BreakFlagName.NetherQuartz))), + DeferredEffect(IO(breakFlagAPI.toggleBreakFlag(BreakSkillTargetConfigKey.NetherQuartz))), DeferredEffect(IO { if (quartzBreakFlag) { SequentialEffect( diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/BreakFlagAPI.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/BreakFlagAPI.scala index ff45976146..5bc6ec5285 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/BreakFlagAPI.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/BreakFlagAPI.scala @@ -1,19 +1,19 @@ package com.github.unchama.seichiassist.subsystems.breakskilltargetconfig import cats.data.Kleisli -import com.github.unchama.seichiassist.subsystems.breakskilltargetconfig.domain.BreakFlagName +import com.github.unchama.seichiassist.subsystems.breakskilltargetconfig.domain.BreakSkillTargetConfigKey trait BreakFlagAPI[F[_], Player] { /** * @return 破壊フラグをトグルする作用 */ - def toggleBreakFlag(breakFlagName: BreakFlagName): Kleisli[F, Player, Unit] + def toggleBreakFlag(breakFlagName: BreakSkillTargetConfigKey): Kleisli[F, Player, Unit] /** * @return 現在の破壊フラグを取得する作用 */ - def breakFlag(player: Player, breakFlagName: BreakFlagName): F[Boolean] + def breakFlag(player: Player, breakFlagName: BreakSkillTargetConfigKey): F[Boolean] } 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 index d7b5f684c8..f4ed2eaab2 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/System.scala @@ -8,7 +8,7 @@ import com.github.unchama.seichiassist.meta.subsystem.Subsystem import com.github.unchama.seichiassist.subsystems.breakskilltargetconfig.application.repository.BreakFlagRepositoryDefinition import com.github.unchama.seichiassist.subsystems.breakskilltargetconfig.domain.{ BreakFlag, - BreakFlagName, + BreakSkillTargetConfigKey, BreakFlagPersistence } import com.github.unchama.seichiassist.subsystems.breakskilltargetconfig.persistence.JdbcBreakFlagPersistence @@ -34,7 +34,7 @@ object System { new System[F, Player] { override val api: BreakFlagAPI[F, Player] = new BreakFlagAPI[F, Player] { - override def toggleBreakFlag(breakFlagName: BreakFlagName): Kleisli[F, Player, Unit] = + override def toggleBreakFlag(breakFlagName: BreakSkillTargetConfigKey): Kleisli[F, Player, Unit] = Kleisli { player => for { breakFlag <- breakFlag(player, breakFlagName) @@ -47,7 +47,7 @@ object System { } yield () } - override def breakFlag(player: Player, breakFlagName: BreakFlagName): F[Boolean] = + override def breakFlag(player: Player, breakFlagName: BreakSkillTargetConfigKey): F[Boolean] = ContextCoercion(for { flags <- breakFlagRepository(player).get } yield { diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/domain/BreakFlag.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/domain/BreakFlag.scala index cddae03a0c..19fbc0edef 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/domain/BreakFlag.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/domain/BreakFlag.scala @@ -1,3 +1,3 @@ package com.github.unchama.seichiassist.subsystems.breakskilltargetconfig.domain -case class BreakFlag(flagName: BreakFlagName, flag: Boolean) +case class BreakFlag(flagName: BreakSkillTargetConfigKey, flag: Boolean) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/domain/BreakFlagName.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/domain/BreakSkillTargetConfigKey.scala similarity index 57% rename from src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/domain/BreakFlagName.scala rename to src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/domain/BreakSkillTargetConfigKey.scala index 3c3c5eb6f1..b1c6d715b7 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/domain/BreakFlagName.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/domain/BreakSkillTargetConfigKey.scala @@ -5,20 +5,20 @@ import enumeratum.{Enum, EnumEntry} /** * 定義されたブロックを破壊するかしないかを表すためのフラグの名前を集めたEnum */ -sealed trait BreakFlagName extends EnumEntry +sealed trait BreakSkillTargetConfigKey extends EnumEntry -object BreakFlagName extends Enum[BreakFlagName] { +object BreakSkillTargetConfigKey extends Enum[BreakSkillTargetConfigKey] { - val values: IndexedSeq[BreakFlagName] = findValues + val values: IndexedSeq[BreakSkillTargetConfigKey] = findValues /** * Chestブロックを破壊するかを示すフラグ名 */ - case object Chest extends BreakFlagName + case object Chest extends BreakSkillTargetConfigKey /** * ネザークォーツ系ブロックを破壊するかを示すフラグ名 */ - case object NetherQuartz extends BreakFlagName + case object NetherQuartz extends BreakSkillTargetConfigKey } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/persistence/JdbcBreakFlagPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/persistence/JdbcBreakFlagPersistence.scala index dc5e759200..cbaa3b2bf2 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/persistence/JdbcBreakFlagPersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/persistence/JdbcBreakFlagPersistence.scala @@ -3,7 +3,7 @@ package com.github.unchama.seichiassist.subsystems.breakskilltargetconfig.persis import cats.effect.Sync import com.github.unchama.seichiassist.subsystems.breakskilltargetconfig.domain.{ BreakFlag, - BreakFlagName, + BreakSkillTargetConfigKey, BreakFlagPersistence } import scalikejdbc.{DB, scalikejdbcSQLInterpolationImplicitDef} @@ -16,7 +16,7 @@ class JdbcBreakFlagPersistence[F[_]: Sync] extends BreakFlagPersistence[F] { val breakFlags = sql"SELECT flag_name, can_break FROM break_flags WHERE uuid = ${key.toString}" .map { rs => - BreakFlagName.withNameOption(rs.string("flag_name")).map { flagName => + BreakSkillTargetConfigKey.withNameOption(rs.string("flag_name")).map { flagName => BreakFlag(flagName, rs.boolean("can_break")) } } 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 b94ee9022d..daa11f6837 100644 --- a/src/main/scala/com/github/unchama/seichiassist/util/BreakUtil.scala +++ b/src/main/scala/com/github/unchama/seichiassist/util/BreakUtil.scala @@ -16,7 +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.BreakFlagName +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 @@ -132,7 +132,7 @@ object BreakUtil { .instance .breakFlagSystem .api - .breakFlag(player, BreakFlagName.Chest) + .breakFlag(player, BreakSkillTargetConfigKey.Chest) .unsafeRunSync() ) { ActionBarMessageEffect(s"${RED}スキルでのチェスト破壊は無効化されています").run(player).unsafeRunSync() @@ -156,7 +156,7 @@ object BreakUtil { .instance .breakFlagSystem .api - .breakFlag(player, BreakFlagName.NetherQuartz) + .breakFlag(player, BreakSkillTargetConfigKey.NetherQuartz) .unsafeRunSync() ) { ActionBarMessageEffect(s"${RED}スキルでのネザー水晶類ブロックの破壊は無効化されています") From d749b61d1b9ec46ca970f810f40ec35458ab1365 Mon Sep 17 00:00:00 2001 From: rito528 Date: Thu, 1 Jun 2023 13:55:39 +0900 Subject: [PATCH 16/59] =?UTF-8?q?docs:=20BreakSkillTargetConfigKey?= =?UTF-8?q?=E3=81=AE=E3=82=AA=E3=83=96=E3=82=B8=E3=82=A7=E3=82=AF=E3=83=88?= =?UTF-8?q?=E3=81=AE=E3=83=89=E3=82=AD=E3=83=A5=E3=83=A1=E3=83=B3=E3=83=88?= =?UTF-8?q?=E3=82=92=E7=9B=B4=E3=81=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/BreakSkillTargetConfigKey.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 index b1c6d715b7..bfff92fc4a 100644 --- 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 @@ -12,12 +12,12 @@ object BreakSkillTargetConfigKey extends Enum[BreakSkillTargetConfigKey] { val values: IndexedSeq[BreakSkillTargetConfigKey] = findValues /** - * Chestブロックを破壊するかを示すフラグ名 + * チェストを破壊するかどうか */ case object Chest extends BreakSkillTargetConfigKey /** - * ネザークォーツ系ブロックを破壊するかを示すフラグ名 + * ネザークォーツをクラフトしたブロックを破壊するかどうか */ case object NetherQuartz extends BreakSkillTargetConfigKey From 5182e84fe505a303a86b1f9705e1e43885643232 Mon Sep 17 00:00:00 2001 From: rito528 Date: Thu, 1 Jun 2023 13:56:48 +0900 Subject: [PATCH 17/59] =?UTF-8?q?style:=20BreakFlag=E3=81=AEflag=E5=A4=89?= =?UTF-8?q?=E6=95=B0=E3=82=92includes=E3=81=AB=E5=A4=89=E3=81=88=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../subsystems/breakskilltargetconfig/System.scala | 4 ++-- .../subsystems/breakskilltargetconfig/domain/BreakFlag.scala | 2 +- .../persistence/JdbcBreakFlagPersistence.scala | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) 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 index f4ed2eaab2..82a09b769e 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/System.scala @@ -41,7 +41,7 @@ object System { _ <- ContextCoercion(breakFlagRepository(player).update { breakFlags => breakFlags.filterNot(_.flagName == breakFlagName) :+ BreakFlag( breakFlagName, - flag = !breakFlag + includes = !breakFlag ) }) } yield () @@ -52,7 +52,7 @@ object System { flags <- breakFlagRepository(player).get } yield { flags.find(_.flagName == breakFlagName) match { - case Some(value) => value.flag + case Some(value) => value.includes case None => true // 破壊フラグのデフォルト値はtrue(破壊する) } }) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/domain/BreakFlag.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/domain/BreakFlag.scala index 19fbc0edef..7801adedfa 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/domain/BreakFlag.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/domain/BreakFlag.scala @@ -1,3 +1,3 @@ package com.github.unchama.seichiassist.subsystems.breakskilltargetconfig.domain -case class BreakFlag(flagName: BreakSkillTargetConfigKey, flag: Boolean) +case class BreakFlag(flagName: BreakSkillTargetConfigKey, includes: Boolean) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/persistence/JdbcBreakFlagPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/persistence/JdbcBreakFlagPersistence.scala index cbaa3b2bf2..ffe80e45f1 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/persistence/JdbcBreakFlagPersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/persistence/JdbcBreakFlagPersistence.scala @@ -31,7 +31,7 @@ class JdbcBreakFlagPersistence[F[_]: Sync] extends BreakFlagPersistence[F] { override def write(key: UUID, value: List[BreakFlag]): F[Unit] = Sync[F].delay { DB.localTx { implicit session => val uuid = key.toString - val batchParams = value.map { flag => Seq(uuid, flag.flagName.entryName, flag.flag) } + val batchParams = value.map { flag => Seq(uuid, flag.flagName.entryName, flag.includes) } sql"""INSERT INTO break_flags (uuid, flag_name, can_break) | VALUES (?, ?, ?) From 7c09c8fd61aae0645afa67c2ce62b61a9ad6af7f Mon Sep 17 00:00:00 2001 From: rito528 Date: Thu, 1 Jun 2023 13:59:13 +0900 Subject: [PATCH 18/59] =?UTF-8?q?refactor:=20BreakFlagPersistence=E3=81=8C?= =?UTF-8?q?=E6=8C=81=E3=81=A4=E5=80=A4=E3=81=AE=E5=9E=8B=E3=82=92List?= =?UTF-8?q?=E3=81=8B=E3=82=89Set=E3=81=AB=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/BreakFlagPersistence.scala | 2 +- .../persistence/JdbcBreakFlagPersistence.scala | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/domain/BreakFlagPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/domain/BreakFlagPersistence.scala index d26a3eb50a..93a3293641 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/domain/BreakFlagPersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/domain/BreakFlagPersistence.scala @@ -4,4 +4,4 @@ import com.github.unchama.generic.RefDict import java.util.UUID -trait BreakFlagPersistence[F[_]] extends RefDict[F, UUID, List[BreakFlag]] +trait BreakFlagPersistence[F[_]] extends RefDict[F, UUID, Set[BreakFlag]] diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/persistence/JdbcBreakFlagPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/persistence/JdbcBreakFlagPersistence.scala index ffe80e45f1..4cf8765083 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/persistence/JdbcBreakFlagPersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/persistence/JdbcBreakFlagPersistence.scala @@ -11,7 +11,7 @@ import scalikejdbc.{DB, scalikejdbcSQLInterpolationImplicitDef} import java.util.UUID class JdbcBreakFlagPersistence[F[_]: Sync] extends BreakFlagPersistence[F] { - override def read(key: UUID): F[Option[List[BreakFlag]]] = Sync[F].delay { + override def read(key: UUID): F[Option[Set[BreakFlag]]] = Sync[F].delay { DB.readOnly { implicit session => val breakFlags = sql"SELECT flag_name, can_break FROM break_flags WHERE uuid = ${key.toString}" @@ -22,16 +22,17 @@ class JdbcBreakFlagPersistence[F[_]: Sync] extends BreakFlagPersistence[F] { } .toList() .apply() + .toSet .collect { case Some(flag) => flag } Some(breakFlags) } } - override def write(key: UUID, value: List[BreakFlag]): F[Unit] = Sync[F].delay { + override def write(key: UUID, value: Set[BreakFlag]): F[Unit] = Sync[F].delay { DB.localTx { implicit session => val uuid = key.toString - val batchParams = value.map { flag => Seq(uuid, flag.flagName.entryName, flag.includes) } + val batchParams = value.map { flag => Seq(uuid, flag.flagName.entryName, flag.includes) }.toSeq sql"""INSERT INTO break_flags (uuid, flag_name, can_break) | VALUES (?, ?, ?) From d4d294b2129154cf3aeef50d111a08d24564ff19 Mon Sep 17 00:00:00 2001 From: rito528 Date: Thu, 1 Jun 2023 14:05:54 +0900 Subject: [PATCH 19/59] =?UTF-8?q?refactor:=20Option#fold=E3=82=92=E4=BD=BF?= =?UTF-8?q?=E3=81=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../subsystems/breakskilltargetconfig/System.scala | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) 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 index 82a09b769e..1858f49f06 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/System.scala @@ -50,12 +50,7 @@ object System { override def breakFlag(player: Player, breakFlagName: BreakSkillTargetConfigKey): F[Boolean] = ContextCoercion(for { flags <- breakFlagRepository(player).get - } yield { - flags.find(_.flagName == breakFlagName) match { - case Some(value) => value.includes - case None => true // 破壊フラグのデフォルト値はtrue(破壊する) - } - }) + } yield flags.find(_.flagName == breakFlagName).fold(true)(_.includes)) } } } From f9c3f076db6e445808992f2d96016ffb2cde1d29 Mon Sep 17 00:00:00 2001 From: rito528 Date: Thu, 1 Jun 2023 14:08:34 +0900 Subject: [PATCH 20/59] =?UTF-8?q?style:=20SkillMenu=E3=81=AEflag=E8=A8=88?= =?UTF-8?q?=E7=AE=97=E3=81=AE=E5=A4=89=E6=95=B0=E5=90=8D=E3=82=92=E5=A4=89?= =?UTF-8?q?=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../menus/skill/PassiveSkillMenu.scala | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) 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 da97507ea3..8440ad7ee3 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 @@ -147,15 +147,15 @@ object PassiveSkillMenu extends Menu { import environment._ val computeToggleChestBreakButton: IO[Button] = RecomputedButton(for { - chestFlag <- breakFlagAPI.breakFlag(player, BreakSkillTargetConfigKey.Chest) + breakChest <- breakFlagAPI.breakFlag(player, BreakSkillTargetConfigKey.Chest) } yield { val baseLore = List(s"${GREEN}スキルでチェストを破壊するスキル") - val statusLore = if (chestFlag) { + val statusLore = if (breakChest) { List(s"${RED}整地ワールドのみで発動中(デフォルト)", "", s"$DARK_GREEN${UNDERLINE}クリックで切り替え") } else { List(s"${RED}発動しません", "", s"$DARK_GREEN${UNDERLINE}クリックで切り替え") } - val material = if (chestFlag) Material.DIAMOND_AXE else Material.CHEST + val material = if (breakChest) Material.DIAMOND_AXE else Material.CHEST Button( new IconItemStackBuilder(material) @@ -166,7 +166,7 @@ object PassiveSkillMenu extends Menu { SequentialEffect( DeferredEffect(IO(breakFlagAPI.toggleBreakFlag(BreakSkillTargetConfigKey.Chest))), DeferredEffect(IO { - if (chestFlag) { + if (breakChest) { SequentialEffect( MessageEffect(s"${GREEN}スキルでのチェスト破壊を有効化しました。"), FocusedSoundEffect(Sound.BLOCK_STONE_BUTTON_CLICK_ON, 1f, 1f) @@ -184,10 +184,10 @@ object PassiveSkillMenu extends Menu { }) val computeToggleNetherQuartzBlockButton: IO[Button] = RecomputedButton(for { - quartzBreakFlag <- breakFlagAPI.breakFlag(player, BreakSkillTargetConfigKey.NetherQuartz) + breakQuartz <- breakFlagAPI.breakFlag(player, BreakSkillTargetConfigKey.NetherQuartz) } yield { val baseLore = List(s"${YELLOW}スキルでネザー水晶類ブロックを破壊するスキル") - val statusLore = if (quartzBreakFlag) { + val statusLore = if (breakQuartz) { List(s"${GREEN}ON (スキルでネザー水晶類ブロックを破壊します。)", s"${DARK_RED}クリックでOFF") } else { List(s"${RED}OFF (スキルでネザー水晶類ブロックを破壊しません。)", s"${DARK_GREEN}クリックでON") @@ -196,7 +196,7 @@ object PassiveSkillMenu extends Menu { Button( new IconItemStackBuilder(Material.QUARTZ_BLOCK) .tap { builder => - if (quartzBreakFlag) + if (breakQuartz) builder.enchanted() } .title(s"$WHITE$UNDERLINE${BOLD}ネザー水晶類ブロック破壊スキル切り替え") @@ -206,7 +206,7 @@ object PassiveSkillMenu extends Menu { SequentialEffect( DeferredEffect(IO(breakFlagAPI.toggleBreakFlag(BreakSkillTargetConfigKey.NetherQuartz))), DeferredEffect(IO { - if (quartzBreakFlag) { + if (breakQuartz) { SequentialEffect( MessageEffect(s"${GREEN}スキルでのネザー水晶類ブロック破壊を有効化しました。"), FocusedSoundEffect(Sound.BLOCK_STONE_BUTTON_CLICK_ON, 1f, 1f) From a102e990c6dca095c3f2c517eb7a4fb768aeff5f Mon Sep 17 00:00:00 2001 From: rito528 Date: Thu, 1 Jun 2023 14:11:21 +0900 Subject: [PATCH 21/59] =?UTF-8?q?style:=20Enum=E5=90=8D=E3=82=92=E3=83=89?= =?UTF-8?q?=E3=82=AD=E3=83=A5=E3=83=A1=E3=83=B3=E3=83=88=E3=81=AB=E3=81=82?= =?UTF-8?q?=E3=82=8F=E3=81=9B=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../unchama/seichiassist/menus/skill/PassiveSkillMenu.scala | 4 ++-- .../domain/BreakSkillTargetConfigKey.scala | 2 +- .../com/github/unchama/seichiassist/util/BreakUtil.scala | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) 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 8440ad7ee3..d52be361a2 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 @@ -184,7 +184,7 @@ object PassiveSkillMenu extends Menu { }) val computeToggleNetherQuartzBlockButton: IO[Button] = RecomputedButton(for { - breakQuartz <- breakFlagAPI.breakFlag(player, BreakSkillTargetConfigKey.NetherQuartz) + breakQuartz <- breakFlagAPI.breakFlag(player, BreakSkillTargetConfigKey.MadeFromNetherQuartz) } yield { val baseLore = List(s"${YELLOW}スキルでネザー水晶類ブロックを破壊するスキル") val statusLore = if (breakQuartz) { @@ -204,7 +204,7 @@ object PassiveSkillMenu extends Menu { .build(), LeftClickButtonEffect { SequentialEffect( - DeferredEffect(IO(breakFlagAPI.toggleBreakFlag(BreakSkillTargetConfigKey.NetherQuartz))), + DeferredEffect(IO(breakFlagAPI.toggleBreakFlag(BreakSkillTargetConfigKey.MadeFromNetherQuartz))), DeferredEffect(IO { if (breakQuartz) { SequentialEffect( 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 index bfff92fc4a..e3a59d494c 100644 --- 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 @@ -19,6 +19,6 @@ object BreakSkillTargetConfigKey extends Enum[BreakSkillTargetConfigKey] { /** * ネザークォーツをクラフトしたブロックを破壊するかどうか */ - case object NetherQuartz extends BreakSkillTargetConfigKey + case object MadeFromNetherQuartz extends BreakSkillTargetConfigKey } 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 daa11f6837..309eb969c5 100644 --- a/src/main/scala/com/github/unchama/seichiassist/util/BreakUtil.scala +++ b/src/main/scala/com/github/unchama/seichiassist/util/BreakUtil.scala @@ -156,7 +156,7 @@ object BreakUtil { .instance .breakFlagSystem .api - .breakFlag(player, BreakSkillTargetConfigKey.NetherQuartz) + .breakFlag(player, BreakSkillTargetConfigKey.MadeFromNetherQuartz) .unsafeRunSync() ) { ActionBarMessageEffect(s"${RED}スキルでのネザー水晶類ブロックの破壊は無効化されています") From b06e6149daee1f8b9349632c3fe4ee407ce38490 Mon Sep 17 00:00:00 2001 From: rito528 Date: Thu, 1 Jun 2023 14:12:27 +0900 Subject: [PATCH 22/59] =?UTF-8?q?docs:=20BreakSkillTargetConfigKey?= =?UTF-8?q?=E3=81=AE=E3=83=89=E3=82=AD=E3=83=A5=E3=83=A1=E3=83=B3=E3=83=88?= =?UTF-8?q?=E3=82=92=E3=82=88=E3=82=8A=E9=81=A9=E5=88=87=E3=81=AA=E3=82=82?= =?UTF-8?q?=E3=81=AE=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/BreakSkillTargetConfigKey.scala | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 index e3a59d494c..ea511195c2 100644 --- 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 @@ -3,7 +3,9 @@ package com.github.unchama.seichiassist.subsystems.breakskilltargetconfig.domain import enumeratum.{Enum, EnumEntry} /** - * 定義されたブロックを破壊するかしないかを表すためのフラグの名前を集めたEnum + * 予め決められたブロックの集合を表現する。 + * これらの値は整地スキルでブロックを破壊する際に、 + * プレイヤーの設定に応じて一部のブロックを除外する際に使われる。 */ sealed trait BreakSkillTargetConfigKey extends EnumEntry From b0171c83eaed8f200ae0384595ad120eb72cb879 Mon Sep 17 00:00:00 2001 From: rito528 Date: Thu, 1 Jun 2023 14:21:35 +0900 Subject: [PATCH 23/59] fix: compile error --- .../seichiassist/menus/skill/PassiveSkillMenu.scala | 7 +++++-- .../subsystems/breakskilltargetconfig/System.scala | 11 ++++++++--- .../repository/BreakFlagRepositoryDefinition.scala | 4 ++-- .../persistence/JdbcBreakFlagPersistence.scala | 8 +++++--- 4 files changed, 20 insertions(+), 10 deletions(-) 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 d52be361a2..253090a088 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 @@ -184,7 +184,8 @@ object PassiveSkillMenu extends Menu { }) val computeToggleNetherQuartzBlockButton: IO[Button] = RecomputedButton(for { - breakQuartz <- breakFlagAPI.breakFlag(player, BreakSkillTargetConfigKey.MadeFromNetherQuartz) + breakQuartz <- breakFlagAPI + .breakFlag(player, BreakSkillTargetConfigKey.MadeFromNetherQuartz) } yield { val baseLore = List(s"${YELLOW}スキルでネザー水晶類ブロックを破壊するスキル") val statusLore = if (breakQuartz) { @@ -204,7 +205,9 @@ object PassiveSkillMenu extends Menu { .build(), LeftClickButtonEffect { SequentialEffect( - DeferredEffect(IO(breakFlagAPI.toggleBreakFlag(BreakSkillTargetConfigKey.MadeFromNetherQuartz))), + DeferredEffect( + IO(breakFlagAPI.toggleBreakFlag(BreakSkillTargetConfigKey.MadeFromNetherQuartz)) + ), DeferredEffect(IO { if (breakQuartz) { SequentialEffect( 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 index 1858f49f06..06951c1f5d 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/System.scala @@ -34,12 +34,14 @@ object System { new System[F, Player] { override val api: BreakFlagAPI[F, Player] = new BreakFlagAPI[F, Player] { - override def toggleBreakFlag(breakFlagName: BreakSkillTargetConfigKey): Kleisli[F, Player, Unit] = + override def toggleBreakFlag( + breakFlagName: BreakSkillTargetConfigKey + ): Kleisli[F, Player, Unit] = Kleisli { player => for { breakFlag <- breakFlag(player, breakFlagName) _ <- ContextCoercion(breakFlagRepository(player).update { breakFlags => - breakFlags.filterNot(_.flagName == breakFlagName) :+ BreakFlag( + breakFlags.filterNot(_.flagName == breakFlagName) + BreakFlag( breakFlagName, includes = !breakFlag ) @@ -47,7 +49,10 @@ object System { } yield () } - override def breakFlag(player: Player, breakFlagName: BreakSkillTargetConfigKey): F[Boolean] = + override def breakFlag( + player: Player, + breakFlagName: BreakSkillTargetConfigKey + ): F[Boolean] = ContextCoercion(for { flags <- breakFlagRepository(player).get } yield flags.find(_.flagName == breakFlagName).fold(true)(_.includes)) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/application/repository/BreakFlagRepositoryDefinition.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/application/repository/BreakFlagRepositoryDefinition.scala index b6c1fff3b3..2ca80f26e4 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/application/repository/BreakFlagRepositoryDefinition.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/application/repository/BreakFlagRepositoryDefinition.scala @@ -13,9 +13,9 @@ object BreakFlagRepositoryDefinition { def withContext[F[_]: Sync, Player]( implicit persistence: BreakFlagPersistence[F] - ): RepositoryDefinition[F, Player, Ref[F, List[BreakFlag]]] = + ): RepositoryDefinition[F, Player, Ref[F, Set[BreakFlag]]] = RefDictBackedRepositoryDefinition - .usingUuidRefDict[F, Player, List[BreakFlag]](persistence)(List.empty) + .usingUuidRefDict[F, Player, Set[BreakFlag]](persistence)(Set.empty) .toRefRepository } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/persistence/JdbcBreakFlagPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/persistence/JdbcBreakFlagPersistence.scala index 4cf8765083..67781e9a74 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/persistence/JdbcBreakFlagPersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/persistence/JdbcBreakFlagPersistence.scala @@ -22,8 +22,8 @@ class JdbcBreakFlagPersistence[F[_]: Sync] extends BreakFlagPersistence[F] { } .toList() .apply() - .toSet .collect { case Some(flag) => flag } + .toSet Some(breakFlags) } @@ -32,13 +32,15 @@ class JdbcBreakFlagPersistence[F[_]: Sync] extends BreakFlagPersistence[F] { override def write(key: UUID, value: Set[BreakFlag]): F[Unit] = Sync[F].delay { DB.localTx { implicit session => val uuid = key.toString - val batchParams = value.map { flag => Seq(uuid, flag.flagName.entryName, flag.includes) }.toSeq + val batchParams = value.map { flag => + Seq(uuid, flag.flagName.entryName, flag.includes) + }.toSeq sql"""INSERT INTO break_flags (uuid, flag_name, can_break) | VALUES (?, ?, ?) | ON DUPLICATE KEY UPDATE | can_break = VALUE(can_break) - """.stripMargin.batch(batchParams: _*).apply[List] + """.stripMargin.batch(batchParams: _*).apply[List]() } } From 8f098dc4d8b62d55e04f4f78c5c2de775dac9df7 Mon Sep 17 00:00:00 2001 From: rito528 Date: Thu, 1 Jun 2023 14:22:05 +0900 Subject: [PATCH 24/59] =?UTF-8?q?fix:=20V1.17.0=E3=81=A7=E6=8C=87=E5=AE=9A?= =?UTF-8?q?=E3=81=99=E3=82=8B=E3=83=87=E3=83=BC=E3=82=BF=E3=83=99=E3=83=BC?= =?UTF-8?q?=E3=82=B9=E5=90=8D=E3=81=8C=E9=96=93=E9=81=95=E3=81=A3=E3=81=A6?= =?UTF-8?q?=E3=81=84=E3=81=9F=E3=81=AE=E3=81=A7=E7=9B=B4=E3=81=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resources/db/migration/V1.17.0__Create_break_flag_table.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/db/migration/V1.17.0__Create_break_flag_table.sql b/src/main/resources/db/migration/V1.17.0__Create_break_flag_table.sql index e48fbc6788..4caf189297 100644 --- a/src/main/resources/db/migration/V1.17.0__Create_break_flag_table.sql +++ b/src/main/resources/db/migration/V1.17.0__Create_break_flag_table.sql @@ -1,4 +1,4 @@ -use SeichiAssist; +USE seichiassist; CREATE TABLE break_flags( uuid CHAR(36) NOT NULL PRIMARY KEY, From 066b4caa7c3c34ba3ad1860991017fc002706ef2 Mon Sep 17 00:00:00 2001 From: rito528 Date: Thu, 1 Jun 2023 14:30:13 +0900 Subject: [PATCH 25/59] =?UTF-8?q?fix:=20API=E3=82=92=E5=91=BC=E3=82=93?= =?UTF-8?q?=E3=81=A0=E3=81=A8=E3=81=8D=E3=81=ABNone#get=E3=81=99=E3=82=8B?= =?UTF-8?q?=E4=B8=8D=E5=85=B7=E5=90=88=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../subsystems/breakskilltargetconfig/System.scala | 4 ++++ 1 file changed, 4 insertions(+) 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 index 06951c1f5d..a4f5fed30c 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/System.scala @@ -57,6 +57,10 @@ object System { flags <- breakFlagRepository(player).get } yield flags.find(_.flagName == breakFlagName).fold(true)(_.includes)) } + + override val managedRepositoryControls: Seq[BukkitRepositoryControls[F, _]] = Seq( + breakFlagRepositoryControls.coerceFinalizationContextTo[F] + ) } } } From e6154ae7a1f64bcc81a866911f1ab005d94e86ad Mon Sep 17 00:00:00 2001 From: rito528 Date: Thu, 1 Jun 2023 14:31:44 +0900 Subject: [PATCH 26/59] =?UTF-8?q?refactor:=20break=5Fflags=E3=81=AEflag=5F?= =?UTF-8?q?name=E3=82=92ENUM=E5=9E=8B=E3=81=AB=E5=A4=89=E6=9B=B4=E3=81=99?= =?UTF-8?q?=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resources/db/migration/V1.17.0__Create_break_flag_table.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/db/migration/V1.17.0__Create_break_flag_table.sql b/src/main/resources/db/migration/V1.17.0__Create_break_flag_table.sql index 4caf189297..6fff4b6728 100644 --- a/src/main/resources/db/migration/V1.17.0__Create_break_flag_table.sql +++ b/src/main/resources/db/migration/V1.17.0__Create_break_flag_table.sql @@ -2,6 +2,6 @@ USE seichiassist; CREATE TABLE break_flags( uuid CHAR(36) NOT NULL PRIMARY KEY, - flag_name VARCHAR(20) NOT NULL, + flag_name ENUM('Chest', 'MadeFromNetherQuartz') NOT NULL, can_break BOOL NOT NULL DEFAULT TRUE ); From 3715ac769079413e6c3907f1b595a0b3b872a5ab Mon Sep 17 00:00:00 2001 From: rito528 Date: Thu, 1 Jun 2023 14:33:16 +0900 Subject: [PATCH 27/59] =?UTF-8?q?style:=20can=5Fbreak=E3=82=AB=E3=83=A9?= =?UTF-8?q?=E3=83=A0=E3=82=92include=E3=82=AB=E3=83=A9=E3=83=A0=E3=81=AB?= =?UTF-8?q?=E6=94=B9=E5=90=8D=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../db/migration/V1.17.0__Create_break_flag_table.sql | 2 +- .../persistence/JdbcBreakFlagPersistence.scala | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/resources/db/migration/V1.17.0__Create_break_flag_table.sql b/src/main/resources/db/migration/V1.17.0__Create_break_flag_table.sql index 6fff4b6728..b0de33aeed 100644 --- a/src/main/resources/db/migration/V1.17.0__Create_break_flag_table.sql +++ b/src/main/resources/db/migration/V1.17.0__Create_break_flag_table.sql @@ -3,5 +3,5 @@ USE seichiassist; CREATE TABLE break_flags( uuid CHAR(36) NOT NULL PRIMARY KEY, flag_name ENUM('Chest', 'MadeFromNetherQuartz') NOT NULL, - can_break BOOL NOT NULL DEFAULT TRUE + include BOOL NOT NULL DEFAULT TRUE ); diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/persistence/JdbcBreakFlagPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/persistence/JdbcBreakFlagPersistence.scala index 67781e9a74..4516f93754 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/persistence/JdbcBreakFlagPersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/persistence/JdbcBreakFlagPersistence.scala @@ -14,10 +14,10 @@ class JdbcBreakFlagPersistence[F[_]: Sync] extends BreakFlagPersistence[F] { override def read(key: UUID): F[Option[Set[BreakFlag]]] = Sync[F].delay { DB.readOnly { implicit session => val breakFlags = - sql"SELECT flag_name, can_break FROM break_flags WHERE uuid = ${key.toString}" + sql"SELECT flag_name, include FROM break_flags WHERE uuid = ${key.toString}" .map { rs => BreakSkillTargetConfigKey.withNameOption(rs.string("flag_name")).map { flagName => - BreakFlag(flagName, rs.boolean("can_break")) + BreakFlag(flagName, rs.boolean("include")) } } .toList() @@ -36,10 +36,10 @@ class JdbcBreakFlagPersistence[F[_]: Sync] extends BreakFlagPersistence[F] { Seq(uuid, flag.flagName.entryName, flag.includes) }.toSeq - sql"""INSERT INTO break_flags (uuid, flag_name, can_break) + sql"""INSERT INTO break_flags (uuid, flag_name, include) | VALUES (?, ?, ?) | ON DUPLICATE KEY UPDATE - | can_break = VALUE(can_break) + | include = VALUE(include) """.stripMargin.batch(batchParams: _*).apply[List]() } } From 6bd7087d0b0f593c4b565fd22ab5831e881b1a35 Mon Sep 17 00:00:00 2001 From: rito528 Date: Thu, 1 Jun 2023 14:36:36 +0900 Subject: [PATCH 28/59] =?UTF-8?q?style:=20=E3=83=86=E3=83=BC=E3=83=96?= =?UTF-8?q?=E3=83=AB=E5=90=8D=E3=82=92=E6=94=B9=E5=90=8D=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...g_table.sql => V1.17.0__Create_break_preference_table.sql} | 2 +- .../persistence/JdbcBreakFlagPersistence.scala | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) rename src/main/resources/db/migration/{V1.17.0__Create_break_flag_table.sql => V1.17.0__Create_break_preference_table.sql} (81%) diff --git a/src/main/resources/db/migration/V1.17.0__Create_break_flag_table.sql b/src/main/resources/db/migration/V1.17.0__Create_break_preference_table.sql similarity index 81% rename from src/main/resources/db/migration/V1.17.0__Create_break_flag_table.sql rename to src/main/resources/db/migration/V1.17.0__Create_break_preference_table.sql index b0de33aeed..5d91ee4112 100644 --- a/src/main/resources/db/migration/V1.17.0__Create_break_flag_table.sql +++ b/src/main/resources/db/migration/V1.17.0__Create_break_preference_table.sql @@ -1,6 +1,6 @@ USE seichiassist; -CREATE TABLE break_flags( +CREATE TABLE player_break_preference( uuid CHAR(36) NOT NULL PRIMARY KEY, flag_name ENUM('Chest', 'MadeFromNetherQuartz') NOT NULL, include BOOL NOT NULL DEFAULT TRUE diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/persistence/JdbcBreakFlagPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/persistence/JdbcBreakFlagPersistence.scala index 4516f93754..e38328fb4b 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/persistence/JdbcBreakFlagPersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/persistence/JdbcBreakFlagPersistence.scala @@ -14,7 +14,7 @@ class JdbcBreakFlagPersistence[F[_]: Sync] extends BreakFlagPersistence[F] { override def read(key: UUID): F[Option[Set[BreakFlag]]] = Sync[F].delay { DB.readOnly { implicit session => val breakFlags = - sql"SELECT flag_name, include FROM break_flags WHERE uuid = ${key.toString}" + sql"SELECT flag_name, include FROM player_break_preference WHERE uuid = ${key.toString}" .map { rs => BreakSkillTargetConfigKey.withNameOption(rs.string("flag_name")).map { flagName => BreakFlag(flagName, rs.boolean("include")) @@ -36,7 +36,7 @@ class JdbcBreakFlagPersistence[F[_]: Sync] extends BreakFlagPersistence[F] { Seq(uuid, flag.flagName.entryName, flag.includes) }.toSeq - sql"""INSERT INTO break_flags (uuid, flag_name, include) + sql"""INSERT INTO player_break_preference (uuid, flag_name, include) | VALUES (?, ?, ?) | ON DUPLICATE KEY UPDATE | include = VALUE(include) From 614007f67afa2f0eea978a5262888511af694086 Mon Sep 17 00:00:00 2001 From: rito528 Date: Thu, 1 Jun 2023 14:40:25 +0900 Subject: [PATCH 29/59] =?UTF-8?q?feat:=20uuid=E3=82=AB=E3=83=A9=E3=83=A0?= =?UTF-8?q?=E3=82=92playerdata=E3=83=86=E3=83=BC=E3=83=96=E3=83=AB?= =?UTF-8?q?=E3=81=AB=E5=AF=BE=E3=81=97=E3=81=A6=E5=A4=96=E9=83=A8=E3=82=AD?= =?UTF-8?q?=E3=83=BC=E5=88=B6=E7=B4=84=E3=82=92=E3=81=8B=E3=81=91=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../db/migration/V1.17.0__Create_break_preference_table.sql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 index 5d91ee4112..73e8aa77fa 100644 --- 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 @@ -3,5 +3,6 @@ USE seichiassist; CREATE TABLE player_break_preference( uuid CHAR(36) NOT NULL PRIMARY KEY, flag_name ENUM('Chest', 'MadeFromNetherQuartz') NOT NULL, - include BOOL NOT NULL DEFAULT TRUE + include BOOL NOT NULL DEFAULT TRUE, + FOREIGN KEY (uuid) REFERENCES playerdata(uuid) ); From 06d47218827f6ec80858236abc9b657d88566256 Mon Sep 17 00:00:00 2001 From: rito528 Date: Thu, 1 Jun 2023 14:41:50 +0900 Subject: [PATCH 30/59] =?UTF-8?q?feat:=20player=5Fbreak=5Fpreference?= =?UTF-8?q?=E3=83=86=E3=83=BC=E3=83=96=E3=83=AB=E3=81=A7=E3=80=81uuid?= =?UTF-8?q?=E3=81=A8flag=5Fname=E3=82=92=E4=B8=BB=E3=82=AD=E3=83=BC?= =?UTF-8?q?=E5=88=B6=E7=B4=84=E3=82=92=E3=81=A4=E3=81=91=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../db/migration/V1.17.0__Create_break_preference_table.sql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 index 73e8aa77fa..7d1ecf29cc 100644 --- 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 @@ -1,8 +1,9 @@ USE seichiassist; CREATE TABLE player_break_preference( - uuid CHAR(36) NOT NULL PRIMARY KEY, + uuid CHAR(36) NOT NULL, flag_name ENUM('Chest', 'MadeFromNetherQuartz') NOT NULL, include BOOL NOT NULL DEFAULT TRUE, + PRIMARY KEY(uuid, flag_name), FOREIGN KEY (uuid) REFERENCES playerdata(uuid) ); From 61ff44c705d2bd85fe9875b06fb4fd9ffd280ef2 Mon Sep 17 00:00:00 2001 From: rito528 Date: Thu, 1 Jun 2023 14:50:00 +0900 Subject: [PATCH 31/59] =?UTF-8?q?feat:=20player=5Fbreak=5Fpreference?= =?UTF-8?q?=E3=81=AEuuid=E3=82=AB=E3=83=A9=E3=83=A0=E3=81=AB=E5=AF=BE?= =?UTF-8?q?=E3=81=97=E3=81=A6index=E3=82=92=E8=B2=BC=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../db/migration/V1.17.0__Create_break_preference_table.sql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 index 7d1ecf29cc..f997e36c5d 100644 --- 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 @@ -5,5 +5,6 @@ CREATE TABLE player_break_preference( flag_name ENUM('Chest', 'MadeFromNetherQuartz') NOT NULL, include BOOL NOT NULL DEFAULT TRUE, PRIMARY KEY(uuid, flag_name), - FOREIGN KEY (uuid) REFERENCES playerdata(uuid) + FOREIGN KEY (uuid) REFERENCES playerdata(uuid), + INDEX index_player_break_preference_on_uuid (uuid) ); From ac0823199087c96000a12585910a5e7116efa30d Mon Sep 17 00:00:00 2001 From: rito528 Date: Thu, 1 Jun 2023 15:05:27 +0900 Subject: [PATCH 32/59] =?UTF-8?q?style:=20BreakFlag=E3=81=AE=E5=A4=89?= =?UTF-8?q?=E6=95=B0=E5=90=8D=E3=82=92=E9=81=A9=E5=88=87=E3=81=AA=E3=82=82?= =?UTF-8?q?=E3=81=AE=E3=81=AB=E5=A4=89=E3=81=88=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../subsystems/breakskilltargetconfig/System.scala | 4 ++-- .../subsystems/breakskilltargetconfig/domain/BreakFlag.scala | 2 +- .../persistence/JdbcBreakFlagPersistence.scala | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) 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 index a4f5fed30c..29cb837dd5 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/System.scala @@ -41,7 +41,7 @@ object System { for { breakFlag <- breakFlag(player, breakFlagName) _ <- ContextCoercion(breakFlagRepository(player).update { breakFlags => - breakFlags.filterNot(_.flagName == breakFlagName) + BreakFlag( + breakFlags.filterNot(_.configKey == breakFlagName) + BreakFlag( breakFlagName, includes = !breakFlag ) @@ -55,7 +55,7 @@ object System { ): F[Boolean] = ContextCoercion(for { flags <- breakFlagRepository(player).get - } yield flags.find(_.flagName == breakFlagName).fold(true)(_.includes)) + } yield flags.find(_.configKey == breakFlagName).fold(true)(_.includes)) } override val managedRepositoryControls: Seq[BukkitRepositoryControls[F, _]] = Seq( diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/domain/BreakFlag.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/domain/BreakFlag.scala index 7801adedfa..be22945f67 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/domain/BreakFlag.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/domain/BreakFlag.scala @@ -1,3 +1,3 @@ package com.github.unchama.seichiassist.subsystems.breakskilltargetconfig.domain -case class BreakFlag(flagName: BreakSkillTargetConfigKey, includes: Boolean) +case class BreakFlag(configKey: BreakSkillTargetConfigKey, includes: Boolean) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/persistence/JdbcBreakFlagPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/persistence/JdbcBreakFlagPersistence.scala index e38328fb4b..508f0b1c95 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/persistence/JdbcBreakFlagPersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/persistence/JdbcBreakFlagPersistence.scala @@ -33,7 +33,7 @@ class JdbcBreakFlagPersistence[F[_]: Sync] extends BreakFlagPersistence[F] { DB.localTx { implicit session => val uuid = key.toString val batchParams = value.map { flag => - Seq(uuid, flag.flagName.entryName, flag.includes) + Seq(uuid, flag.configKey.entryName, flag.includes) }.toSeq sql"""INSERT INTO player_break_preference (uuid, flag_name, include) From 59784917c6a82c5fbaf7a82a1f976aa041ff7849 Mon Sep 17 00:00:00 2001 From: rito528 Date: Thu, 1 Jun 2023 15:11:37 +0900 Subject: [PATCH 33/59] =?UTF-8?q?style:=20BreakSkillTargetConfig=E3=81=AB?= =?UTF-8?q?=E3=82=AF=E3=83=A9=E3=82=B9=E5=90=8D=E3=81=AA=E3=81=A9=E3=82=92?= =?UTF-8?q?=E5=90=88=E3=82=8F=E3=81=9B=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...agAPI.scala => BreakSkillTargetConfigAPI.scala} | 6 +++--- .../subsystems/breakskilltargetconfig/System.scala | 14 +++++++------- ...eakSkillTargetConfigRepositoryDefinition.scala} | 12 ++++++------ .../breakskilltargetconfig/domain/BreakFlag.scala | 3 --- .../domain/BreakSkillTargetConfig.scala | 3 +++ ...ala => BreakSkillTargetConfigPersistence.scala} | 2 +- ...=> JdbcBreakSkillTargetConfigPersistence.scala} | 12 ++++++------ 7 files changed, 26 insertions(+), 26 deletions(-) rename src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/{BreakFlagAPI.scala => BreakSkillTargetConfigAPI.scala} (72%) rename src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/application/repository/{BreakFlagRepositoryDefinition.scala => BreakSkillTargetConfigRepositoryDefinition.scala} (59%) delete mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/domain/BreakFlag.scala create mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/domain/BreakSkillTargetConfig.scala rename src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/domain/{BreakFlagPersistence.scala => BreakSkillTargetConfigPersistence.scala} (59%) rename src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/persistence/{JdbcBreakFlagPersistence.scala => JdbcBreakSkillTargetConfigPersistence.scala} (73%) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/BreakFlagAPI.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/BreakSkillTargetConfigAPI.scala similarity index 72% rename from src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/BreakFlagAPI.scala rename to src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/BreakSkillTargetConfigAPI.scala index 5bc6ec5285..9aae74dd0e 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/BreakFlagAPI.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/BreakSkillTargetConfigAPI.scala @@ -3,7 +3,7 @@ package com.github.unchama.seichiassist.subsystems.breakskilltargetconfig import cats.data.Kleisli import com.github.unchama.seichiassist.subsystems.breakskilltargetconfig.domain.BreakSkillTargetConfigKey -trait BreakFlagAPI[F[_], Player] { +trait BreakSkillTargetConfigAPI[F[_], Player] { /** * @return 破壊フラグをトグルする作用 @@ -17,8 +17,8 @@ trait BreakFlagAPI[F[_], Player] { } -object BreakFlagAPI { +object BreakSkillTargetConfigAPI { - def apply[F[_], Player](implicit ev: BreakFlagAPI[F, Player]): BreakFlagAPI[F, Player] = ev + 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 index 29cb837dd5..8e6b88055c 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/System.scala @@ -5,13 +5,13 @@ 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.BreakFlagRepositoryDefinition +import com.github.unchama.seichiassist.subsystems.breakskilltargetconfig.application.repository.BreakSkillTargetConfigRepositoryDefinition import com.github.unchama.seichiassist.subsystems.breakskilltargetconfig.domain.{ - BreakFlag, + BreakSkillTargetConfig, BreakSkillTargetConfigKey, - BreakFlagPersistence + BreakSkillTargetConfigPersistence } -import com.github.unchama.seichiassist.subsystems.breakskilltargetconfig.persistence.JdbcBreakFlagPersistence +import com.github.unchama.seichiassist.subsystems.breakskilltargetconfig.persistence.JdbcBreakSkillTargetConfigPersistence import org.bukkit.entity.Player trait System[F[_], Player] extends Subsystem[F] { @@ -23,11 +23,11 @@ object System { import cats.implicits._ def wired[F[_]: Sync, G[_]: SyncEffect: ContextCoercion[*[_], F]]: G[System[F, Player]] = { - implicit val breakFlagPersistence: BreakFlagPersistence[G] = new JdbcBreakFlagPersistence[G] + implicit val breakFlagPersistence: BreakSkillTargetConfigPersistence[G] = new JdbcBreakSkillTargetConfigPersistence[G] for { breakFlagRepositoryControls <- BukkitRepositoryControls.createHandles( - BreakFlagRepositoryDefinition.withContext[G, Player] + BreakSkillTargetConfigRepositoryDefinition.withContext[G, Player] ) } yield { val breakFlagRepository = breakFlagRepositoryControls.repository @@ -41,7 +41,7 @@ object System { for { breakFlag <- breakFlag(player, breakFlagName) _ <- ContextCoercion(breakFlagRepository(player).update { breakFlags => - breakFlags.filterNot(_.configKey == breakFlagName) + BreakFlag( + breakFlags.filterNot(_.configKey == breakFlagName) + BreakSkillTargetConfig( breakFlagName, includes = !breakFlag ) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/application/repository/BreakFlagRepositoryDefinition.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/application/repository/BreakSkillTargetConfigRepositoryDefinition.scala similarity index 59% rename from src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/application/repository/BreakFlagRepositoryDefinition.scala rename to src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/application/repository/BreakSkillTargetConfigRepositoryDefinition.scala index 2ca80f26e4..cfd673f537 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/application/repository/BreakFlagRepositoryDefinition.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/application/repository/BreakSkillTargetConfigRepositoryDefinition.scala @@ -5,17 +5,17 @@ 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.{ - BreakFlag, - BreakFlagPersistence + BreakSkillTargetConfig, + BreakSkillTargetConfigPersistence } -object BreakFlagRepositoryDefinition { +object BreakSkillTargetConfigRepositoryDefinition { def withContext[F[_]: Sync, Player]( - implicit persistence: BreakFlagPersistence[F] - ): RepositoryDefinition[F, Player, Ref[F, Set[BreakFlag]]] = + implicit persistence: BreakSkillTargetConfigPersistence[F] + ): RepositoryDefinition[F, Player, Ref[F, Set[BreakSkillTargetConfig]]] = RefDictBackedRepositoryDefinition - .usingUuidRefDict[F, Player, Set[BreakFlag]](persistence)(Set.empty) + .usingUuidRefDict[F, Player, Set[BreakSkillTargetConfig]](persistence)(Set.empty) .toRefRepository } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/domain/BreakFlag.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/domain/BreakFlag.scala deleted file mode 100644 index be22945f67..0000000000 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/domain/BreakFlag.scala +++ /dev/null @@ -1,3 +0,0 @@ -package com.github.unchama.seichiassist.subsystems.breakskilltargetconfig.domain - -case class BreakFlag(configKey: BreakSkillTargetConfigKey, includes: Boolean) 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..f88e261239 --- /dev/null +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/domain/BreakSkillTargetConfig.scala @@ -0,0 +1,3 @@ +package com.github.unchama.seichiassist.subsystems.breakskilltargetconfig.domain + +case class BreakSkillTargetConfig(configKey: BreakSkillTargetConfigKey, includes: Boolean) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/domain/BreakFlagPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/domain/BreakSkillTargetConfigPersistence.scala similarity index 59% rename from src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/domain/BreakFlagPersistence.scala rename to src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/domain/BreakSkillTargetConfigPersistence.scala index 93a3293641..b7860c6c21 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/domain/BreakFlagPersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/domain/BreakSkillTargetConfigPersistence.scala @@ -4,4 +4,4 @@ import com.github.unchama.generic.RefDict import java.util.UUID -trait BreakFlagPersistence[F[_]] extends RefDict[F, UUID, Set[BreakFlag]] +trait BreakSkillTargetConfigPersistence[F[_]] extends RefDict[F, UUID, Set[BreakSkillTargetConfig]] diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/persistence/JdbcBreakFlagPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/persistence/JdbcBreakSkillTargetConfigPersistence.scala similarity index 73% rename from src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/persistence/JdbcBreakFlagPersistence.scala rename to src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/persistence/JdbcBreakSkillTargetConfigPersistence.scala index 508f0b1c95..5be160ca35 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/persistence/JdbcBreakFlagPersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/persistence/JdbcBreakSkillTargetConfigPersistence.scala @@ -2,22 +2,22 @@ package com.github.unchama.seichiassist.subsystems.breakskilltargetconfig.persis import cats.effect.Sync import com.github.unchama.seichiassist.subsystems.breakskilltargetconfig.domain.{ - BreakFlag, + BreakSkillTargetConfig, BreakSkillTargetConfigKey, - BreakFlagPersistence + BreakSkillTargetConfigPersistence } import scalikejdbc.{DB, scalikejdbcSQLInterpolationImplicitDef} import java.util.UUID -class JdbcBreakFlagPersistence[F[_]: Sync] extends BreakFlagPersistence[F] { - override def read(key: UUID): F[Option[Set[BreakFlag]]] = Sync[F].delay { +class JdbcBreakSkillTargetConfigPersistence[F[_]: Sync] extends BreakSkillTargetConfigPersistence[F] { + override def read(key: UUID): F[Option[Set[BreakSkillTargetConfig]]] = Sync[F].delay { DB.readOnly { implicit session => val breakFlags = sql"SELECT flag_name, include FROM player_break_preference WHERE uuid = ${key.toString}" .map { rs => BreakSkillTargetConfigKey.withNameOption(rs.string("flag_name")).map { flagName => - BreakFlag(flagName, rs.boolean("include")) + BreakSkillTargetConfig(flagName, rs.boolean("include")) } } .toList() @@ -29,7 +29,7 @@ class JdbcBreakFlagPersistence[F[_]: Sync] extends BreakFlagPersistence[F] { } } - override def write(key: UUID, value: Set[BreakFlag]): F[Unit] = Sync[F].delay { + override def write(key: UUID, value: Set[BreakSkillTargetConfig]): F[Unit] = Sync[F].delay { DB.localTx { implicit session => val uuid = key.toString val batchParams = value.map { flag => From eed1e2ccaa1f4bc63e92a01446ea7c5b9412b035 Mon Sep 17 00:00:00 2001 From: rito528 Date: Thu, 1 Jun 2023 15:14:45 +0900 Subject: [PATCH 34/59] =?UTF-8?q?style:=20API=E5=90=8D=E3=82=92=E6=94=B9?= =?UTF-8?q?=E5=90=8D=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../unchama/seichiassist/SeichiAssist.scala | 4 +- .../seichiassist/menus/TopLevelRouter.scala | 54 +++++++++---------- .../menus/skill/PassiveSkillMenu.scala | 12 ++--- .../breakskilltargetconfig/System.scala | 4 +- 4 files changed, 37 insertions(+), 37 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala b/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala index 3855f0785d..b653bfc77b 100644 --- a/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala +++ b/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala @@ -61,7 +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.BreakFlagAPI +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 @@ -702,7 +702,7 @@ class SeichiAssist extends JavaPlugin() { implicit val gachaAPI: GachaDrawAPI[IO, Player] = gachaSystem.api implicit val consumeGachaTicketAPI: ConsumeGachaTicketAPI[IO, Player] = consumeGachaTicketSystem.api - implicit val breakFlagAPI: BreakFlagAPI[IO, Player] = breakFlagSystem.api + implicit val breakSkillTargetConfigAPI: BreakSkillTargetConfigAPI[IO, Player] = breakFlagSystem.api val menuRouter = TopLevelRouter.apply import SeichiAssist.Scopes.globalChatInterceptionScope 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 960d53195d..1ed2045b31 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/TopLevelRouter.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/TopLevelRouter.scala @@ -29,7 +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.BreakFlagAPI +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 @@ -73,32 +73,32 @@ trait TopLevelRouter[F[_]] { object TopLevelRouter { def apply( - implicit javaTime: JavaTime[IO], - layoutPreparationContext: LayoutPreparationContext, - onMainThread: OnMinecraftServerThread[IO], - nonServerThreadContextShift: NonServerThreadContextShift[IO], - breakCountApi: BreakCountAPI[IO, SyncIO, Player], - breakCountBarAPI: BreakCountBarAPI[SyncIO, Player], - manaApi: ManaApi[IO, SyncIO, Player], - assortedRankingApi: AssortedRankingApi[IO], - gachaPointApi: GachaPointApi[IO, SyncIO, Player], - fastDiggingEffectApi: FastDiggingEffectApi[IO, Player], - fastDiggingSettingsApi: FastDiggingSettingsApi[IO, Player], - fourDimensionalPocketApi: FourDimensionalPocketApi[IO, Player], - globalNotification: DiscordNotificationAPI[IO], - homeReadApi: HomeReadAPI[IO], - enderChestAccessApi: AnywhereEnderChestAPI[IO], - sharedInventoryAPI: SharedInventoryAPI[IO, Player], - voteAPI: VoteAPI[IO, Player], - fairyAPI: FairyAPI[IO, SyncIO, Player], - donateAPI: DonatePremiumPointAPI[IO], - gachaTicketAPI: GachaTicketAPI[IO], - gachaPrizeAPI: GachaPrizeAPI[IO, ItemStack, Player], - mineStackAPI: MineStackAPI[IO, Player, ItemStack], - gachaDrawAPI: GachaDrawAPI[IO, Player], - consumeGachaTicketAPI: ConsumeGachaTicketAPI[IO, Player], - fairySpeechAPI: FairySpeechAPI[IO, Player], - breakFlagAPI: BreakFlagAPI[IO, Player] + implicit javaTime: JavaTime[IO], + layoutPreparationContext: LayoutPreparationContext, + onMainThread: OnMinecraftServerThread[IO], + nonServerThreadContextShift: NonServerThreadContextShift[IO], + breakCountApi: BreakCountAPI[IO, SyncIO, Player], + breakCountBarAPI: BreakCountBarAPI[SyncIO, Player], + manaApi: ManaApi[IO, SyncIO, Player], + assortedRankingApi: AssortedRankingApi[IO], + gachaPointApi: GachaPointApi[IO, SyncIO, Player], + fastDiggingEffectApi: FastDiggingEffectApi[IO, Player], + fastDiggingSettingsApi: FastDiggingSettingsApi[IO, Player], + fourDimensionalPocketApi: FourDimensionalPocketApi[IO, Player], + globalNotification: DiscordNotificationAPI[IO], + homeReadApi: HomeReadAPI[IO], + enderChestAccessApi: AnywhereEnderChestAPI[IO], + sharedInventoryAPI: SharedInventoryAPI[IO, Player], + voteAPI: VoteAPI[IO, Player], + fairyAPI: FairyAPI[IO, SyncIO, Player], + donateAPI: DonatePremiumPointAPI[IO], + gachaTicketAPI: GachaTicketAPI[IO], + gachaPrizeAPI: GachaPrizeAPI[IO, ItemStack, Player], + mineStackAPI: MineStackAPI[IO, Player, ItemStack], + gachaDrawAPI: GachaDrawAPI[IO, Player], + consumeGachaTicketAPI: ConsumeGachaTicketAPI[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 253090a088..52017d44c9 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,7 +11,7 @@ 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.BreakFlagAPI +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 @@ -32,7 +32,7 @@ object PassiveSkillMenu extends Menu { class Environment( implicit val breakCountApi: BreakCountAPI[IO, SyncIO, Player], - implicit val breakFlagAPI: BreakFlagAPI[IO, Player], + implicit val breakSkillTargetConfigAPI: BreakSkillTargetConfigAPI[IO, Player], val ioCanOpenFirstPage: IO CanOpen FirstPage.type ) @@ -147,7 +147,7 @@ object PassiveSkillMenu extends Menu { import environment._ val computeToggleChestBreakButton: IO[Button] = RecomputedButton(for { - breakChest <- breakFlagAPI.breakFlag(player, BreakSkillTargetConfigKey.Chest) + breakChest <- breakSkillTargetConfigAPI.breakFlag(player, BreakSkillTargetConfigKey.Chest) } yield { val baseLore = List(s"${GREEN}スキルでチェストを破壊するスキル") val statusLore = if (breakChest) { @@ -164,7 +164,7 @@ object PassiveSkillMenu extends Menu { .build(), LeftClickButtonEffect { SequentialEffect( - DeferredEffect(IO(breakFlagAPI.toggleBreakFlag(BreakSkillTargetConfigKey.Chest))), + DeferredEffect(IO(breakSkillTargetConfigAPI.toggleBreakFlag(BreakSkillTargetConfigKey.Chest))), DeferredEffect(IO { if (breakChest) { SequentialEffect( @@ -184,7 +184,7 @@ object PassiveSkillMenu extends Menu { }) val computeToggleNetherQuartzBlockButton: IO[Button] = RecomputedButton(for { - breakQuartz <- breakFlagAPI + breakQuartz <- breakSkillTargetConfigAPI .breakFlag(player, BreakSkillTargetConfigKey.MadeFromNetherQuartz) } yield { val baseLore = List(s"${YELLOW}スキルでネザー水晶類ブロックを破壊するスキル") @@ -206,7 +206,7 @@ object PassiveSkillMenu extends Menu { LeftClickButtonEffect { SequentialEffect( DeferredEffect( - IO(breakFlagAPI.toggleBreakFlag(BreakSkillTargetConfigKey.MadeFromNetherQuartz)) + IO(breakSkillTargetConfigAPI.toggleBreakFlag(BreakSkillTargetConfigKey.MadeFromNetherQuartz)) ), DeferredEffect(IO { if (breakQuartz) { 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 index 8e6b88055c..b7f4ff4b89 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/System.scala @@ -15,7 +15,7 @@ import com.github.unchama.seichiassist.subsystems.breakskilltargetconfig.persist import org.bukkit.entity.Player trait System[F[_], Player] extends Subsystem[F] { - val api: BreakFlagAPI[F, Player] + val api: BreakSkillTargetConfigAPI[F, Player] } object System { @@ -33,7 +33,7 @@ object System { val breakFlagRepository = breakFlagRepositoryControls.repository new System[F, Player] { - override val api: BreakFlagAPI[F, Player] = new BreakFlagAPI[F, Player] { + override val api: BreakSkillTargetConfigAPI[F, Player] = new BreakSkillTargetConfigAPI[F, Player] { override def toggleBreakFlag( breakFlagName: BreakSkillTargetConfigKey ): Kleisli[F, Player, Unit] = From 478318f50e9385d623387498ed61a623620bd96d Mon Sep 17 00:00:00 2001 From: rito528 Date: Thu, 1 Jun 2023 15:15:50 +0900 Subject: [PATCH 35/59] =?UTF-8?q?style:=20API=E3=81=AE=E9=96=A2=E6=95=B0?= =?UTF-8?q?=E5=90=8D=E3=82=92=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../seichiassist/menus/skill/PassiveSkillMenu.scala | 8 ++++---- .../BreakSkillTargetConfigAPI.scala | 4 ++-- .../subsystems/breakskilltargetconfig/System.scala | 6 +++--- .../com/github/unchama/seichiassist/util/BreakUtil.scala | 4 ++-- 4 files changed, 11 insertions(+), 11 deletions(-) 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 52017d44c9..d6a47f3dc2 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 @@ -147,7 +147,7 @@ object PassiveSkillMenu extends Menu { import environment._ val computeToggleChestBreakButton: IO[Button] = RecomputedButton(for { - breakChest <- breakSkillTargetConfigAPI.breakFlag(player, BreakSkillTargetConfigKey.Chest) + breakChest <- breakSkillTargetConfigAPI.breakSkillTargetConfig(player, BreakSkillTargetConfigKey.Chest) } yield { val baseLore = List(s"${GREEN}スキルでチェストを破壊するスキル") val statusLore = if (breakChest) { @@ -164,7 +164,7 @@ object PassiveSkillMenu extends Menu { .build(), LeftClickButtonEffect { SequentialEffect( - DeferredEffect(IO(breakSkillTargetConfigAPI.toggleBreakFlag(BreakSkillTargetConfigKey.Chest))), + DeferredEffect(IO(breakSkillTargetConfigAPI.toggleBreakSkillTargetConfig(BreakSkillTargetConfigKey.Chest))), DeferredEffect(IO { if (breakChest) { SequentialEffect( @@ -185,7 +185,7 @@ object PassiveSkillMenu extends Menu { val computeToggleNetherQuartzBlockButton: IO[Button] = RecomputedButton(for { breakQuartz <- breakSkillTargetConfigAPI - .breakFlag(player, BreakSkillTargetConfigKey.MadeFromNetherQuartz) + .breakSkillTargetConfig(player, BreakSkillTargetConfigKey.MadeFromNetherQuartz) } yield { val baseLore = List(s"${YELLOW}スキルでネザー水晶類ブロックを破壊するスキル") val statusLore = if (breakQuartz) { @@ -206,7 +206,7 @@ object PassiveSkillMenu extends Menu { LeftClickButtonEffect { SequentialEffect( DeferredEffect( - IO(breakSkillTargetConfigAPI.toggleBreakFlag(BreakSkillTargetConfigKey.MadeFromNetherQuartz)) + IO(breakSkillTargetConfigAPI.toggleBreakSkillTargetConfig(BreakSkillTargetConfigKey.MadeFromNetherQuartz)) ), DeferredEffect(IO { if (breakQuartz) { 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 index 9aae74dd0e..ea2d6e5f14 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/BreakSkillTargetConfigAPI.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/BreakSkillTargetConfigAPI.scala @@ -8,12 +8,12 @@ trait BreakSkillTargetConfigAPI[F[_], Player] { /** * @return 破壊フラグをトグルする作用 */ - def toggleBreakFlag(breakFlagName: BreakSkillTargetConfigKey): Kleisli[F, Player, Unit] + def toggleBreakSkillTargetConfig(breakFlagName: BreakSkillTargetConfigKey): Kleisli[F, Player, Unit] /** * @return 現在の破壊フラグを取得する作用 */ - def breakFlag(player: Player, breakFlagName: BreakSkillTargetConfigKey): F[Boolean] + def breakSkillTargetConfig(player: Player, breakFlagName: BreakSkillTargetConfigKey): F[Boolean] } 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 index b7f4ff4b89..2943b6e692 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/System.scala @@ -34,12 +34,12 @@ object System { new System[F, Player] { override val api: BreakSkillTargetConfigAPI[F, Player] = new BreakSkillTargetConfigAPI[F, Player] { - override def toggleBreakFlag( + override def toggleBreakSkillTargetConfig( breakFlagName: BreakSkillTargetConfigKey ): Kleisli[F, Player, Unit] = Kleisli { player => for { - breakFlag <- breakFlag(player, breakFlagName) + breakFlag <- breakSkillTargetConfig(player, breakFlagName) _ <- ContextCoercion(breakFlagRepository(player).update { breakFlags => breakFlags.filterNot(_.configKey == breakFlagName) + BreakSkillTargetConfig( breakFlagName, @@ -49,7 +49,7 @@ object System { } yield () } - override def breakFlag( + override def breakSkillTargetConfig( player: Player, breakFlagName: BreakSkillTargetConfigKey ): F[Boolean] = 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 309eb969c5..6f48e4c7ea 100644 --- a/src/main/scala/com/github/unchama/seichiassist/util/BreakUtil.scala +++ b/src/main/scala/com/github/unchama/seichiassist/util/BreakUtil.scala @@ -132,7 +132,7 @@ object BreakUtil { .instance .breakFlagSystem .api - .breakFlag(player, BreakSkillTargetConfigKey.Chest) + .breakSkillTargetConfig(player, BreakSkillTargetConfigKey.Chest) .unsafeRunSync() ) { ActionBarMessageEffect(s"${RED}スキルでのチェスト破壊は無効化されています").run(player).unsafeRunSync() @@ -156,7 +156,7 @@ object BreakUtil { .instance .breakFlagSystem .api - .breakFlag(player, BreakSkillTargetConfigKey.MadeFromNetherQuartz) + .breakSkillTargetConfig(player, BreakSkillTargetConfigKey.MadeFromNetherQuartz) .unsafeRunSync() ) { ActionBarMessageEffect(s"${RED}スキルでのネザー水晶類ブロックの破壊は無効化されています") From f18605974d5ce0c6dcb0873d9ebdd4bd0c9fa636 Mon Sep 17 00:00:00 2001 From: rito528 Date: Thu, 1 Jun 2023 15:17:37 +0900 Subject: [PATCH 36/59] style: apply scalafmt and scalafix --- .../unchama/seichiassist/SeichiAssist.scala | 3 +- .../seichiassist/menus/TopLevelRouter.scala | 52 +++++++++---------- .../menus/skill/PassiveSkillMenu.scala | 15 ++++-- .../BreakSkillTargetConfigAPI.scala | 13 +++-- .../breakskilltargetconfig/System.scala | 50 +++++++++--------- .../BreakSkillTargetConfigPersistence.scala | 3 +- ...dbcBreakSkillTargetConfigPersistence.scala | 3 +- 7 files changed, 80 insertions(+), 59 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala b/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala index b653bfc77b..bc27cdbe5e 100644 --- a/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala +++ b/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala @@ -702,7 +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] = breakFlagSystem.api + implicit val breakSkillTargetConfigAPI: BreakSkillTargetConfigAPI[IO, Player] = + breakFlagSystem.api val menuRouter = TopLevelRouter.apply import SeichiAssist.Scopes.globalChatInterceptionScope 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 1ed2045b31..cfde172a20 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/TopLevelRouter.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/TopLevelRouter.scala @@ -73,32 +73,32 @@ trait TopLevelRouter[F[_]] { object TopLevelRouter { def apply( - implicit javaTime: JavaTime[IO], - layoutPreparationContext: LayoutPreparationContext, - onMainThread: OnMinecraftServerThread[IO], - nonServerThreadContextShift: NonServerThreadContextShift[IO], - breakCountApi: BreakCountAPI[IO, SyncIO, Player], - breakCountBarAPI: BreakCountBarAPI[SyncIO, Player], - manaApi: ManaApi[IO, SyncIO, Player], - assortedRankingApi: AssortedRankingApi[IO], - gachaPointApi: GachaPointApi[IO, SyncIO, Player], - fastDiggingEffectApi: FastDiggingEffectApi[IO, Player], - fastDiggingSettingsApi: FastDiggingSettingsApi[IO, Player], - fourDimensionalPocketApi: FourDimensionalPocketApi[IO, Player], - globalNotification: DiscordNotificationAPI[IO], - homeReadApi: HomeReadAPI[IO], - enderChestAccessApi: AnywhereEnderChestAPI[IO], - sharedInventoryAPI: SharedInventoryAPI[IO, Player], - voteAPI: VoteAPI[IO, Player], - fairyAPI: FairyAPI[IO, SyncIO, Player], - donateAPI: DonatePremiumPointAPI[IO], - gachaTicketAPI: GachaTicketAPI[IO], - gachaPrizeAPI: GachaPrizeAPI[IO, ItemStack, Player], - mineStackAPI: MineStackAPI[IO, Player, ItemStack], - gachaDrawAPI: GachaDrawAPI[IO, Player], - consumeGachaTicketAPI: ConsumeGachaTicketAPI[IO, Player], - fairySpeechAPI: FairySpeechAPI[IO, Player], - BreakSkillTargetConfigAPI: BreakSkillTargetConfigAPI[IO, Player] + implicit javaTime: JavaTime[IO], + layoutPreparationContext: LayoutPreparationContext, + onMainThread: OnMinecraftServerThread[IO], + nonServerThreadContextShift: NonServerThreadContextShift[IO], + breakCountApi: BreakCountAPI[IO, SyncIO, Player], + breakCountBarAPI: BreakCountBarAPI[SyncIO, Player], + manaApi: ManaApi[IO, SyncIO, Player], + assortedRankingApi: AssortedRankingApi[IO], + gachaPointApi: GachaPointApi[IO, SyncIO, Player], + fastDiggingEffectApi: FastDiggingEffectApi[IO, Player], + fastDiggingSettingsApi: FastDiggingSettingsApi[IO, Player], + fourDimensionalPocketApi: FourDimensionalPocketApi[IO, Player], + globalNotification: DiscordNotificationAPI[IO], + homeReadApi: HomeReadAPI[IO], + enderChestAccessApi: AnywhereEnderChestAPI[IO], + sharedInventoryAPI: SharedInventoryAPI[IO, Player], + voteAPI: VoteAPI[IO, Player], + fairyAPI: FairyAPI[IO, SyncIO, Player], + donateAPI: DonatePremiumPointAPI[IO], + gachaTicketAPI: GachaTicketAPI[IO], + gachaPrizeAPI: GachaPrizeAPI[IO, ItemStack, Player], + mineStackAPI: MineStackAPI[IO, Player, ItemStack], + gachaDrawAPI: GachaDrawAPI[IO, Player], + consumeGachaTicketAPI: ConsumeGachaTicketAPI[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 d6a47f3dc2..3cf68c97e5 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 @@ -147,7 +147,8 @@ object PassiveSkillMenu extends Menu { import environment._ val computeToggleChestBreakButton: IO[Button] = RecomputedButton(for { - breakChest <- breakSkillTargetConfigAPI.breakSkillTargetConfig(player, BreakSkillTargetConfigKey.Chest) + breakChest <- breakSkillTargetConfigAPI + .breakSkillTargetConfig(player, BreakSkillTargetConfigKey.Chest) } yield { val baseLore = List(s"${GREEN}スキルでチェストを破壊するスキル") val statusLore = if (breakChest) { @@ -164,7 +165,12 @@ object PassiveSkillMenu extends Menu { .build(), LeftClickButtonEffect { SequentialEffect( - DeferredEffect(IO(breakSkillTargetConfigAPI.toggleBreakSkillTargetConfig(BreakSkillTargetConfigKey.Chest))), + DeferredEffect( + IO( + breakSkillTargetConfigAPI + .toggleBreakSkillTargetConfig(BreakSkillTargetConfigKey.Chest) + ) + ), DeferredEffect(IO { if (breakChest) { SequentialEffect( @@ -206,7 +212,10 @@ object PassiveSkillMenu extends Menu { LeftClickButtonEffect { SequentialEffect( DeferredEffect( - IO(breakSkillTargetConfigAPI.toggleBreakSkillTargetConfig(BreakSkillTargetConfigKey.MadeFromNetherQuartz)) + IO( + breakSkillTargetConfigAPI + .toggleBreakSkillTargetConfig(BreakSkillTargetConfigKey.MadeFromNetherQuartz) + ) ), DeferredEffect(IO { if (breakQuartz) { 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 index ea2d6e5f14..b490077d13 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/BreakSkillTargetConfigAPI.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/BreakSkillTargetConfigAPI.scala @@ -8,17 +8,24 @@ trait BreakSkillTargetConfigAPI[F[_], Player] { /** * @return 破壊フラグをトグルする作用 */ - def toggleBreakSkillTargetConfig(breakFlagName: BreakSkillTargetConfigKey): Kleisli[F, Player, Unit] + def toggleBreakSkillTargetConfig( + breakFlagName: BreakSkillTargetConfigKey + ): Kleisli[F, Player, Unit] /** * @return 現在の破壊フラグを取得する作用 */ - def breakSkillTargetConfig(player: Player, breakFlagName: BreakSkillTargetConfigKey): F[Boolean] + def breakSkillTargetConfig( + player: Player, + breakFlagName: BreakSkillTargetConfigKey + ): F[Boolean] } object BreakSkillTargetConfigAPI { - def apply[F[_], Player](implicit ev: BreakSkillTargetConfigAPI[F, Player]): BreakSkillTargetConfigAPI[F, Player] = ev + 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 index 2943b6e692..55fb9f9846 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/System.scala @@ -23,7 +23,8 @@ object System { import cats.implicits._ def wired[F[_]: Sync, G[_]: SyncEffect: ContextCoercion[*[_], F]]: G[System[F, Player]] = { - implicit val breakFlagPersistence: BreakSkillTargetConfigPersistence[G] = new JdbcBreakSkillTargetConfigPersistence[G] + implicit val breakFlagPersistence: BreakSkillTargetConfigPersistence[G] = + new JdbcBreakSkillTargetConfigPersistence[G] for { breakFlagRepositoryControls <- BukkitRepositoryControls.createHandles( @@ -33,30 +34,31 @@ object System { val breakFlagRepository = breakFlagRepositoryControls.repository new System[F, Player] { - override val api: BreakSkillTargetConfigAPI[F, Player] = new BreakSkillTargetConfigAPI[F, Player] { - override def toggleBreakSkillTargetConfig( - breakFlagName: BreakSkillTargetConfigKey - ): Kleisli[F, Player, Unit] = - Kleisli { player => - for { - breakFlag <- breakSkillTargetConfig(player, breakFlagName) - _ <- ContextCoercion(breakFlagRepository(player).update { breakFlags => - breakFlags.filterNot(_.configKey == breakFlagName) + BreakSkillTargetConfig( - breakFlagName, - includes = !breakFlag - ) - }) - } yield () - } + override val api: BreakSkillTargetConfigAPI[F, Player] = + new BreakSkillTargetConfigAPI[F, Player] { + override def toggleBreakSkillTargetConfig( + breakFlagName: BreakSkillTargetConfigKey + ): Kleisli[F, Player, Unit] = + Kleisli { player => + for { + breakFlag <- breakSkillTargetConfig(player, breakFlagName) + _ <- ContextCoercion(breakFlagRepository(player).update { breakFlags => + breakFlags.filterNot(_.configKey == breakFlagName) + BreakSkillTargetConfig( + breakFlagName, + includes = !breakFlag + ) + }) + } yield () + } - override def breakSkillTargetConfig( - player: Player, - breakFlagName: BreakSkillTargetConfigKey - ): F[Boolean] = - ContextCoercion(for { - flags <- breakFlagRepository(player).get - } yield flags.find(_.configKey == breakFlagName).fold(true)(_.includes)) - } + override def breakSkillTargetConfig( + player: Player, + breakFlagName: BreakSkillTargetConfigKey + ): F[Boolean] = + ContextCoercion(for { + flags <- breakFlagRepository(player).get + } yield flags.find(_.configKey == breakFlagName).fold(true)(_.includes)) + } override val managedRepositoryControls: Seq[BukkitRepositoryControls[F, _]] = Seq( breakFlagRepositoryControls.coerceFinalizationContextTo[F] 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 index b7860c6c21..e2fafa93dc 100644 --- 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 @@ -4,4 +4,5 @@ import com.github.unchama.generic.RefDict import java.util.UUID -trait BreakSkillTargetConfigPersistence[F[_]] extends RefDict[F, UUID, Set[BreakSkillTargetConfig]] +trait BreakSkillTargetConfigPersistence[F[_]] + extends RefDict[F, UUID, Set[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 index 5be160ca35..bcd4d83b83 100644 --- 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 @@ -10,7 +10,8 @@ import scalikejdbc.{DB, scalikejdbcSQLInterpolationImplicitDef} import java.util.UUID -class JdbcBreakSkillTargetConfigPersistence[F[_]: Sync] extends BreakSkillTargetConfigPersistence[F] { +class JdbcBreakSkillTargetConfigPersistence[F[_]: Sync] + extends BreakSkillTargetConfigPersistence[F] { override def read(key: UUID): F[Option[Set[BreakSkillTargetConfig]]] = Sync[F].delay { DB.readOnly { implicit session => val breakFlags = From 10c9e09062ce75cc8e956b863058409f064a7180 Mon Sep 17 00:00:00 2001 From: rito528 Date: Thu, 1 Jun 2023 15:21:02 +0900 Subject: [PATCH 37/59] =?UTF-8?q?style:=20subsystem=E5=90=8D=E3=81=AE?= =?UTF-8?q?=E7=9B=B4=E3=81=97=E6=BC=8F=E3=82=8C=E3=82=92=E7=9B=B4=E3=81=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/github/unchama/seichiassist/SeichiAssist.scala | 8 ++++---- .../com/github/unchama/seichiassist/util/BreakUtil.scala | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala b/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala index bc27cdbe5e..caf7eafff1 100644 --- a/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala +++ b/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala @@ -481,9 +481,9 @@ class SeichiAssist extends JavaPlugin() { subsystems.vote.subsystems.fairyspeech.System.wired[IO] } - /* TODO: breakFlagSystemは本来privateであるべきだが、 + /* TODO: breakSkillTargetConfigSystemは本来privateであるべきだが、 BreakUtilで呼び出されているため、やむを得ずpublicになっている */ - lazy val breakFlagSystem: subsystems.breakskilltargetconfig.System[IO, Player] = + lazy val breakSkillTargetConfigSystem: subsystems.breakskilltargetconfig.System[IO, Player] = subsystems.breakskilltargetconfig.System.wired[IO, SyncIO].unsafeRunSync() /* TODO: mineStackSystemは本来privateであるべきだが、mineStackにアイテムを格納するAPIが現状の @@ -527,7 +527,7 @@ class SeichiAssist extends JavaPlugin() { mineStackSystem, consumeGachaTicketSystem, openirontrapdoor.System.wired, - breakFlagSystem + breakSkillTargetConfigSystem ) private lazy val buildAssist: BuildAssist = { @@ -703,7 +703,7 @@ class SeichiAssist extends JavaPlugin() { implicit val consumeGachaTicketAPI: ConsumeGachaTicketAPI[IO, Player] = consumeGachaTicketSystem.api implicit val breakSkillTargetConfigAPI: BreakSkillTargetConfigAPI[IO, Player] = - breakFlagSystem.api + breakSkillTargetConfigSystem.api val menuRouter = TopLevelRouter.apply import SeichiAssist.Scopes.globalChatInterceptionScope 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 6f48e4c7ea..5ef37e79cc 100644 --- a/src/main/scala/com/github/unchama/seichiassist/util/BreakUtil.scala +++ b/src/main/scala/com/github/unchama/seichiassist/util/BreakUtil.scala @@ -130,7 +130,7 @@ object BreakUtil { if ( !SeichiAssist .instance - .breakFlagSystem + .breakSkillTargetConfigSystem .api .breakSkillTargetConfig(player, BreakSkillTargetConfigKey.Chest) .unsafeRunSync() @@ -154,7 +154,7 @@ object BreakUtil { if ( !SeichiAssist .instance - .breakFlagSystem + .breakSkillTargetConfigSystem .api .breakSkillTargetConfig(player, BreakSkillTargetConfigKey.MadeFromNetherQuartz) .unsafeRunSync() From c68fd52e45d9f9a7bf36a8489a24a5529b960453 Mon Sep 17 00:00:00 2001 From: rito528 Date: Thu, 1 Jun 2023 15:22:20 +0900 Subject: [PATCH 38/59] =?UTF-8?q?style:=20=E3=81=AA=E3=81=9C=E3=81=8B?= =?UTF-8?q?=E6=96=87=E9=A0=AD=E3=81=8C=E5=A4=A7=E6=96=87=E5=AD=97=E3=81=AB?= =?UTF-8?q?=E3=81=AA=E3=81=A3=E3=81=A6=E3=81=84=E3=81=9F=E3=81=AE=E3=81=A7?= =?UTF-8?q?=E7=9B=B4=E3=81=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/github/unchama/seichiassist/menus/TopLevelRouter.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 cfde172a20..09cf6adcd4 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/TopLevelRouter.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/TopLevelRouter.scala @@ -98,7 +98,7 @@ object TopLevelRouter { gachaDrawAPI: GachaDrawAPI[IO, Player], consumeGachaTicketAPI: ConsumeGachaTicketAPI[IO, Player], fairySpeechAPI: FairySpeechAPI[IO, Player], - BreakSkillTargetConfigAPI: BreakSkillTargetConfigAPI[IO, Player] + breakSkillTargetConfigAPI: BreakSkillTargetConfigAPI[IO, Player] ): TopLevelRouter[IO] = new TopLevelRouter[IO] { import assortedRankingApi._ From 7f351ffc290128f4a665508c3053bfc1a21cabe9 Mon Sep 17 00:00:00 2001 From: rito528 Date: Fri, 9 Jun 2023 14:26:30 +0900 Subject: [PATCH 39/59] =?UTF-8?q?chore:=20player=5Fbreak=5Fpreference?= =?UTF-8?q?=E3=81=AE=E3=83=86=E3=83=BC=E3=83=96=E3=83=AB=E3=81=AE=E5=A4=96?= =?UTF-8?q?=E9=83=A8=E3=82=AD=E3=83=BC=E5=88=B6=E7=B4=84=E3=82=92=E5=A4=96?= =?UTF-8?q?=E3=81=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../db/migration/V1.17.0__Create_break_preference_table.sql | 1 - 1 file changed, 1 deletion(-) 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 index f997e36c5d..fc5c847850 100644 --- 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 @@ -5,6 +5,5 @@ CREATE TABLE player_break_preference( flag_name ENUM('Chest', 'MadeFromNetherQuartz') NOT NULL, include BOOL NOT NULL DEFAULT TRUE, PRIMARY KEY(uuid, flag_name), - FOREIGN KEY (uuid) REFERENCES playerdata(uuid), INDEX index_player_break_preference_on_uuid (uuid) ); From 2bfb49469d7f30e44ceee18c4c1b6049ece900a7 Mon Sep 17 00:00:00 2001 From: rito528 Date: Fri, 9 Jun 2023 14:29:52 +0900 Subject: [PATCH 40/59] =?UTF-8?q?DeferredEffect=E3=82=92=E5=89=A5=E3=81=8C?= =?UTF-8?q?=E3=81=97=E3=81=A6Effect=E3=82=92=E5=91=BC=E3=81=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../menus/skill/PassiveSkillMenu.scala | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) 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 3cf68c97e5..d2f08151fe 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 @@ -165,12 +165,8 @@ object PassiveSkillMenu extends Menu { .build(), LeftClickButtonEffect { SequentialEffect( - DeferredEffect( - IO( - breakSkillTargetConfigAPI - .toggleBreakSkillTargetConfig(BreakSkillTargetConfigKey.Chest) - ) - ), + breakSkillTargetConfigAPI + .toggleBreakSkillTargetConfig(BreakSkillTargetConfigKey.Chest), DeferredEffect(IO { if (breakChest) { SequentialEffect( @@ -211,12 +207,8 @@ object PassiveSkillMenu extends Menu { .build(), LeftClickButtonEffect { SequentialEffect( - DeferredEffect( - IO( - breakSkillTargetConfigAPI - .toggleBreakSkillTargetConfig(BreakSkillTargetConfigKey.MadeFromNetherQuartz) - ) - ), + breakSkillTargetConfigAPI + .toggleBreakSkillTargetConfig(BreakSkillTargetConfigKey.MadeFromNetherQuartz), DeferredEffect(IO { if (breakQuartz) { SequentialEffect( From 12fe3479722c9c3e137bc5d9e3ff878040af9c38 Mon Sep 17 00:00:00 2001 From: rito528 Date: Fri, 9 Jun 2023 14:42:16 +0900 Subject: [PATCH 41/59] =?UTF-8?q?style:=20system=E3=81=AB=E3=83=89?= =?UTF-8?q?=E3=83=A1=E3=82=A4=E3=83=B3=E3=83=AD=E3=82=B8=E3=83=83=E3=82=AF?= =?UTF-8?q?=E3=82=92=E6=9B=B8=E3=81=8B=E3=81=AA=E3=81=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/codeStyles/codeStyleConfig.xml | 2 +- .../breakskilltargetconfig/System.scala | 31 ++++++++------- ...kkitBreakSkillTargetConfigRepository.scala | 39 +++++++++++++++++++ .../BreakSkillTargetConfigRepository.scala | 15 +++++++ 4 files changed, 72 insertions(+), 15 deletions(-) create mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/bukkit/BukkitBreakSkillTargetConfigRepository.scala create mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/domain/BreakSkillTargetConfigRepository.scala 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/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/System.scala index 55fb9f9846..aa926ea593 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/System.scala @@ -1,11 +1,16 @@ package com.github.unchama.seichiassist.subsystems.breakskilltargetconfig import cats.data.Kleisli +import cats.effect.concurrent.Ref import cats.effect.{Sync, SyncEffect} -import com.github.unchama.datarepository.bukkit.player.BukkitRepositoryControls +import com.github.unchama.datarepository.bukkit.player.{ + BukkitRepositoryControls, + PlayerDataRepository +} 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.bukkit.BukkitBreakSkillTargetConfigRepository import com.github.unchama.seichiassist.subsystems.breakskilltargetconfig.domain.{ BreakSkillTargetConfig, BreakSkillTargetConfigKey, @@ -31,7 +36,10 @@ object System { BreakSkillTargetConfigRepositoryDefinition.withContext[G, Player] ) } yield { - val breakFlagRepository = breakFlagRepositoryControls.repository + implicit val breakFlagRepository + : PlayerDataRepository[Ref[G, Set[BreakSkillTargetConfig]]] = + breakFlagRepositoryControls.repository + val breakSkillTargetConfigRepository = new BukkitBreakSkillTargetConfigRepository[G] new System[F, Player] { override val api: BreakSkillTargetConfigAPI[F, Player] = @@ -40,24 +48,19 @@ object System { breakFlagName: BreakSkillTargetConfigKey ): Kleisli[F, Player, Unit] = Kleisli { player => - for { - breakFlag <- breakSkillTargetConfig(player, breakFlagName) - _ <- ContextCoercion(breakFlagRepository(player).update { breakFlags => - breakFlags.filterNot(_.configKey == breakFlagName) + BreakSkillTargetConfig( - breakFlagName, - includes = !breakFlag - ) - }) - } yield () + ContextCoercion( + breakSkillTargetConfigRepository + .toggleBreakSkillTargetConfig(player, breakFlagName) + ) } override def breakSkillTargetConfig( player: Player, breakFlagName: BreakSkillTargetConfigKey ): F[Boolean] = - ContextCoercion(for { - flags <- breakFlagRepository(player).get - } yield flags.find(_.configKey == breakFlagName).fold(true)(_.includes)) + ContextCoercion( + breakSkillTargetConfigRepository.breakSkillTargetConfig(player, breakFlagName) + ) } override val managedRepositoryControls: Seq[BukkitRepositoryControls[F, _]] = Seq( diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/bukkit/BukkitBreakSkillTargetConfigRepository.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/bukkit/BukkitBreakSkillTargetConfigRepository.scala new file mode 100644 index 0000000000..c143fe166f --- /dev/null +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/bukkit/BukkitBreakSkillTargetConfigRepository.scala @@ -0,0 +1,39 @@ +package com.github.unchama.seichiassist.subsystems.breakskilltargetconfig.bukkit + +import cats.effect.Sync +import cats.effect.concurrent.Ref +import com.github.unchama.datarepository.bukkit.player.PlayerDataRepository +import com.github.unchama.seichiassist.subsystems.breakskilltargetconfig.domain.{ + BreakSkillTargetConfig, + BreakSkillTargetConfigKey, + BreakSkillTargetConfigRepository +} +import org.bukkit.entity.Player + +class BukkitBreakSkillTargetConfigRepository[F[_]: Sync]( + implicit breakFlagRepository: PlayerDataRepository[Ref[F, Set[BreakSkillTargetConfig]]] +) extends BreakSkillTargetConfigRepository[F, Player] { + + import cats.implicits._ + + override def toggleBreakSkillTargetConfig( + player: Player, + configKey: BreakSkillTargetConfigKey + ): F[Unit] = for { + breakFlag <- breakSkillTargetConfig(player, configKey) + _ <- breakFlagRepository(player).update { breakFlags => + breakFlags.filterNot(_.configKey == configKey) + BreakSkillTargetConfig( + configKey, + includes = !breakFlag + ) + } + } yield () + + override def breakSkillTargetConfig( + player: Player, + configKey: BreakSkillTargetConfigKey + ): F[Boolean] = for { + flags <- breakFlagRepository(player).get + } yield flags.find(_.configKey == configKey).fold(true)(_.includes) + +} diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/domain/BreakSkillTargetConfigRepository.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/domain/BreakSkillTargetConfigRepository.scala new file mode 100644 index 0000000000..d93be48b96 --- /dev/null +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/domain/BreakSkillTargetConfigRepository.scala @@ -0,0 +1,15 @@ +package com.github.unchama.seichiassist.subsystems.breakskilltargetconfig.domain + +trait BreakSkillTargetConfigRepository[F[_], Player] { + + /** + * @return `configKey`の破壊フラグをトグルする作用 + */ + def toggleBreakSkillTargetConfig(player: Player, configKey: BreakSkillTargetConfigKey): F[Unit] + + /** + * @return `player`の現在の破壊フラグを取得する作用 + */ + def breakSkillTargetConfig(player: Player, configKey: BreakSkillTargetConfigKey): F[Boolean] + +} From f3fdd3738dec2403a6d463090a402dbdca782a8e Mon Sep 17 00:00:00 2001 From: rito528 Date: Fri, 9 Jun 2023 14:45:38 +0900 Subject: [PATCH 42/59] style: scalafmt and scalafix --- .../seichiassist/menus/skill/PassiveSkillMenu.scala | 10 ++++++---- .../domain/BreakSkillTargetConfigRepository.scala | 5 ++++- 2 files changed, 10 insertions(+), 5 deletions(-) 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 d2f08151fe..c3503dae3b 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 @@ -165,8 +165,9 @@ object PassiveSkillMenu extends Menu { .build(), LeftClickButtonEffect { SequentialEffect( - breakSkillTargetConfigAPI - .toggleBreakSkillTargetConfig(BreakSkillTargetConfigKey.Chest), + breakSkillTargetConfigAPI.toggleBreakSkillTargetConfig( + BreakSkillTargetConfigKey.Chest + ), DeferredEffect(IO { if (breakChest) { SequentialEffect( @@ -207,8 +208,9 @@ object PassiveSkillMenu extends Menu { .build(), LeftClickButtonEffect { SequentialEffect( - breakSkillTargetConfigAPI - .toggleBreakSkillTargetConfig(BreakSkillTargetConfigKey.MadeFromNetherQuartz), + breakSkillTargetConfigAPI.toggleBreakSkillTargetConfig( + BreakSkillTargetConfigKey.MadeFromNetherQuartz + ), DeferredEffect(IO { if (breakQuartz) { SequentialEffect( diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/domain/BreakSkillTargetConfigRepository.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/domain/BreakSkillTargetConfigRepository.scala index d93be48b96..c59168d84c 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/domain/BreakSkillTargetConfigRepository.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/domain/BreakSkillTargetConfigRepository.scala @@ -5,7 +5,10 @@ trait BreakSkillTargetConfigRepository[F[_], Player] { /** * @return `configKey`の破壊フラグをトグルする作用 */ - def toggleBreakSkillTargetConfig(player: Player, configKey: BreakSkillTargetConfigKey): F[Unit] + def toggleBreakSkillTargetConfig( + player: Player, + configKey: BreakSkillTargetConfigKey + ): F[Unit] /** * @return `player`の現在の破壊フラグを取得する作用 From c961022186f414c0e9eef854f0d995360e8aa8af Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 11 Jun 2023 20:46:49 +0900 Subject: [PATCH 43/59] =?UTF-8?q?feat:=20Repository=E3=82=92RepositoryDefi?= =?UTF-8?q?nition=E3=81=A7=E5=AE=9A=E7=BE=A9=E3=81=99=E3=82=8B=E3=82=88?= =?UTF-8?q?=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BreakSkillTargetConfigAPI.scala | 7 +- .../breakskilltargetconfig/System.scala | 29 +++----- ...killTargetConfigRepositoryDefinition.scala | 12 ++-- ...kkitBreakSkillTargetConfigRepository.scala | 39 ---------- .../BreakSkillTargetConfigPersistence.scala | 2 +- .../BreakSkillTargetConfigRepository.scala | 46 ++++++++++-- ...dbcBreakSkillTargetConfigPersistence.scala | 71 +++++++++++-------- 7 files changed, 100 insertions(+), 106 deletions(-) delete mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/bukkit/BukkitBreakSkillTargetConfigRepository.scala 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 index b490077d13..97770a5520 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/BreakSkillTargetConfigAPI.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/BreakSkillTargetConfigAPI.scala @@ -9,16 +9,13 @@ trait BreakSkillTargetConfigAPI[F[_], Player] { * @return 破壊フラグをトグルする作用 */ def toggleBreakSkillTargetConfig( - breakFlagName: BreakSkillTargetConfigKey + configKey: BreakSkillTargetConfigKey ): Kleisli[F, Player, Unit] /** * @return 現在の破壊フラグを取得する作用 */ - def breakSkillTargetConfig( - player: Player, - breakFlagName: BreakSkillTargetConfigKey - ): F[Boolean] + def breakSkillTargetConfig(player: Player, configKey: BreakSkillTargetConfigKey): F[Boolean] } 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 index aa926ea593..a40fd88a57 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/System.scala @@ -1,18 +1,12 @@ package com.github.unchama.seichiassist.subsystems.breakskilltargetconfig import cats.data.Kleisli -import cats.effect.concurrent.Ref import cats.effect.{Sync, SyncEffect} -import com.github.unchama.datarepository.bukkit.player.{ - BukkitRepositoryControls, - PlayerDataRepository -} +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.bukkit.BukkitBreakSkillTargetConfigRepository import com.github.unchama.seichiassist.subsystems.breakskilltargetconfig.domain.{ - BreakSkillTargetConfig, BreakSkillTargetConfigKey, BreakSkillTargetConfigPersistence } @@ -28,43 +22,40 @@ object System { import cats.implicits._ def wired[F[_]: Sync, G[_]: SyncEffect: ContextCoercion[*[_], F]]: G[System[F, Player]] = { - implicit val breakFlagPersistence: BreakSkillTargetConfigPersistence[G] = + implicit val breakSkillTargetConfigPersistence: BreakSkillTargetConfigPersistence[G] = new JdbcBreakSkillTargetConfigPersistence[G] for { - breakFlagRepositoryControls <- BukkitRepositoryControls.createHandles( + breakSkillTargetConfigRepositoryControls <- BukkitRepositoryControls.createHandles( BreakSkillTargetConfigRepositoryDefinition.withContext[G, Player] ) } yield { - implicit val breakFlagRepository - : PlayerDataRepository[Ref[G, Set[BreakSkillTargetConfig]]] = - breakFlagRepositoryControls.repository - val breakSkillTargetConfigRepository = new BukkitBreakSkillTargetConfigRepository[G] + val breakSkillTargetConfigRepository = breakSkillTargetConfigRepositoryControls.repository new System[F, Player] { override val api: BreakSkillTargetConfigAPI[F, Player] = new BreakSkillTargetConfigAPI[F, Player] { override def toggleBreakSkillTargetConfig( - breakFlagName: BreakSkillTargetConfigKey + configKey: BreakSkillTargetConfigKey ): Kleisli[F, Player, Unit] = Kleisli { player => ContextCoercion( - breakSkillTargetConfigRepository - .toggleBreakSkillTargetConfig(player, breakFlagName) + breakSkillTargetConfigRepository(player) + .toggleBreakSkillTargetConfig(configKey) ) } override def breakSkillTargetConfig( player: Player, - breakFlagName: BreakSkillTargetConfigKey + configKey: BreakSkillTargetConfigKey ): F[Boolean] = ContextCoercion( - breakSkillTargetConfigRepository.breakSkillTargetConfig(player, breakFlagName) + breakSkillTargetConfigRepository(player).breakSkillTargetConfig(configKey) ) } override val managedRepositoryControls: Seq[BukkitRepositoryControls[F, _]] = Seq( - breakFlagRepositoryControls.coerceFinalizationContextTo[F] + 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 index cfd673f537..c1a9200e73 100644 --- 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 @@ -1,21 +1,21 @@ 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 + BreakSkillTargetConfigPersistence, + BreakSkillTargetConfigRepository } object BreakSkillTargetConfigRepositoryDefinition { def withContext[F[_]: Sync, Player]( implicit persistence: BreakSkillTargetConfigPersistence[F] - ): RepositoryDefinition[F, Player, Ref[F, Set[BreakSkillTargetConfig]]] = + ): RepositoryDefinition[F, Player, BreakSkillTargetConfigRepository[F]] = RefDictBackedRepositoryDefinition - .usingUuidRefDict[F, Player, Set[BreakSkillTargetConfig]](persistence)(Set.empty) - .toRefRepository + .usingUuidRefDict[F, Player, BreakSkillTargetConfigRepository[F]](persistence)( + new BreakSkillTargetConfigRepository[F] + ) } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/bukkit/BukkitBreakSkillTargetConfigRepository.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/bukkit/BukkitBreakSkillTargetConfigRepository.scala deleted file mode 100644 index c143fe166f..0000000000 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/bukkit/BukkitBreakSkillTargetConfigRepository.scala +++ /dev/null @@ -1,39 +0,0 @@ -package com.github.unchama.seichiassist.subsystems.breakskilltargetconfig.bukkit - -import cats.effect.Sync -import cats.effect.concurrent.Ref -import com.github.unchama.datarepository.bukkit.player.PlayerDataRepository -import com.github.unchama.seichiassist.subsystems.breakskilltargetconfig.domain.{ - BreakSkillTargetConfig, - BreakSkillTargetConfigKey, - BreakSkillTargetConfigRepository -} -import org.bukkit.entity.Player - -class BukkitBreakSkillTargetConfigRepository[F[_]: Sync]( - implicit breakFlagRepository: PlayerDataRepository[Ref[F, Set[BreakSkillTargetConfig]]] -) extends BreakSkillTargetConfigRepository[F, Player] { - - import cats.implicits._ - - override def toggleBreakSkillTargetConfig( - player: Player, - configKey: BreakSkillTargetConfigKey - ): F[Unit] = for { - breakFlag <- breakSkillTargetConfig(player, configKey) - _ <- breakFlagRepository(player).update { breakFlags => - breakFlags.filterNot(_.configKey == configKey) + BreakSkillTargetConfig( - configKey, - includes = !breakFlag - ) - } - } yield () - - override def breakSkillTargetConfig( - player: Player, - configKey: BreakSkillTargetConfigKey - ): F[Boolean] = for { - flags <- breakFlagRepository(player).get - } yield flags.find(_.configKey == configKey).fold(true)(_.includes) - -} 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 index e2fafa93dc..7a864135e9 100644 --- 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 @@ -5,4 +5,4 @@ import com.github.unchama.generic.RefDict import java.util.UUID trait BreakSkillTargetConfigPersistence[F[_]] - extends RefDict[F, UUID, Set[BreakSkillTargetConfig]] + extends RefDict[F, UUID, BreakSkillTargetConfigRepository[F]] diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/domain/BreakSkillTargetConfigRepository.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/domain/BreakSkillTargetConfigRepository.scala index c59168d84c..411d3c1ddd 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/domain/BreakSkillTargetConfigRepository.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/domain/BreakSkillTargetConfigRepository.scala @@ -1,18 +1,50 @@ package com.github.unchama.seichiassist.subsystems.breakskilltargetconfig.domain -trait BreakSkillTargetConfigRepository[F[_], Player] { +import cats.effect.Sync +import cats.effect.concurrent.Ref + +class BreakSkillTargetConfigRepository[F[_]: Sync] { + + import cats.implicits._ + + private val breakSkillTargetConfigs: Ref[F, Set[BreakSkillTargetConfig]] = + Ref.unsafe(Set.empty) /** * @return `configKey`の破壊フラグをトグルする作用 */ - def toggleBreakSkillTargetConfig( - player: Player, - configKey: BreakSkillTargetConfigKey - ): F[Unit] + def toggleBreakSkillTargetConfig(configKey: BreakSkillTargetConfigKey): F[Unit] = for { + _ <- breakSkillTargetConfigs.getAndUpdate { breakFlags => + val currentTargetBreakConfig = + breakFlags.find(_.configKey == configKey).exists(_.includes) + + breakFlags.filterNot(_.configKey == configKey) + BreakSkillTargetConfig( + configKey, + includes = !currentTargetBreakConfig + ) + } + } yield () + + /** + * @return 現在の破壊フラグを取得する作用 + */ + def breakSkillTargetConfig(configKey: BreakSkillTargetConfigKey): F[Boolean] = { + for { + config <- breakSkillTargetConfigs.get + } yield config.find(_.configKey == configKey).exists(_.includes) + } + + /** + * この関数は永続化層で利用されることを想定しています。 + * @return 現在の[[BreakSkillTargetConfig]]をすべて取得する作用 + */ + def getConfigAll: F[Set[BreakSkillTargetConfig]] = breakSkillTargetConfigs.get /** - * @return `player`の現在の破壊フラグを取得する作用 + * この関数は永続化層で利用することを想定しています。 + * @return 現在の設定を`config`で上書きする作用 */ - def breakSkillTargetConfig(player: Player, configKey: BreakSkillTargetConfigKey): F[Boolean] + def setConfig(config: Set[BreakSkillTargetConfig]): F[Unit] = + breakSkillTargetConfigs.set(config) } 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 index bcd4d83b83..753a3b1847 100644 --- 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 @@ -4,7 +4,8 @@ import cats.effect.Sync import com.github.unchama.seichiassist.subsystems.breakskilltargetconfig.domain.{ BreakSkillTargetConfig, BreakSkillTargetConfigKey, - BreakSkillTargetConfigPersistence + BreakSkillTargetConfigPersistence, + BreakSkillTargetConfigRepository } import scalikejdbc.{DB, scalikejdbcSQLInterpolationImplicitDef} @@ -12,37 +13,49 @@ import java.util.UUID class JdbcBreakSkillTargetConfigPersistence[F[_]: Sync] extends BreakSkillTargetConfigPersistence[F] { - override def read(key: UUID): F[Option[Set[BreakSkillTargetConfig]]] = Sync[F].delay { - DB.readOnly { implicit session => - val breakFlags = - sql"SELECT flag_name, include FROM player_break_preference WHERE uuid = ${key.toString}" - .map { rs => - BreakSkillTargetConfigKey.withNameOption(rs.string("flag_name")).map { flagName => - BreakSkillTargetConfig(flagName, rs.boolean("include")) + + import cats.implicits._ + + override def read(key: UUID): F[Option[BreakSkillTargetConfigRepository[F]]] = { + for { + breakSkillTargetConfig <- Sync[F].delay { + DB.readOnly { implicit session => + sql"SELECT flag_name, include FROM player_break_preference WHERE uuid = ${key.toString}" + .map { rs => + BreakSkillTargetConfigKey.withNameOption(rs.string("flag_name")).map { flagName => + BreakSkillTargetConfig(flagName, rs.boolean("include")) + } } - } - .toList() - .apply() - .collect { case Some(flag) => flag } - .toSet - - Some(breakFlags) - } + .toList() + .apply() + .collect { case Some(flag) => flag } + .toSet + } + } + repository = new BreakSkillTargetConfigRepository[F] + _ <- repository.setConfig(breakSkillTargetConfig) + } yield Some(repository) } - override def write(key: UUID, value: Set[BreakSkillTargetConfig]): F[Unit] = Sync[F].delay { - DB.localTx { implicit session => - val uuid = key.toString - val batchParams = value.map { flag => - Seq(uuid, flag.configKey.entryName, flag.includes) - }.toSeq - - sql"""INSERT INTO player_break_preference (uuid, flag_name, include) - | VALUES (?, ?, ?) - | ON DUPLICATE KEY UPDATE - | include = VALUE(include) - """.stripMargin.batch(batchParams: _*).apply[List]() - } + override def write(key: UUID, value: BreakSkillTargetConfigRepository[F]): F[Unit] = { + for { + currentConfig <- value.getConfigAll + _ <- Sync[F].delay { + DB.localTx { implicit session => + val uuid = key.toString + val batchParams = + currentConfig.map { flag => + Seq(uuid, flag.configKey.entryName, flag.includes) + }.toSeq + + sql"""INSERT INTO player_break_preference (uuid, flag_name, include) + | VALUES (?, ?, ?) + | ON DUPLICATE KEY UPDATE + | include = VALUE(include) + """.stripMargin.batch(batchParams: _*).apply[List]() + } + } + } yield () } } From f4a76242729efa7c1373a0e6a0550b3c836aa375 Mon Sep 17 00:00:00 2001 From: rito528 Date: Wed, 14 Jun 2023 10:03:19 +0900 Subject: [PATCH 44/59] =?UTF-8?q?chore:=20BreakSkillTargetConfigRepository?= =?UTF-8?q?=E3=82=92=E5=BB=83=E6=AD=A2=E3=81=97=E3=80=81BreaskSkillTargetC?= =?UTF-8?q?onfigDefinition=E3=81=A7Ref=E3=82=92=E7=AE=A1=E7=90=86=E3=81=99?= =?UTF-8?q?=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../breakskilltargetconfig/System.scala | 6 +- ...killTargetConfigRepositoryDefinition.scala | 12 +-- .../domain/BreakSkillTargetConfig.scala | 31 +++++++- .../BreakSkillTargetConfigPersistence.scala | 3 +- .../BreakSkillTargetConfigRepository.scala | 50 ------------ ...dbcBreakSkillTargetConfigPersistence.scala | 76 +++++++++---------- 6 files changed, 77 insertions(+), 101 deletions(-) delete mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/domain/BreakSkillTargetConfigRepository.scala 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 index a40fd88a57..08ded6514f 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/System.scala @@ -41,7 +41,7 @@ object System { Kleisli { player => ContextCoercion( breakSkillTargetConfigRepository(player) - .toggleBreakSkillTargetConfig(configKey) + .update(_.toggleBreakSkillTargetConfig(configKey)) ) } @@ -50,7 +50,9 @@ object System { configKey: BreakSkillTargetConfigKey ): F[Boolean] = ContextCoercion( - breakSkillTargetConfigRepository(player).breakSkillTargetConfig(configKey) + breakSkillTargetConfigRepository(player) + .get + .map(_.breakSkillTargetConfig(configKey)) ) } 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 index c1a9200e73..05d871b5c5 100644 --- 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 @@ -1,21 +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.{ - BreakSkillTargetConfigPersistence, - BreakSkillTargetConfigRepository + BreakSkillTargetConfig, + BreakSkillTargetConfigPersistence } object BreakSkillTargetConfigRepositoryDefinition { def withContext[F[_]: Sync, Player]( implicit persistence: BreakSkillTargetConfigPersistence[F] - ): RepositoryDefinition[F, Player, BreakSkillTargetConfigRepository[F]] = + ): RepositoryDefinition[F, Player, Ref[F, BreakSkillTargetConfig]] = RefDictBackedRepositoryDefinition - .usingUuidRefDict[F, Player, BreakSkillTargetConfigRepository[F]](persistence)( - new BreakSkillTargetConfigRepository[F] + .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 index f88e261239..6f8c0a4cac 100644 --- 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 @@ -1,3 +1,32 @@ package com.github.unchama.seichiassist.subsystems.breakskilltargetconfig.domain -case class BreakSkillTargetConfig(configKey: BreakSkillTargetConfigKey, includes: Boolean) +case class BreakSkillTargetConfig(config: Map[BreakSkillTargetConfigKey, Boolean]) { + + /** + * @return `configKey`の破壊フラグをトグルする作用 + */ + def toggleBreakSkillTargetConfig( + configKey: BreakSkillTargetConfigKey + ): BreakSkillTargetConfig = + this.copy( + this.config.filterNot(_._1 == configKey) ++ Map( + 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/BreakSkillTargetConfigPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/domain/BreakSkillTargetConfigPersistence.scala index 7a864135e9..6c91b1a752 100644 --- 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 @@ -4,5 +4,4 @@ import com.github.unchama.generic.RefDict import java.util.UUID -trait BreakSkillTargetConfigPersistence[F[_]] - extends RefDict[F, UUID, BreakSkillTargetConfigRepository[F]] +trait BreakSkillTargetConfigPersistence[F[_]] extends RefDict[F, UUID, BreakSkillTargetConfig] diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/domain/BreakSkillTargetConfigRepository.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/domain/BreakSkillTargetConfigRepository.scala deleted file mode 100644 index 411d3c1ddd..0000000000 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/breakskilltargetconfig/domain/BreakSkillTargetConfigRepository.scala +++ /dev/null @@ -1,50 +0,0 @@ -package com.github.unchama.seichiassist.subsystems.breakskilltargetconfig.domain - -import cats.effect.Sync -import cats.effect.concurrent.Ref - -class BreakSkillTargetConfigRepository[F[_]: Sync] { - - import cats.implicits._ - - private val breakSkillTargetConfigs: Ref[F, Set[BreakSkillTargetConfig]] = - Ref.unsafe(Set.empty) - - /** - * @return `configKey`の破壊フラグをトグルする作用 - */ - def toggleBreakSkillTargetConfig(configKey: BreakSkillTargetConfigKey): F[Unit] = for { - _ <- breakSkillTargetConfigs.getAndUpdate { breakFlags => - val currentTargetBreakConfig = - breakFlags.find(_.configKey == configKey).exists(_.includes) - - breakFlags.filterNot(_.configKey == configKey) + BreakSkillTargetConfig( - configKey, - includes = !currentTargetBreakConfig - ) - } - } yield () - - /** - * @return 現在の破壊フラグを取得する作用 - */ - def breakSkillTargetConfig(configKey: BreakSkillTargetConfigKey): F[Boolean] = { - for { - config <- breakSkillTargetConfigs.get - } yield config.find(_.configKey == configKey).exists(_.includes) - } - - /** - * この関数は永続化層で利用されることを想定しています。 - * @return 現在の[[BreakSkillTargetConfig]]をすべて取得する作用 - */ - def getConfigAll: F[Set[BreakSkillTargetConfig]] = breakSkillTargetConfigs.get - - /** - * この関数は永続化層で利用することを想定しています。 - * @return 現在の設定を`config`で上書きする作用 - */ - def setConfig(config: Set[BreakSkillTargetConfig]): F[Unit] = - breakSkillTargetConfigs.set(config) - -} 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 index 753a3b1847..6f2b50ed5a 100644 --- 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 @@ -4,8 +4,7 @@ import cats.effect.Sync import com.github.unchama.seichiassist.subsystems.breakskilltargetconfig.domain.{ BreakSkillTargetConfig, BreakSkillTargetConfigKey, - BreakSkillTargetConfigPersistence, - BreakSkillTargetConfigRepository + BreakSkillTargetConfigPersistence } import scalikejdbc.{DB, scalikejdbcSQLInterpolationImplicitDef} @@ -14,48 +13,43 @@ import java.util.UUID class JdbcBreakSkillTargetConfigPersistence[F[_]: Sync] extends BreakSkillTargetConfigPersistence[F] { - import cats.implicits._ - - override def read(key: UUID): F[Option[BreakSkillTargetConfigRepository[F]]] = { - for { - breakSkillTargetConfig <- Sync[F].delay { - DB.readOnly { implicit session => - sql"SELECT flag_name, include FROM player_break_preference WHERE uuid = ${key.toString}" - .map { rs => - BreakSkillTargetConfigKey.withNameOption(rs.string("flag_name")).map { flagName => - BreakSkillTargetConfig(flagName, rs.boolean("include")) - } - } - .toList() - .apply() - .collect { case Some(flag) => flag } - .toSet + override def read(key: UUID): F[Option[BreakSkillTargetConfig]] = Sync[F].delay { + val config = DB.readOnly { implicit session => + sql"SELECT flag_name, include FROM player_break_preference WHERE uuid = ${key.toString}" + .map { rs => + BreakSkillTargetConfigKey.withNameOption(rs.string("flag_name")).map { flagName => + Map(flagName -> rs.boolean("include")) + } } - } - repository = new BreakSkillTargetConfigRepository[F] - _ <- repository.setConfig(breakSkillTargetConfig) - } yield Some(repository) + .toList() + .apply() + .collect { case Some(flag) => flag } + .foldLeft(Map.empty[BreakSkillTargetConfigKey, Boolean]) { + case (previous, next) => previous ++ next + } + } + + Some(BreakSkillTargetConfig(config)) } - override def write(key: UUID, value: BreakSkillTargetConfigRepository[F]): F[Unit] = { - for { - currentConfig <- value.getConfigAll - _ <- Sync[F].delay { - DB.localTx { implicit session => - val uuid = key.toString - val batchParams = - currentConfig.map { flag => - Seq(uuid, flag.configKey.entryName, flag.includes) - }.toSeq - - sql"""INSERT INTO player_break_preference (uuid, flag_name, include) - | VALUES (?, ?, ?) - | ON DUPLICATE KEY UPDATE - | include = VALUE(include) - """.stripMargin.batch(batchParams: _*).apply[List]() - } - } - } yield () + 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 (configKey, includes) => + Seq(uuid, configKey.entryName, includes) + } + .toSeq + + sql"""INSERT INTO player_break_preference (uuid, flag_name, include) + | VALUES (?, ?, ?) + | ON DUPLICATE KEY UPDATE + | include = VALUE(include) + """.stripMargin.batch(batchParams: _*).apply[List]() + } } } From c6bbf1a8715fcd7614123c38575f482411518465 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 16 Jun 2023 20:34:15 +0000 Subject: [PATCH 45/59] chore(deps): update dependency eu.timepit:refined to v0.11.0 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 923b1fbea1..00b86b5744 100644 --- a/build.sbt +++ b/build.sbt @@ -103,7 +103,7 @@ val dependenciesToEmbed = Seq( "com.typesafe.scala-logging" % "scala-logging-slf4j_2.10" % "2.1.2", // type-safety utils - "eu.timepit" %% "refined" % "0.10.3", + "eu.timepit" %% "refined" % "0.11.0", "com.beachape" %% "enumeratum" % "1.7.2", // protobuf From a3bed294e080e0b692734557e3cc5ab4b4a9ae60 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 21 Jun 2023 20:35:29 +0000 Subject: [PATCH 46/59] chore(deps): update dependency commons-codec:commons-codec to v1.16.0 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 4627ebf8e5..7510e6da0c 100644 --- a/build.sbt +++ b/build.sbt @@ -57,7 +57,7 @@ resolvers ++= Seq( val providedDependencies = Seq( "org.jetbrains" % "annotations" % "24.0.1", "org.apache.commons" % "commons-lang3" % "3.12.0", - "commons-codec" % "commons-codec" % "1.15", + "commons-codec" % "commons-codec" % "1.16.0", "org.spigotmc" % "spigot-api" % "1.12.2-R0.1-SNAPSHOT", // https://maven.enginehub.org/repo/com/sk89q/worldedit/worldedit-bukkit/ "com.sk89q.worldguard" % "worldguard-legacy" % "6.2", From fa340ff7a7a74c51d78802b327b35ba1fc44b2b7 Mon Sep 17 00:00:00 2001 From: rito528 <39003544+rito528@users.noreply.github.com> Date: Fri, 30 Jun 2023 14:51:05 +0900 Subject: [PATCH 47/59] =?UTF-8?q?fix:=20=E3=82=AC=E3=83=81=E3=83=A3?= =?UTF-8?q?=E3=82=A4=E3=83=99=E3=83=B3=E3=83=88=E3=81=AE=E9=96=8B=E5=82=AC?= =?UTF-8?q?=E6=97=A5=E6=99=82=E3=81=AB=E5=88=9D=E6=97=A5=E3=81=8C=E5=90=AB?= =?UTF-8?q?=E3=81=BE=E3=82=8C=E3=81=A6=E3=81=84=E3=81=AA=E3=81=8B=E3=81=A3?= =?UTF-8?q?=E3=81=9F=E4=B8=8D=E5=85=B7=E5=90=88=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../subsystems/gachaprize/domain/gachaevent/GachaEvent.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/gachaprize/domain/gachaevent/GachaEvent.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/gachaprize/domain/gachaevent/GachaEvent.scala index 8d7c837ea9..6d273ca905 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/gachaprize/domain/gachaevent/GachaEvent.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/gachaprize/domain/gachaevent/GachaEvent.scala @@ -28,7 +28,7 @@ case class GachaEvent(eventName: GachaEventName, startDate: LocalDate, endDate: def isHolding: Boolean = { val now = LocalDate.now() - now.isAfter(startDate) && now.isBefore(endDate) + now.isAfter(startDate.minusDays(1)) && now.isBefore(endDate) } } From 40ca34fa16ea8cf08535763baa9328042b573f70 Mon Sep 17 00:00:00 2001 From: rito528 <39003544+rito528@users.noreply.github.com> Date: Fri, 30 Jun 2023 15:31:26 +0900 Subject: [PATCH 48/59] =?UTF-8?q?fix:=20=E7=B5=82=E4=BA=86=E6=97=A5?= =?UTF-8?q?=E6=99=82=E3=82=82=E7=9B=B4=E3=81=97=E3=80=81=E5=A4=89=E6=95=B0?= =?UTF-8?q?=E3=81=AB=E5=88=87=E3=82=8A=E5=87=BA=E3=81=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../subsystems/gachaprize/domain/gachaevent/GachaEvent.scala | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/gachaprize/domain/gachaevent/GachaEvent.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/gachaprize/domain/gachaevent/GachaEvent.scala index 6d273ca905..2c62c67a01 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/gachaprize/domain/gachaevent/GachaEvent.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/gachaprize/domain/gachaevent/GachaEvent.scala @@ -27,8 +27,10 @@ case class GachaEvent(eventName: GachaEventName, startDate: LocalDate, endDate: */ def isHolding: Boolean = { val now = LocalDate.now() + val isAfterStartDate = now.equals(startDate) || now.isAfter(startDate) + val isBeforeEndDate = now.equals(endDate) || now.isBefore(endDate) - now.isAfter(startDate.minusDays(1)) && now.isBefore(endDate) + isAfterStartDate && isBeforeEndDate } } From ac7a149c1e77f2e2a25671420633f0b3e660d4ae Mon Sep 17 00:00:00 2001 From: rito528 <39003544+rito528@users.noreply.github.com> Date: Fri, 30 Jun 2023 15:39:50 +0900 Subject: [PATCH 49/59] =?UTF-8?q?style:=20=E5=A4=89=E6=95=B0=E3=81=AE?= =?UTF-8?q?=E5=91=BD=E5=90=8D=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gachaprize/domain/gachaevent/GachaEvent.scala | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/gachaprize/domain/gachaevent/GachaEvent.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/gachaprize/domain/gachaevent/GachaEvent.scala index 2c62c67a01..1cafb099b4 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/gachaprize/domain/gachaevent/GachaEvent.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/gachaprize/domain/gachaevent/GachaEvent.scala @@ -27,10 +27,10 @@ case class GachaEvent(eventName: GachaEventName, startDate: LocalDate, endDate: */ def isHolding: Boolean = { val now = LocalDate.now() - val isAfterStartDate = now.equals(startDate) || now.isAfter(startDate) - val isBeforeEndDate = now.equals(endDate) || now.isBefore(endDate) + val isAfterStartDateOrFirstDay = now.equals(startDate) || now.isAfter(startDate) + val isBeforeEndDateOrFinalDay = now.equals(endDate) || now.isBefore(endDate) - isAfterStartDate && isBeforeEndDate + isAfterStartDateOrFirstDay && isBeforeEndDateOrFinalDay } } From c9489b3a7df088e0f3c1506d91c3a948600c7fe4 Mon Sep 17 00:00:00 2001 From: rito528 <39003544+rito528@users.noreply.github.com> Date: Fri, 30 Jun 2023 15:54:49 +0900 Subject: [PATCH 50/59] style: final -> end --- .../subsystems/gachaprize/domain/gachaevent/GachaEvent.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/gachaprize/domain/gachaevent/GachaEvent.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/gachaprize/domain/gachaevent/GachaEvent.scala index 1cafb099b4..727355caa8 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/gachaprize/domain/gachaevent/GachaEvent.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/gachaprize/domain/gachaevent/GachaEvent.scala @@ -28,9 +28,9 @@ case class GachaEvent(eventName: GachaEventName, startDate: LocalDate, endDate: def isHolding: Boolean = { val now = LocalDate.now() val isAfterStartDateOrFirstDay = now.equals(startDate) || now.isAfter(startDate) - val isBeforeEndDateOrFinalDay = now.equals(endDate) || now.isBefore(endDate) + val isBeforeEndDateOrEndDay = now.equals(endDate) || now.isBefore(endDate) - isAfterStartDateOrFirstDay && isBeforeEndDateOrFinalDay + isAfterStartDateOrFirstDay && isBeforeEndDateOrEndDay } } From fb90e1477d78382c981aefd07ce58abec76544aa Mon Sep 17 00:00:00 2001 From: rito528 <39003544+rito528@users.noreply.github.com> Date: Fri, 30 Jun 2023 15:58:48 +0900 Subject: [PATCH 51/59] =?UTF-8?q?docs:=20=E8=BF=94=E3=82=8A=E5=80=A4?= =?UTF-8?q?=E3=81=AE=E8=A1=A8=E8=A8=98=E3=82=92=E9=81=A9=E5=88=87=E3=81=AA?= =?UTF-8?q?=E3=82=82=E3=81=AE=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/BreakSkillTargetConfig.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 index 6f8c0a4cac..7c77badf07 100644 --- 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 @@ -3,7 +3,7 @@ package com.github.unchama.seichiassist.subsystems.breakskilltargetconfig.domain case class BreakSkillTargetConfig(config: Map[BreakSkillTargetConfigKey, Boolean]) { /** - * @return `configKey`の破壊フラグをトグルする作用 + * @return `configKey`の破壊フラグをトグルする */ def toggleBreakSkillTargetConfig( configKey: BreakSkillTargetConfigKey @@ -15,7 +15,7 @@ case class BreakSkillTargetConfig(config: Map[BreakSkillTargetConfigKey, Boolean ) /** - * @return 現在の破壊フラグを取得する作用 + * @return 現在の破壊フラグを取得する */ def breakSkillTargetConfig(configKey: BreakSkillTargetConfigKey): Boolean = this.config.getOrElse(configKey, false) From 56d64f913301178d21d634a5ede59707dbc23833 Mon Sep 17 00:00:00 2001 From: rito528 <39003544+rito528@users.noreply.github.com> Date: Fri, 30 Jun 2023 16:00:03 +0900 Subject: [PATCH 52/59] =?UTF-8?q?refactor:=20BreakSkillTargetConfig?= =?UTF-8?q?=E3=81=AE=E8=AA=AD=E3=81=BF=E5=8F=96=E3=82=8A=E5=87=A6=E7=90=86?= =?UTF-8?q?=E3=82=92=E5=AE=8C=E7=B5=90=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../JdbcBreakSkillTargetConfigPersistence.scala | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) 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 index 6f2b50ed5a..fcff4103ad 100644 --- 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 @@ -18,15 +18,13 @@ class JdbcBreakSkillTargetConfigPersistence[F[_]: Sync] sql"SELECT flag_name, include FROM player_break_preference WHERE uuid = ${key.toString}" .map { rs => BreakSkillTargetConfigKey.withNameOption(rs.string("flag_name")).map { flagName => - Map(flagName -> rs.boolean("include")) + flagName -> rs.boolean("include") } } .toList() .apply() - .collect { case Some(flag) => flag } - .foldLeft(Map.empty[BreakSkillTargetConfigKey, Boolean]) { - case (previous, next) => previous ++ next - } + .flatten + .toMap } Some(BreakSkillTargetConfig(config)) From 66101e152a6caa0b3c522cd153fbd124fb33172f Mon Sep 17 00:00:00 2001 From: rito528 <39003544+rito528@users.noreply.github.com> Date: Fri, 30 Jun 2023 16:38:28 +0900 Subject: [PATCH 53/59] =?UTF-8?q?style:=20=E3=83=96=E3=83=AD=E3=83=83?= =?UTF-8?q?=E3=82=AF=E7=A0=B4=E5=A3=8A=E8=A8=AD=E5=AE=9A=E3=82=92=E4=BF=9D?= =?UTF-8?q?=E5=AD=98=E3=81=99=E3=82=8B=E3=83=86=E3=83=BC=E3=83=96=E3=83=AB?= =?UTF-8?q?=E3=81=AE=E3=82=AB=E3=83=A9=E3=83=A0=E5=90=8D=E3=82=92=E5=A4=89?= =?UTF-8?q?=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../db/migration/V1.17.0__Create_break_preference_table.sql | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 index fc5c847850..2b23aa3bb3 100644 --- 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 @@ -2,8 +2,8 @@ USE seichiassist; CREATE TABLE player_break_preference( uuid CHAR(36) NOT NULL, - flag_name ENUM('Chest', 'MadeFromNetherQuartz') NOT NULL, - include BOOL NOT NULL DEFAULT TRUE, - PRIMARY KEY(uuid, flag_name), + break_category ENUM('Chest', 'MadeFromNetherQuartz') NOT NULL, + do_break BOOL NOT NULL DEFAULT TRUE, + PRIMARY KEY(uuid, break_category), INDEX index_player_break_preference_on_uuid (uuid) ); From d959376f33c280db411492c51aec25de4c837877 Mon Sep 17 00:00:00 2001 From: rito528 <39003544+rito528@users.noreply.github.com> Date: Fri, 30 Jun 2023 16:40:33 +0900 Subject: [PATCH 54/59] =?UTF-8?q?fix:=20=E3=82=AB=E3=83=A9=E3=83=A0?= =?UTF-8?q?=E5=90=8D=E3=81=AE=E5=A4=89=E6=9B=B4=E3=81=AB=E5=90=88=E3=82=8F?= =?UTF-8?q?=E3=81=9B=E3=81=A6=E5=AE=9F=E8=A3=85=E5=81=B4=E3=82=82=E5=A4=89?= =?UTF-8?q?=E6=9B=B4=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../JdbcBreakSkillTargetConfigPersistence.scala | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) 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 index fcff4103ad..2ed07fa43d 100644 --- 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 @@ -15,10 +15,10 @@ class JdbcBreakSkillTargetConfigPersistence[F[_]: Sync] override def read(key: UUID): F[Option[BreakSkillTargetConfig]] = Sync[F].delay { val config = DB.readOnly { implicit session => - sql"SELECT flag_name, include FROM player_break_preference WHERE uuid = ${key.toString}" + sql"SELECT block_category, do_break FROM player_break_preference WHERE uuid = ${key.toString}" .map { rs => - BreakSkillTargetConfigKey.withNameOption(rs.string("flag_name")).map { flagName => - flagName -> rs.boolean("include") + BreakSkillTargetConfigKey.withNameOption(rs.string("block_category")).map { + flagName => flagName -> rs.boolean("do_break") } } .toList() @@ -37,15 +37,15 @@ class JdbcBreakSkillTargetConfigPersistence[F[_]: Sync] value .config .map { - case (configKey, includes) => - Seq(uuid, configKey.entryName, includes) + case (blockCategory, doBreak) => + Seq(uuid, blockCategory.entryName, doBreak) } .toSeq - sql"""INSERT INTO player_break_preference (uuid, flag_name, include) + sql"""INSERT INTO player_break_preference (uuid, block_category, do_break) | VALUES (?, ?, ?) | ON DUPLICATE KEY UPDATE - | include = VALUE(include) + | do_break = VALUE(do_break) """.stripMargin.batch(batchParams: _*).apply[List]() } } From 7f70ae8922651802ebf9392d950dc52e00ec45a2 Mon Sep 17 00:00:00 2001 From: rito528 <39003544+rito528@users.noreply.github.com> Date: Fri, 30 Jun 2023 16:44:17 +0900 Subject: [PATCH 55/59] =?UTF-8?q?fix:=20=E5=88=87=E3=82=8A=E6=9B=BF?= =?UTF-8?q?=E3=81=88=E5=BE=8C=E3=81=AE=E3=83=A1=E3=83=83=E3=82=BB=E3=83=BC?= =?UTF-8?q?=E3=82=B8=E3=81=8C=E9=80=86=E3=81=AE=E3=82=82=E3=81=AE=E3=81=8C?= =?UTF-8?q?=E8=A1=A8=E7=A4=BA=E3=81=95=E3=82=8C=E3=81=A6=E3=81=97=E3=81=BE?= =?UTF-8?q?=E3=81=86=E4=B8=8D=E5=85=B7=E5=90=88=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../menus/skill/PassiveSkillMenu.scala | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) 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 c3503dae3b..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 @@ -147,16 +147,16 @@ object PassiveSkillMenu extends Menu { import environment._ val computeToggleChestBreakButton: IO[Button] = RecomputedButton(for { - breakChest <- breakSkillTargetConfigAPI + originalBreakChestConfig <- breakSkillTargetConfigAPI .breakSkillTargetConfig(player, BreakSkillTargetConfigKey.Chest) } yield { val baseLore = List(s"${GREEN}スキルでチェストを破壊するスキル") - val statusLore = if (breakChest) { + val statusLore = if (originalBreakChestConfig) { List(s"${RED}整地ワールドのみで発動中(デフォルト)", "", s"$DARK_GREEN${UNDERLINE}クリックで切り替え") } else { List(s"${RED}発動しません", "", s"$DARK_GREEN${UNDERLINE}クリックで切り替え") } - val material = if (breakChest) Material.DIAMOND_AXE else Material.CHEST + val material = if (originalBreakChestConfig) Material.DIAMOND_AXE else Material.CHEST Button( new IconItemStackBuilder(material) @@ -169,7 +169,7 @@ object PassiveSkillMenu extends Menu { BreakSkillTargetConfigKey.Chest ), DeferredEffect(IO { - if (breakChest) { + if (!originalBreakChestConfig) { SequentialEffect( MessageEffect(s"${GREEN}スキルでのチェスト破壊を有効化しました。"), FocusedSoundEffect(Sound.BLOCK_STONE_BUTTON_CLICK_ON, 1f, 1f) @@ -187,11 +187,11 @@ object PassiveSkillMenu extends Menu { }) val computeToggleNetherQuartzBlockButton: IO[Button] = RecomputedButton(for { - breakQuartz <- breakSkillTargetConfigAPI + originalBreakQuartz <- breakSkillTargetConfigAPI .breakSkillTargetConfig(player, BreakSkillTargetConfigKey.MadeFromNetherQuartz) } yield { val baseLore = List(s"${YELLOW}スキルでネザー水晶類ブロックを破壊するスキル") - val statusLore = if (breakQuartz) { + val statusLore = if (originalBreakQuartz) { List(s"${GREEN}ON (スキルでネザー水晶類ブロックを破壊します。)", s"${DARK_RED}クリックでOFF") } else { List(s"${RED}OFF (スキルでネザー水晶類ブロックを破壊しません。)", s"${DARK_GREEN}クリックでON") @@ -200,7 +200,7 @@ object PassiveSkillMenu extends Menu { Button( new IconItemStackBuilder(Material.QUARTZ_BLOCK) .tap { builder => - if (breakQuartz) + if (originalBreakQuartz) builder.enchanted() } .title(s"$WHITE$UNDERLINE${BOLD}ネザー水晶類ブロック破壊スキル切り替え") @@ -212,7 +212,7 @@ object PassiveSkillMenu extends Menu { BreakSkillTargetConfigKey.MadeFromNetherQuartz ), DeferredEffect(IO { - if (breakQuartz) { + if (!originalBreakQuartz) { SequentialEffect( MessageEffect(s"${GREEN}スキルでのネザー水晶類ブロック破壊を有効化しました。"), FocusedSoundEffect(Sound.BLOCK_STONE_BUTTON_CLICK_ON, 1f, 1f) From 6c35ea876a703b195adb6d004aba7fc52a3cb3e0 Mon Sep 17 00:00:00 2001 From: rito528 <39003544+rito528@users.noreply.github.com> Date: Fri, 30 Jun 2023 16:45:22 +0900 Subject: [PATCH 56/59] =?UTF-8?q?refactor:=20Map=E3=81=AE=E4=B8=8A?= =?UTF-8?q?=E6=9B=B8=E3=81=8D=E3=82=92=E3=82=88=E3=82=8A=E7=B0=A1=E6=BD=94?= =?UTF-8?q?=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/BreakSkillTargetConfig.scala | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) 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 index 7c77badf07..ea916a8348 100644 --- 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 @@ -8,11 +8,7 @@ case class BreakSkillTargetConfig(config: Map[BreakSkillTargetConfigKey, Boolean def toggleBreakSkillTargetConfig( configKey: BreakSkillTargetConfigKey ): BreakSkillTargetConfig = - this.copy( - this.config.filterNot(_._1 == configKey) ++ Map( - configKey -> this.config.getOrElse(configKey, false) - ) - ) + this.copy(this.config + (configKey -> this.config.getOrElse(configKey, false))) /** * @return 現在の破壊フラグを取得する From ab68cb662293eb386988a7cf5d90a85d882401ad Mon Sep 17 00:00:00 2001 From: rito528 <39003544+rito528@users.noreply.github.com> Date: Fri, 30 Jun 2023 20:12:26 +0900 Subject: [PATCH 57/59] chore: break_category -> block_category --- .../db/migration/V1.17.0__Create_break_preference_table.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 index 2b23aa3bb3..3e2b33c847 100644 --- 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 @@ -2,8 +2,8 @@ USE seichiassist; CREATE TABLE player_break_preference( uuid CHAR(36) NOT NULL, - break_category ENUM('Chest', 'MadeFromNetherQuartz') NOT NULL, + block_category ENUM('Chest', 'MadeFromNetherQuartz') NOT NULL, do_break BOOL NOT NULL DEFAULT TRUE, - PRIMARY KEY(uuid, break_category), + PRIMARY KEY(uuid, block_category), INDEX index_player_break_preference_on_uuid (uuid) ); From b5b65e1eee35da17c8b637b1c54f7c4dac2a9020 Mon Sep 17 00:00:00 2001 From: rito528 <39003544+rito528@users.noreply.github.com> Date: Sun, 2 Jul 2023 23:37:56 +0900 Subject: [PATCH 58/59] =?UTF-8?q?fix:=20=E3=82=AC=E3=83=81=E3=83=A3?= =?UTF-8?q?=E6=99=AF=E5=93=81=E3=81=8C=E5=89=8A=E9=99=A4=E3=81=95=E3=82=8C?= =?UTF-8?q?=E3=81=AA=E3=81=84=E4=B8=8D=E5=85=B7=E5=90=88=E3=82=92=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../unchama/seichiassist/subsystems/gachaprize/System.scala | 1 + .../gachaprize/domain/GachaPrizeListPersistence.scala | 5 +++++ .../infrastructure/JdbcGachaPrizeListPersistence.scala | 6 ++++++ 3 files changed, 12 insertions(+) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/gachaprize/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/gachaprize/System.scala index eeaf1c9670..5321dce06a 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/gachaprize/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/gachaprize/System.scala @@ -91,6 +91,7 @@ object System { prizes.filterNot(_.id == gachaPrizeId) } _ <- _gachaPersistence.deleteMineStackGachaObject(gachaPrizeId) + _ <- _gachaPersistence.removeGachaPrize(gachaPrizeId) } yield () override def addGachaPrize(gachaPrize: GachaPrizeByGachaPrizeId): F[Unit] = for { diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/gachaprize/domain/GachaPrizeListPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/gachaprize/domain/GachaPrizeListPersistence.scala index 6a86c01521..8ebb5d1976 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/gachaprize/domain/GachaPrizeListPersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/gachaprize/domain/GachaPrizeListPersistence.scala @@ -22,6 +22,11 @@ trait GachaPrizeListPersistence[F[_], ItemStack] { */ def addGachaPrizes(gachaPrizes: Vector[GachaPrize[ItemStack]]): F[Unit] + /** + * @return ガチャアイテムを削除する作用 + */ + def removeGachaPrize(gachaPrizeId: GachaPrizeId): F[Unit] + /** * @return ガチャリストを更新する作用 */ diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/gachaprize/infrastructure/JdbcGachaPrizeListPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/gachaprize/infrastructure/JdbcGachaPrizeListPersistence.scala index 84770d875e..2554f60f85 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/gachaprize/infrastructure/JdbcGachaPrizeListPersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/gachaprize/infrastructure/JdbcGachaPrizeListPersistence.scala @@ -60,6 +60,12 @@ class JdbcGachaPrizeListPersistence[F[_]: Sync, ItemStack: Cloneable]( } } + override def removeGachaPrize(gachaPrizeId: GachaPrizeId): F[Unit] = Sync[F].delay { + DB.localTx { implicit session => + sql"DELETE FROM gachadata WHERE id = ${gachaPrizeId.id}".execute().apply() + } + } + override def addGachaPrizes(gachaPrizes: Vector[GachaPrize[ItemStack]]): F[Unit] = Sync[F].delay { DB.localTx { implicit session => From 7ac3d9c3eb83237460effc2f75de132b0e948521 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sun, 2 Jul 2023 15:03:30 +0000 Subject: [PATCH 59/59] chore(bump): 83 -> 84 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index f0b1ddb383..08350e4bc9 100644 --- a/build.sbt +++ b/build.sbt @@ -8,7 +8,7 @@ import java.io._ ThisBuild / scalaVersion := "2.13.11" // ThisBuild / version はGitHub Actionsによって取得/自動更新される。 // 次の行は ThisBuild / version := "(\d*)" の形式でなければならない。 -ThisBuild / version := "83" +ThisBuild / version := "84" ThisBuild / organization := "click.seichi" ThisBuild / description := "ギガンティック☆整地鯖の独自要素を司るプラグイン"