Skip to content

Commit

Permalink
Merge branch 'develop' into 1_18
Browse files Browse the repository at this point in the history
  • Loading branch information
outductor authored Jul 3, 2023
2 parents 47901df + a980dc5 commit ace8e7d
Show file tree
Hide file tree
Showing 20 changed files with 316 additions and 48 deletions.
9 changes: 3 additions & 6 deletions .github/workflows/build_and_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion .idea/codeStyles/codeStyleConfig.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -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 := "ギガンティック☆整地鯖の独自要素を司るプラグイン"

Expand Down Expand Up @@ -59,7 +59,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.18.2-R0.1-SNAPSHOT",
// https://maven.enginehub.org/repo/com/sk89q/worldedit/worldedit-bukkit/
"com.sk89q.worldguard" % "worldguard-bukkit" % "7.0.7",
Expand Down Expand Up @@ -108,7 +108,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
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
USE seichiassist;

CREATE TABLE player_break_preference(
uuid CHAR(36) NOT NULL,
block_category ENUM('Chest', 'MadeFromNetherQuartz') NOT NULL,
do_break BOOL NOT NULL DEFAULT TRUE,
PRIMARY KEY(uuid, block_category),
INDEX index_player_break_preference_on_uuid (uuid)
);
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ import com.github.unchama.seichiassist.subsystems._
import com.github.unchama.seichiassist.subsystems.anywhereender.AnywhereEnderChestAPI
import com.github.unchama.seichiassist.subsystems.breakcount.{BreakCountAPI, BreakCountReadAPI}
import com.github.unchama.seichiassist.subsystems.breakcountbar.BreakCountBarAPI
import com.github.unchama.seichiassist.subsystems.breakskilltargetconfig.BreakSkillTargetConfigAPI
import com.github.unchama.seichiassist.subsystems.buildcount.BuildCountAPI
import com.github.unchama.seichiassist.subsystems.discordnotification.DiscordNotificationAPI
import com.github.unchama.seichiassist.subsystems.donate.DonatePremiumPointAPI
Expand Down Expand Up @@ -478,6 +479,11 @@ class SeichiAssist extends JavaPlugin() {
subsystems.vote.subsystems.fairyspeech.System.wired[IO]
}

/* TODO: breakSkillTargetConfigSystemは本来privateであるべきだが、
BreakUtilで呼び出されているため、やむを得ずpublicになっている */
lazy val breakSkillTargetConfigSystem: subsystems.breakskilltargetconfig.System[IO, Player] =
subsystems.breakskilltargetconfig.System.wired[IO, SyncIO].unsafeRunSync()

/* TODO: mineStackSystemは本来privateであるべきだが、mineStackにアイテムを格納するAPIが現状の
BreakUtilの実装から呼び出されている都合上やむを得ずpublicになっている。*/
lazy val mineStackSystem: subsystems.minestack.System[IO, Player, ItemStack] =
Expand Down Expand Up @@ -518,7 +524,8 @@ class SeichiAssist extends JavaPlugin() {
sharedInventorySystem,
mineStackSystem,
consumeGachaTicketSystem,
openirontrapdoor.System.wired
openirontrapdoor.System.wired,
breakSkillTargetConfigSystem
)

