Skip to content

Commit

Permalink
Merge pull request #1120 from GiganticMinecraft/develop
Browse files Browse the repository at this point in the history
バージョン 12 リリース
  • Loading branch information
kory33 authored Jul 27, 2021
2 parents 33d72ab + 2fcfc4b commit 86b3943
Show file tree
Hide file tree
Showing 18 changed files with 41 additions and 46 deletions.
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import java.io._
ThisBuild / scalaVersion := "2.13.1"
// ThisBuild / version はGitHub Actionsによって自動更新される。
// 次の行は ThisBuild / version := "(\d*)" の形式でなければならない。
ThisBuild / version := "10"
ThisBuild / version := "12"
ThisBuild / organization := "click.seichi"
ThisBuild / description := "ギガンティック☆整地鯖の独自要素を司るプラグイン"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ object SignallingRepositoryDefinition {
// - restart the stream when the downstream stream fails
// - unsubscribe when the player exits
// We should be able to achieve this by returning a CancelToken or something on this flatXmapWithPlayer
StreamExtra.compileToRestartingStream {
StreamExtra.compileToRestartingStream("[SignallingRepositoryDefinition]") {
stream.map(player -> _).through(publishSink)
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.github.unchama.generic.effect.stream

import cats.Eq
import cats.effect.concurrent.Ref
import cats.effect.{Async, Concurrent}
import cats.effect.{Concurrent, Sync}
import cats.{Eq, Monad}
import com.github.unchama.generic.Diff
import com.github.unchama.minecraft.algebra.HasUuid
import fs2.{Chunk, Pull, Stream}
Expand Down Expand Up @@ -92,17 +92,17 @@ object StreamExtra {
/**
* 与えられたストリームを、エラーが発生したときに再起動するストリームに変換してコンパイルする。
*/
def compileToRestartingStream[F[_] : Async : ErrorLogger, A](stream: Stream[F, _]): F[A] = {
stream
.handleErrorWith { error =>
Stream.eval {
ErrorLogger[F]
.error(error)("fs2.Stream が予期せぬエラーで終了しました。再起動します。")
def compileToRestartingStream[F[_] : Sync : ErrorLogger, A](context: String)(stream: Stream[F, _]): F[A] = {
Monad[F].foreverM {
stream
.handleErrorWith { error =>
Stream.eval {
ErrorLogger[F]
.error(error)(s"$context fs2.Stream が予期せぬエラーで終了しました。再起動します。")
}
}
}
.repeat
.compile
.drain
.flatMap(_ => Async[F].never[A])
.compile
.drain
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ object System {
](breakCountReadAPI: BreakCountReadAPI[F, G, Player]) : F[A] = {
val action: NotifyLevelUp[F, Player] = BukkitNotifyLevelUp[F]

StreamExtra.compileToRestartingStream {
StreamExtra.compileToRestartingStream("[breakcount.notification]") {
breakCountReadAPI
.seichiLevelUpdates
.either(breakCountReadAPI.seichiStarLevelUpdates)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ object ExpBarSynchronizationRepositoryTemplate {

_ <- EffectExtra.runAsyncAndForget[F, G, Unit](bossBar.players.add(player))
_ <- EffectExtra.runAsyncAndForget[F, G, Unit] {
StreamExtra.compileToRestartingStream[F, Unit] {
StreamExtra.compileToRestartingStream[F, Unit]("[ExpBarSynchronizationRepositoryTemplate]") {
switching.concurrently(synchronization)
}.start >>= fiberPromise.complete
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ object System {
}

_ <-
StreamExtra.compileToRestartingStream[F, Unit] {
StreamExtra.compileToRestartingStream[F, Unit]("[FastDiggingEffect/EffectStatsNotification]") {
EffectStatsNotification.using[F, Player](effectListDiffTopic.subscribe(1).mapFilter(identity))
}.start

Expand Down Expand Up @@ -176,15 +176,15 @@ object System {
implicit val api: FastDiggingEffectApi[F, Player] = system.effectApi

List(
BreakCountEffectSynchronization.using[F, H, Player],
PlayerCountEffectSynchronization.using[F, Player],
SynchronizationProcess.using[F, Player](
"BreakCountEffectSynchronization" -> BreakCountEffectSynchronization.using[F, H, Player],
"PlayerCountEffectSynchronization" -> PlayerCountEffectSynchronization.using[F, Player],
"SynchronizationProcess" -> SynchronizationProcess.using[F, Player](
system.settingsApi.currentSuppressionSettings,
system.effectApi.effectClock
)
).traverse(
StreamExtra.compileToRestartingStream(_).start
)
).traverse { case (str, stream) =>
StreamExtra.compileToRestartingStream(s"[FastDiggingEffect/$str]")(stream).start
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ object EffectListRepositoryDefinitions {
val (mutexRef, fiberPromise) = value

val programToRun: F[Unit] =
StreamExtra.compileToRestartingStream {
StreamExtra.compileToRestartingStream("[EffectListRepositoryDefinitions]") {
fs2.Stream
.awakeEvery[F](1.second)
.evalMap[F, FastDiggingEffectList](_ => ContextCoercion(mutexRef.readLatest))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ object EffectStatsSettingsRepositoryDefinition {
}

EffectExtra.runAsyncAndForget[F, G, Unit] {
StreamExtra.compileToRestartingStream(processStream).start >>= fiberPromise.complete
StreamExtra.compileToRestartingStream("[EffectStatsSettingsRepository]") {
processStream
}.start >>= fiberPromise.complete
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ object PocketInventoryRepositoryDefinition {
}

EffectExtra.runAsyncAndForget[F, G, Unit] {
StreamExtra.compileToRestartingStream(processStream).start >>= fiberPromise.complete
StreamExtra.compileToRestartingStream("[PocketInventoryRepository]")(processStream).start >>=
fiberPromise.complete
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ object System {

EffectExtra.runAsyncAndForget[F, G, Unit] {
streams
.traverse(StreamExtra.compileToRestartingStream(_).start)
.traverse(StreamExtra.compileToRestartingStream("[GachaPoint]")(_).start)
.as(())
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ object System {
implicit val sendBukkitMessage: SendMinecraftMessage[F, Player] = SendBukkitMessage[F]
implicit val broadcastBukkitMessage: BroadcastMinecraftMessage[F] = BroadcastBukkitMessage[F]

StreamExtra.compileToRestartingStream {
StreamExtra.compileToRestartingStream("[HalfHourRanking]") {
breakCountReadAPI
.batchedIncreases(30.minutes)
.map(RankingRecord.apply)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ object System {
_ <- List(
UpdateManaCaps.using[F, G, Player](handles.repository),
RefillToCap.using[F, G, Player](handles.repository)
).traverse(StreamExtra.compileToRestartingStream[F, Unit](_).start)
).traverse(StreamExtra.compileToRestartingStream[F, Unit]("[Mana]")(_).start)
} yield new System[F, G, Player] {
override val manaApi: ManaApi[F, G, Player] = new ManaApi[F, G, Player] {
override val readManaAmount: KeyedDataRepository[Player, G[LevelCappedManaAmount]] =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ object ManaBarSynchronizationRepository {
val programToRunAsync =
bossBar.players.add(player) >>
Concurrent[F].start[Nothing] {
StreamExtra.compileToRestartingStream[F, Nothing](synchronization)
StreamExtra.compileToRestartingStream("[ManaBarSynchronization]")(synchronization)
} >>= promise.complete

EffectExtra.runAsyncAndForget[F, G, Unit](programToRunAsync)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ object GenericRefreshingRankingCache {
initialRankingRecords <- persistence.getAllRankingRecords
rankingRef <- Ref.of(new Ranking(initialRankingRecords))
_ <-
StreamExtra.compileToRestartingStream[F, Unit] {
StreamExtra.compileToRestartingStream[F, Unit]("[GenericRefreshingRankingCache]") {
fs2.Stream
.awakeEvery[F](30.seconds)
.evalMap(_ => persistence.getAllRankingRecords)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ object System {
}
}

StreamExtra.compileToRestartingStream {
StreamExtra.compileToRestartingStream("[SeichiLevelUpGift]") {
breakCountReadApi
.seichiLevelUpdates
.evalTap { case (player, diff) => interpreter.onLevelDiff(diff).run(player) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ object System {
G[_],
Player
](implicit breakCountReadAPI: BreakCountReadAPI[F, G, Player]): F[Nothing] = {
StreamExtra.compileToRestartingStream {
StreamExtra.compileToRestartingStream("[SeichiLevelUpMessage]") {
breakCountReadAPI
.seichiLevelUpdates
.evalMap { case (player, diff) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import org.bukkit.entity.{Entity, EntityType, Player}
import org.bukkit.inventory.ItemStack
import org.bukkit.material.Dye

import java.time.LocalDate
import java.util.Random
import java.util.stream.IntStream

Expand Down Expand Up @@ -280,14 +279,7 @@ object BreakUtil {
def blockCountWeight(world: World): Double = {
val managedWorld = ManagedWorld.fromBukkitWorld(world)
val seichiWorldFactor = if (managedWorld.exists(_.isSeichi)) 1.0 else 0.0
val sw01Penalty =
if (managedWorld.contains(ManagedWorld.WORLD_SW)) {
// 5周年記念企画のうち21億チャレンジ用の条件分岐
// TODO: 終わったら消去する
if (LocalDate.now().isEqual(LocalDate.of(2021, 7, 22))) 2.5
else 0.8
}
else 1.0
val sw01Penalty = if (managedWorld.contains(ManagedWorld.WORLD_SW)) 0.8 else 1.0

seichiWorldFactor * sw01Penalty
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,12 +300,12 @@ object Util {
if (itemstack.getAmount == count) {
// アイテムをcount個使うので、プレイヤーの手を素手にする
inventory.setItemInMainHand(new ItemStack(Material.AIR))
true
} else if (itemstack.getAmount > count) {
// プレイヤーが持っているアイテムをcount個減らす
itemstack.setAmount(itemstack.getAmount - count)
} else
return itemstack.getAmount >= count
true
true
} else false
}

def itemStackContainsOwnerName(itemstack: ItemStack, name: String): Boolean = {
Expand Down

0 comments on commit 86b3943

Please sign in to comment.