Skip to content

Commit

Permalink
Merge pull request #1491 from GiganticMinecraft/develop
Browse files Browse the repository at this point in the history
バージョン 38 リリース
  • Loading branch information
KisaragiEffective authored May 2, 2022
2 parents f91c1a6 + cf4f8bb commit ecde20d
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 5 deletions.
2 changes: 1 addition & 1 deletion 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.1"
// ThisBuild / version はGitHub Actionsによって取得/自動更新される。
// 次の行は ThisBuild / version := "(\d*)" の形式でなければならない。
ThisBuild / version := "37"
ThisBuild / version := "38"
ThisBuild / organization := "click.seichi"
ThisBuild / description := "ギガンティック☆整地鯖の独自要素を司るプラグイン"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,29 @@ import cats.effect.{Clock, ConcurrentEffect, SyncEffect}
import com.github.unchama.concurrent.NonServerThreadContextShift
import com.github.unchama.datarepository.KeyedDataRepository
import com.github.unchama.datarepository.bukkit.player.BukkitRepositoryControls
import com.github.unchama.datarepository.template.RepositoryDefinition
import com.github.unchama.fs2.workaround.fs3.Fs3Topic
import com.github.unchama.generic.ContextCoercion
import com.github.unchama.generic.effect.concurrent.ReadOnlyRef
import com.github.unchama.generic.ratelimiting.RateLimiter
import com.github.unchama.minecraft.actions.OnMinecraftServerThread
import com.github.unchama.seichiassist.meta.subsystem.Subsystem
import com.github.unchama.seichiassist.subsystems.buildcount.application.actions.{
ClassifyPlayerWorld,
IncrementBuildExpWhenBuiltByHand,
IncrementBuildExpWhenBuiltWithSkill
}
import com.github.unchama.seichiassist.subsystems.buildcount.application.application.BuildAmountDataRepositoryDefinition
import com.github.unchama.seichiassist.subsystems.buildcount.application.application.{
BuildAmountDataRepositoryDefinition,
RateLimiterRepositoryDefinitions
}
import com.github.unchama.seichiassist.subsystems.buildcount.application.{
BuildExpMultiplier,
Configuration
}
import com.github.unchama.seichiassist.subsystems.buildcount.bukkit.actions.ClassifyBukkitPlayerWorld
import com.github.unchama.seichiassist.subsystems.buildcount.bukkit.listeners.BuildExpIncrementer
import com.github.unchama.seichiassist.subsystems.buildcount.domain.explevel.BuildExpAmount
import com.github.unchama.seichiassist.subsystems.buildcount.domain.playerdata.BuildAmountData
import com.github.unchama.seichiassist.subsystems.buildcount.infrastructure.{
JdbcBuildAmountDataPersistence,
Expand All @@ -31,6 +37,8 @@ import io.chrisdavenport.log4cats.ErrorLogger
import org.bukkit.entity.Player
import org.bukkit.event.Listener

import java.util.UUID

trait System[F[_], G[_]] extends Subsystem[F] {

val api: BuildCountAPI[F, G, Player]
Expand Down Expand Up @@ -58,6 +66,18 @@ object System {

val createSystem: F[System[F, G]] = for {
buildCountTopic <- Fs3Topic[F, (Player, BuildAmountData)]
rateLimiterRepositoryControls <-
ContextCoercion(
BukkitRepositoryControls.createHandles(
RepositoryDefinition
.Phased
.SinglePhased
.withoutTappingAction[G, Player, RateLimiter[G, BuildExpAmount]](
RateLimiterRepositoryDefinitions.initialization[G],
RateLimiterRepositoryDefinitions.finalization[G, UUID]
)
)
)

buildAmountDataRepositoryControls <-
ContextCoercion(
Expand All @@ -71,6 +91,7 @@ object System {
new ClassifyBukkitPlayerWorld[G]
implicit val incrementBuildExp: IncrementBuildExpWhenBuiltByHand[G, Player] =
IncrementBuildExpWhenBuiltByHand.using(
rateLimiterRepositoryControls.repository,
buildAmountDataRepositoryControls.repository,
buildCountTopic
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import com.github.unchama.datarepository.KeyedDataRepository
import com.github.unchama.fs2.workaround.fs3.Fs3Topic
import com.github.unchama.generic.ContextCoercion
import com.github.unchama.generic.effect.EffectExtra
import com.github.unchama.generic.ratelimiting.RateLimiter
import com.github.unchama.seichiassist.subsystems.buildcount.application.BuildExpMultiplier
import com.github.unchama.seichiassist.subsystems.buildcount.domain.explevel.BuildExpAmount
import com.github.unchama.seichiassist.subsystems.buildcount.domain.playerdata.BuildAmountData
Expand Down Expand Up @@ -34,6 +35,7 @@ object IncrementBuildExpWhenBuiltByHand {
F,
*[_]
], Player](
rateLimiterRepository: KeyedDataRepository[Player, RateLimiter[F, BuildExpAmount]],
dataRepository: KeyedDataRepository[Player, Ref[F, BuildAmountData]],
dataTopic: Fs3Topic[G, (Player, BuildAmountData)]
)(
Expand All @@ -45,10 +47,11 @@ object IncrementBuildExpWhenBuiltByHand {

F.ifM(ClassifyPlayerWorld[F, Player].isInBuildWorld(player))(
for {
newData <-
dataRepository(player).updateAndGet(_.addExpAmount(by))
limitedNewData <- rateLimiterRepository(player).requestPermission(by)
incremented <-
dataRepository(player).updateAndGet(_.addExpAmount(limitedNewData))
_ <- EffectExtra.runAsyncAndForget[G, F, Unit] {
dataTopic.publish1((player, newData)).void
dataTopic.publish1((player, incremented)).void
}
} yield (),
F.unit
Expand Down

0 comments on commit ecde20d

Please sign in to comment.