private lazy val buildAssist: BuildAssist = {
Expand Down Expand Up @@ -693,6 +700,8 @@ class SeichiAssist extends JavaPlugin() {
implicit val gachaAPI: GachaDrawAPI[IO, Player] = gachaSystem.api
implicit val consumeGachaTicketAPI: ConsumeGachaTicketAPI[IO, Player] =
consumeGachaTicketSystem.api
implicit val breakSkillTargetConfigAPI: BreakSkillTargetConfigAPI[IO, Player] =
breakSkillTargetConfigSystem.api

val menuRouter = TopLevelRouter.apply
import SeichiAssist.Scopes.globalChatInterceptionScope
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
// 投票受け取りボタン連打防止用
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import com.github.unchama.seichiassist.subsystems.anywhereender.AnywhereEnderChe
import com.github.unchama.seichiassist.subsystems.breakcount.BreakCountAPI
import com.github.unchama.seichiassist.subsystems.breakcount.domain.SeichiAmountData
import com.github.unchama.seichiassist.subsystems.breakcountbar.BreakCountBarAPI
import com.github.unchama.seichiassist.subsystems.breakskilltargetconfig.BreakSkillTargetConfigAPI
import com.github.unchama.seichiassist.subsystems.buildcount.domain.playerdata.BuildAmountData
import com.github.unchama.seichiassist.subsystems.discordnotification.DiscordNotificationAPI
import com.github.unchama.seichiassist.subsystems.donate.DonatePremiumPointAPI
Expand Down Expand Up @@ -96,7 +97,8 @@ object TopLevelRouter {
mineStackAPI: MineStackAPI[IO, Player, ItemStack],
gachaDrawAPI: GachaDrawAPI[IO, Player],
consumeGachaTicketAPI: ConsumeGachaTicketAPI[IO, Player],
fairySpeechAPI: FairySpeechAPI[IO, Player]
fairySpeechAPI: FairySpeechAPI[IO, Player],
breakSkillTargetConfigAPI: BreakSkillTargetConfigAPI[IO, Player]
): TopLevelRouter[IO] = new TopLevelRouter[IO] {
import assortedRankingApi._

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import com.github.unchama.seichiassist.data.MenuInventoryData
import com.github.unchama.seichiassist.menus.CommonButtons
import com.github.unchama.seichiassist.menus.stickmenu.FirstPage
import com.github.unchama.seichiassist.subsystems.breakcount.BreakCountAPI
import com.github.unchama.seichiassist.subsystems.breakskilltargetconfig.BreakSkillTargetConfigAPI
import com.github.unchama.seichiassist.subsystems.breakskilltargetconfig.domain.BreakSkillTargetConfigKey
import com.github.unchama.targetedeffect._
import com.github.unchama.targetedeffect.commandsender.MessageEffect
import com.github.unchama.targetedeffect.player.FocusedSoundEffect
Expand All @@ -30,6 +32,7 @@ object PassiveSkillMenu extends Menu {

class Environment(
implicit val breakCountApi: BreakCountAPI[IO, SyncIO, Player],
implicit val breakSkillTargetConfigAPI: BreakSkillTargetConfigAPI[IO, Player],
val ioCanOpenFirstPage: IO CanOpen FirstPage.type
)

Expand Down Expand Up @@ -141,16 +144,19 @@ object PassiveSkillMenu extends Menu {
)
}

val computeToggleChestBreakButton: IO[Button] = RecomputedButton(IO {
val openerData = SeichiAssist.playermap(getUniqueId)
import environment._

val computeToggleChestBreakButton: IO[Button] = RecomputedButton(for {
originalBreakChestConfig <- breakSkillTargetConfigAPI
.breakSkillTargetConfig(player, BreakSkillTargetConfigKey.Chest)
} yield {
val baseLore = List(s"${GREEN}スキルでチェストを破壊するスキル")
val statusLore = if (openerData.chestflag) {
val statusLore = if (originalBreakChestConfig) {
List(s"${RED}整地ワールドのみで発動中(デフォルト)", "", s"$DARK_GREEN${UNDERLINE}クリックで切り替え")
} else {
List(s"${RED}発動しません", "", s"$DARK_GREEN${UNDERLINE}クリックで切り替え")
}
val material = if (openerData.chestflag) Material.DIAMOND_AXE else Material.CHEST
val material = if (originalBreakChestConfig) Material.DIAMOND_AXE else Material.CHEST

Button(
new IconItemStackBuilder(material)
Expand All @@ -159,9 +165,11 @@ object PassiveSkillMenu extends Menu {
.build(),
LeftClickButtonEffect {
SequentialEffect(
openerData.toggleChestBreakFlag,
breakSkillTargetConfigAPI.toggleBreakSkillTargetConfig(
BreakSkillTargetConfigKey.Chest
),
DeferredEffect(IO {
if (openerData.chestflag) {
if (!originalBreakChestConfig) {
SequentialEffect(
MessageEffect(s"${GREEN}スキルでのチェスト破壊を有効化しました。"),
FocusedSoundEffect(Sound.BLOCK_STONE_BUTTON_CLICK_ON, 1f, 1f)
Expand All @@ -178,11 +186,12 @@ object PassiveSkillMenu extends Menu {
)
})

val computeToggleNetherQuartzBlockButton: IO[Button] = RecomputedButton(IO {
val openerData = SeichiAssist.playermap(getUniqueId)

val computeToggleNetherQuartzBlockButton: IO[Button] = RecomputedButton(for {
originalBreakQuartz <- breakSkillTargetConfigAPI
.breakSkillTargetConfig(player, BreakSkillTargetConfigKey.MadeFromNetherQuartz)
} yield {
val baseLore = List(s"${YELLOW}スキルでネザー水晶類ブロックを破壊するスキル")
val statusLore = if (openerData.netherQuartzBlockflag) {
val statusLore = if (originalBreakQuartz) {
List(s"${GREEN}ON (スキルでネザー水晶類ブロックを破壊します。)", s"${DARK_RED}クリックでOFF")
} else {
List(s"${RED}OFF (スキルでネザー水晶類ブロックを破壊しません。)", s"${DARK_GREEN}クリックでON")
Expand All @@ -191,17 +200,19 @@ object PassiveSkillMenu extends Menu {
Button(
new IconItemStackBuilder(Material.QUARTZ_BLOCK)
.tap { builder =>
if (openerData.netherQuartzBlockflag)
if (originalBreakQuartz)
builder.enchanted()
}
.title(s"$WHITE$UNDERLINE${BOLD}ネザー水晶類ブロック破壊スキル切り替え")
.lore(baseLore ++ statusLore)
.build(),
LeftClickButtonEffect {
SequentialEffect(
openerData.toggleNetherQuartzBlockBreakFlag,
breakSkillTargetConfigAPI.toggleBreakSkillTargetConfig(
BreakSkillTargetConfigKey.MadeFromNetherQuartz
),
DeferredEffect(IO {
if (openerData.netherQuartzBlockflag) {
if (!originalBreakQuartz) {
SequentialEffect(
MessageEffect(s"${GREEN}スキルでのネザー水晶類ブロック破壊を有効化しました。"),
FocusedSoundEffect(Sound.BLOCK_STONE_BUTTON_CLICK_ON, 1f, 1f)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.github.unchama.seichiassist.subsystems.breakskilltargetconfig

import cats.data.Kleisli
import com.github.unchama.seichiassist.subsystems.breakskilltargetconfig.domain.BreakSkillTargetConfigKey

trait BreakSkillTargetConfigAPI[F[_], Player] {

/**
* @return 破壊フラグをトグルする作用
*/
def toggleBreakSkillTargetConfig(
configKey: BreakSkillTargetConfigKey
): Kleisli[F, Player, Unit]

/**
* @return 現在の破壊フラグを取得する作用
*/
def breakSkillTargetConfig(player: Player, configKey: BreakSkillTargetConfigKey): F[Boolean]

}

object BreakSkillTargetConfigAPI {

def apply[F[_], Player](
implicit ev: BreakSkillTargetConfigAPI[F, Player]
): BreakSkillTargetConfigAPI[F, Player] = ev

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package com.github.unchama.seichiassist.subsystems.breakskilltargetconfig

import cats.data.Kleisli
import cats.effect.{Sync, SyncEffect}
import com.github.unchama.datarepository.bukkit.player.BukkitRepositoryControls
import com.github.unchama.generic.ContextCoercion
import com.github.unchama.seichiassist.meta.subsystem.Subsystem
import com.github.unchama.seichiassist.subsystems.breakskilltargetconfig.application.repository.BreakSkillTargetConfigRepositoryDefinition
import com.github.unchama.seichiassist.subsystems.breakskilltargetconfig.domain.{
BreakSkillTargetConfigKey,
BreakSkillTargetConfigPersistence
}
import com.github.unchama.seichiassist.subsystems.breakskilltargetconfig.persistence.JdbcBreakSkillTargetConfigPersistence
import org.bukkit.entity.Player

trait System[F[_], Player] extends Subsystem[F] {
val api: BreakSkillTargetConfigAPI[F, Player]
}

object System {

import cats.implicits._

def wired[F[_]: Sync, G[_]: SyncEffect: ContextCoercion[*[_], F]]: G[System[F, Player]] = {
implicit val breakSkillTargetConfigPersistence: BreakSkillTargetConfigPersistence[G] =
new JdbcBreakSkillTargetConfigPersistence[G]

for {
breakSkillTargetConfigRepositoryControls <- BukkitRepositoryControls.createHandles(
BreakSkillTargetConfigRepositoryDefinition.withContext[G, Player]
)
} yield {
val breakSkillTargetConfigRepository = breakSkillTargetConfigRepositoryControls.repository

new System[F, Player] {
override val api: BreakSkillTargetConfigAPI[F, Player] =
new BreakSkillTargetConfigAPI[F, Player] {
override def toggleBreakSkillTargetConfig(
configKey: BreakSkillTargetConfigKey
): Kleisli[F, Player, Unit] =
Kleisli { player =>
ContextCoercion(
breakSkillTargetConfigRepository(player)
.update(_.toggleBreakSkillTargetConfig(configKey))
)
}

override def breakSkillTargetConfig(
player: Player,
configKey: BreakSkillTargetConfigKey
): F[Boolean] =
ContextCoercion(
breakSkillTargetConfigRepository(player)
.get
.map(_.breakSkillTargetConfig(configKey))
)
}

override val managedRepositoryControls: Seq[BukkitRepositoryControls[F, _]] = Seq(
breakSkillTargetConfigRepositoryControls.coerceFinalizationContextTo[F]
)
}
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.github.unchama.seichiassist.subsystems.breakskilltargetconfig.application.repository

import cats.effect.Sync
import cats.effect.concurrent.Ref
import com.github.unchama.datarepository.definitions.RefDictBackedRepositoryDefinition
import com.github.unchama.datarepository.template.RepositoryDefinition
import com.github.unchama.seichiassist.subsystems.breakskilltargetconfig.domain.{
BreakSkillTargetConfig,
BreakSkillTargetConfigPersistence
}

object BreakSkillTargetConfigRepositoryDefinition {

def withContext[F[_]: Sync, Player](
implicit persistence: BreakSkillTargetConfigPersistence[F]
): RepositoryDefinition[F, Player, Ref[F, BreakSkillTargetConfig]] =
RefDictBackedRepositoryDefinition
.usingUuidRefDict[F, Player, BreakSkillTargetConfig](persistence)(
BreakSkillTargetConfig.initial
)
.toRefRepository

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.github.unchama.seichiassist.subsystems.breakskilltargetconfig.domain

case class BreakSkillTargetConfig(config: Map[BreakSkillTargetConfigKey, Boolean]) {

/**
* @return `configKey`の破壊フラグをトグルする
*/
def toggleBreakSkillTargetConfig(
configKey: BreakSkillTargetConfigKey
): BreakSkillTargetConfig =
this.copy(this.config + (configKey -> this.config.getOrElse(configKey, false)))

/**
* @return 現在の破壊フラグを取得する
*/
def breakSkillTargetConfig(configKey: BreakSkillTargetConfigKey): Boolean =
this.config.getOrElse(configKey, false)

}

object BreakSkillTargetConfig {

/**
* [[BreakSkillTargetConfig]]の初期値
*/
val initial: BreakSkillTargetConfig = BreakSkillTargetConfig(Map.empty)

}
Loading

0 comments on commit ace8e7d

Please sign in to comment.