Skip to content

Commit

Permalink
Merge pull request #1083 from GiganticMinecraft/develop
Browse files Browse the repository at this point in the history
1.8.4 リリース
  • Loading branch information
kory33 authored Jul 12, 2021
2 parents 3c6b855 + 8616118 commit 535dcb0
Show file tree
Hide file tree
Showing 30 changed files with 51 additions and 52 deletions.
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import sbt.Keys.baseDirectory
import java.io._

ThisBuild / scalaVersion := "2.13.1"
ThisBuild / version := "1.8.3"
ThisBuild / version := "1.8.4"
ThisBuild / organization := "click.seichi"
ThisBuild / description := "ギガンティック☆整地鯖の独自要素を司るプラグイン"

Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ commands:
permission-message: *denied
fly:
description: This is a fly command.
usage: /<command>
usage: /<command> <操作> (詳細については/fly helpを参照してください)
permission-message: *denied
permission: seichiassist.fly
stickmenu:
Expand Down Expand Up @@ -162,4 +162,4 @@ permissions:
- seichiassist.present.grant
- seichiassist.present.revoke
- seichiassist.present.define
- seichiassist.present.delete
- seichiassist.present.delete
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class PlayerInventoryListener(implicit effectEnvironment: EffectEnvironment,
if (itemstackcurrent.getType == Material.SKULL_ITEM) {
//ホームメニューへ帰還

effectEnvironment.runAsyncTargetedEffect(player)(
effectEnvironment.unsafeRunAsyncTargetedEffect(player)(
SequentialEffect(
CommonSoundEffects.menuTransitionFenceSound,
ioCanOpenBuildMainMenu.open(BuildMainMenu)
Expand Down
11 changes: 7 additions & 4 deletions src/main/scala/com/github/unchama/fs2/workaround/Topic.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.github.unchama.fs2.workaround

import cats.effect.Concurrent
import cats.effect.{Concurrent, Sync}
import cats.effect.concurrent.{Deferred, Ref}
import cats.implicits._
import fs2.Stream._
Expand All @@ -9,6 +9,7 @@ import fs2.{Sink, Stream}

/*
Code directly copied from https://github.com/typelevel/fs2/blob/4ddd75a2dc032b7604dc1205c86d7d6adc993859/core/shared/src/main/scala/fs2/concurrent/Topic.scala.
and then generalized to a more generic version.
This is due to https://github.com/typelevel/fs2/issues/1406, and the recommended workaround
was to switch back to an old implementation of Topic which is better in terms of performance.
Expand Down Expand Up @@ -116,7 +117,7 @@ abstract class Topic[F[_], A] {

object Topic {

def apply[F[_], A](initial: A)(implicit F: Concurrent[F]): F[Topic[F, A]] = {
def in[G[_], F[_], A](initial: A)(implicit G: Sync[G], F: Concurrent[F]): G[Topic[F, A]] = {
// Id identifying each subscriber uniquely
class ID

Expand All @@ -133,9 +134,9 @@ object Topic {
}

Ref
.of[F, (A, Vector[Subscriber])]((initial, Vector.empty[Subscriber]))
.in[G, F, (A, Vector[Subscriber])]((initial, Vector.empty[Subscriber]))
.flatMap { state =>
SignallingRef[F, Int](0).map { subSignal =>
SignallingRef.in[G, F, Int](0).map { subSignal =>
def mkSubscriber(maxQueued: Int): F[Subscriber] =
for {
q <- InspectableQueue.bounded[F, A](maxQueued)
Expand Down Expand Up @@ -200,4 +201,6 @@ object Topic {
}
}
}

def apply[F[_], A](initial: A)(implicit F: Concurrent[F]): F[Topic[F, A]] = in[F, F, A](initial)
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ import com.github.unchama.generic.effect.EffectExtra
import com.github.unchama.generic.effect.stream.ReorderingPipe
import com.github.unchama.generic.effect.stream.ReorderingPipe.TimeStamped
import com.github.unchama.generic.{ContextCoercion, Token}
import com.github.unchama.fs2.workaround.Topic
import fs2.Stream
import fs2.concurrent.{Signal, Topic}
import fs2.concurrent.Signal

/**
* 更新が [[Stream]] により読め出せるような可変参照セル。
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@ trait EffectEnvironment {
* 理想的には、これはプログラムの最も外側にて「一度だけ」呼び出されるべきである。
*
* このメソッドの実装は `context` を用いて実行に関するロギングを行ってよい。
*
* TODO rename to unsafeRunEffectAsync
*/
def runEffectAsync[U, F[_] : Effect](context: String, program: F[U]): Unit
def unsafeRunEffectAsync[U, F[_] : Effect](context: String, program: F[U]): Unit

/**
* `receiver`を`effect`に適用して得られる`IO`を例外を補足して実行する。
Expand All @@ -30,7 +28,7 @@ trait EffectEnvironment {
* @tparam T レシーバの型
* @deprecated use [[EffectEnvironment]]
*/
def runAsyncTargetedEffect[T](receiver: T)(effect: TargetedEffect[T], context: String): Unit =
runEffectAsync(context, effect(receiver))
def unsafeRunAsyncTargetedEffect[T](receiver: T)(effect: TargetedEffect[T], context: String): Unit =
unsafeRunEffectAsync(context, effect(receiver))

}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class MenuHandler(implicit val cs: NonServerThreadContextShift[IO], env: EffectE
return
}

env.runEffectAsync(
env.unsafeRunEffectAsync(
"メニューのクリックを非同期で処理する",
for {
currentLayout <- holder.currentLayout.get
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import com.github.unchama.generic.effect.unsafe.EffectEnvironment
// TODO prepare alternative environment that uses dedicated Logger for effect execution
object DefaultEffectEnvironment extends EffectEnvironment {

override def runEffectAsync[U, F[_] : Effect](context: String, program: F[U]): Unit = {
override def unsafeRunEffectAsync[U, F[_] : Effect](context: String, program: F[U]): Unit = {
import cats.effect.implicits._

program
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class BuildMainMenuOpener(implicit effectEnvironment: EffectEnvironment,
if (!hasStickOnMainHand || !actionWasOnMainHand) return
}

effectEnvironment.runAsyncTargetedEffect(player)(
effectEnvironment.unsafeRunAsyncTargetedEffect(player)(
SequentialEffect(
CommonSoundEffects.menuTransitionFenceSound,
ioCanOpenBuildMainMenu.open(BuildMainMenu)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import com.github.unchama.minecraft.actions.OnMinecraftServerThread
import com.github.unchama.seichiassist.MaterialSets.{BlockBreakableBySkill, BreakTool}
import com.github.unchama.seichiassist._
import com.github.unchama.seichiassist.seichiskill.{BlockSearching, BreakArea}
import com.github.unchama.seichiassist.subsystems.discordnotification.DiscordNotificationAPI
import com.github.unchama.seichiassist.subsystems.mana.ManaApi
import com.github.unchama.seichiassist.subsystems.mana.domain.ManaAmount
import com.github.unchama.seichiassist.subsystems.discordnotification.DiscordNotificationAPI
import com.github.unchama.seichiassist.task.GiganticBerserkTask
import com.github.unchama.seichiassist.util.{BreakUtil, Util}
import org.bukkit._
Expand Down Expand Up @@ -150,7 +150,7 @@ class EntityListener(implicit effectEnvironment: EffectEnvironment,
//元ブロックの真ん中の位置
val centerOfBlock = hitBlock.getLocation.add(0.5, 0.5, 0.5)

effectEnvironment.runEffectAsync(
effectEnvironment.unsafeRunEffectAsync(
"破壊エフェクトを再生する",
playerData.skillEffectState.selection
.runBreakEffect(player, selectedSkill, tool, breakBlocks.toSet, breakArea, centerOfBlock)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,11 +230,11 @@ class PlayerBlockBreakListener(implicit effectEnvironment: EffectEnvironment,
if (!tool.getItemMeta.isUnbreakable) tool.setDurability(toolDamageToSet.toShort)
}

effectEnvironment.runEffectAsync(
effectEnvironment.unsafeRunEffectAsync(
"複数破壊エフェクトを実行する",
effectPrograms.toList.sequence[IO, Fiber[IO, Unit]]
)
effectEnvironment.runEffectAsync(
effectEnvironment.unsafeRunEffectAsync(
"複数破壊エフェクトの後処理を実行する",
adjustManaAndDurability >> availabilityFlagManipulation
)
Expand All @@ -251,7 +251,7 @@ class PlayerBlockBreakListener(implicit effectEnvironment: EffectEnvironment,
BreakUtil.blockCountWeight(event.getPlayer.getWorld) * BreakUtil.totalBreakCount(Seq(block.getType))
}

effectEnvironment.runEffectAsync(
effectEnvironment.unsafeRunEffectAsync(
"通常破壊されたブロックを整地量に計上する",
SeichiAssist.instance
.breakCountSystem.api
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ class PlayerClickListener(implicit effectEnvironment: EffectEnvironment,

val arrowEffect = playerData.skillEffectState.selection.arrowEffect(player)

effectEnvironment.runEffectAsync("スキルのクールダウンの状態を戻す", controlSkillAvailability)
effectEnvironment.runEffectAsync("ArrowEffectを非同期で実行する", arrowEffect)
effectEnvironment.unsafeRunEffectAsync("スキルのクールダウンの状態を戻す", controlSkillAvailability)
effectEnvironment.unsafeRunEffectAsync("ArrowEffectを非同期で実行する", arrowEffect)
case _ =>
}
}
Expand Down Expand Up @@ -393,7 +393,7 @@ class PlayerClickListener(implicit effectEnvironment: EffectEnvironment,
if (event.getHand == EquipmentSlot.OFF_HAND) return
event.setCancelled(true)

effectEnvironment.runAsyncTargetedEffect(player)(
effectEnvironment.unsafeRunAsyncTargetedEffect(player)(
SequentialEffect(
CommonSoundEffects.menuTransitionFenceSound,
ioCanOpenStickMenu.open(StickMenu.firstPage)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import com.github.unchama.seichiassist.data.{GachaSkullData, ItemData, MenuInven
import com.github.unchama.seichiassist.effects.player.CommonSoundEffects
import com.github.unchama.seichiassist.listener.invlistener.OnClickTitleMenu
import com.github.unchama.seichiassist.menus.achievement.AchievementMenu
import com.github.unchama.seichiassist.menus.ranking.RankingRootMenu
import com.github.unchama.seichiassist.menus.stickmenu.{FirstPage, StickMenu}
import com.github.unchama.seichiassist.subsystems.mana.ManaApi
import com.github.unchama.seichiassist.task.VotingFairyTask
Expand Down Expand Up @@ -232,7 +231,7 @@ class PlayerInventoryListener(implicit effectEnvironment: EffectEnvironment,
val ticketsToGive = Seq.fill(ticketAmount)(exchangeTicket)

if (ticketsToGive.nonEmpty) {
effectEnvironment.runAsyncTargetedEffect(player)(
effectEnvironment.unsafeRunAsyncTargetedEffect(player)(
SequentialEffect(
Util.grantItemStacksEffect(ticketsToGive: _*),
FocusedSoundEffect(Sound.BLOCK_ANVIL_PLACE, 1f, 1f),
Expand All @@ -257,7 +256,7 @@ class PlayerInventoryListener(implicit effectEnvironment: EffectEnvironment,
}.++(rejectedItems)

//返却処理
effectEnvironment.runAsyncTargetedEffect(player)(
effectEnvironment.unsafeRunAsyncTargetedEffect(player)(
Util.grantItemStacksEffect(itemStacksToReturn: _*),
"鉱石交換でのアイテム返却を行う"
)
Expand Down Expand Up @@ -516,7 +515,7 @@ class PlayerInventoryListener(implicit effectEnvironment: EffectEnvironment,
player.closeInventory()
} else if (isSkull && itemstackcurrent.getItemMeta.asInstanceOf[SkullMeta].getOwner == "MHF_ArrowLeft") {

effectEnvironment.runAsyncTargetedEffect(player)(
effectEnvironment.unsafeRunAsyncTargetedEffect(player)(
SequentialEffect(
CommonSoundEffects.menuTransitionFenceSound,
ioCanOpenFirstPage.open(StickMenu.firstPage)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ object OnClickTitleMenu {
case _ if isSkull && isApplicableAsPrevPageButton(current) =>


effectEnvironment.runAsyncTargetedEffect(player)(
effectEnvironment.unsafeRunAsyncTargetedEffect(player)(
SequentialEffect(
CommonSoundEffects.menuTransitionFenceSound,
ioCanOpenAchievementMenu.open(AchievementMenu)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ object ActiveSkillMenu extends Menu {
MessageEffect(s"$YELLOW${BOLD}全てのスキルを習得し、アサルト・アーマーを解除しました"),
Kleisli.liftF(DiscordNotificationAPI[F].send(notificationMessage).toIO),
Kleisli.liftF(IO {
Util.sendMessageToEveryoneIgnoringPreference(notificationMessage)
Util.sendMessageToEveryoneIgnoringPreference(s"$GOLD$BOLD$notificationMessage")
}),
BroadcastSoundEffect(Sound.ENTITY_ENDERDRAGON_DEATH, 1.0f, 1.2f),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ object AssaultRoutine {
// ブロックを書き換える
if (shouldBreakAllBlocks) {
(foundWaters ++ foundLavas).foreach(_.setType(Material.AIR))
DefaultEffectEnvironment.runEffectAsync(
DefaultEffectEnvironment.unsafeRunEffectAsync(
"ブロックを大量破壊する",
BreakUtil.massBreakBlock(player, foundBlocks, player.getLocation, toolToBeUsed, shouldPlayBreakSound = false)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@ class GrantBookedAchievementListener[F[_] : ConcurrentEffect : NonServerThreadCo
}.sequence)
} yield ()

effectEnvironment.runEffectAsync("未受け取りの予約実績を読み込み、付与する", program)
effectEnvironment.unsafeRunEffectAsync("未受け取りの予約実績を読み込み、付与する", program)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class ExpBottleStackUsageController[
val bottleCount = BottleCount(playerInventory.getItemInMainHand.getAmount)
val bottleResource = Resources.bottleResourceSpawningAt[F](player.getLocation, bottleCount)

effectEnvironment.runEffectAsync(
effectEnvironment.unsafeRunEffectAsync(
"経験値瓶の消費を待つ",
managedBottleScope.useTracked[ThrownExpBottle, Nothing](bottleResource) { _ => Effect[F].never }
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class OpenPocketInventoryOnPlacingEnderPortalFrame[
//設置をキャンセル
event.setCancelled(true)

effectEnvironment.runEffectAsync(
effectEnvironment.unsafeRunEffectAsync(
"ポケットインベントリを開く",
api.openPocketInventory(player)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ object ManaBarManipulation {

// 3桁毎カンマ区切り、小数点以下一桁を表示
private def formatAmount(manaAmount: ManaAmount): String = {
val decimalFormat = new DecimalFormat("#,###.0")
val decimalFormat = new DecimalFormat("#,##0.0")
decimalFormat.format(manaAmount.value)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package com.github.unchama.seichiassist.subsystems.mebius.bukkit.listeners
import cats.effect.{IO, SyncEffect, SyncIO, Timer}
import com.github.unchama.datarepository.bukkit.player.PlayerDataRepository
import com.github.unchama.generic.effect.unsafe.EffectEnvironment
import com.github.unchama.seichiassist.MaterialSets
import com.github.unchama.seichiassist.ManagedWorld._
import com.github.unchama.seichiassist.MaterialSets
import com.github.unchama.seichiassist.subsystems.mebius.bukkit.codec.BukkitMebiusItemStackCodec
import com.github.unchama.seichiassist.subsystems.mebius.domain.MebiusDrop
import com.github.unchama.seichiassist.subsystems.mebius.domain.speech.{MebiusSpeech, MebiusSpeechStrength}
Expand All @@ -18,8 +18,8 @@ import org.bukkit.ChatColor._
import org.bukkit.Sound
import org.bukkit.event.block.BlockBreakEvent
import org.bukkit.event.{EventHandler, EventPriority, Listener}
import java.util.concurrent.TimeUnit

import java.util.concurrent.TimeUnit
import scala.concurrent.duration.FiniteDuration

class MebiusDropTrialListener[
Expand Down Expand Up @@ -49,7 +49,7 @@ class MebiusDropTrialListener[
player.sendMessage(s"$RESET$YELLOW${BOLD}MEBIUSはプレイヤーと共に成長するヘルメットです。")
player.sendMessage(s"$RESET$YELLOW${BOLD}あなただけのMEBIUSを育てましょう!")

effectEnvironment.runEffectAsync(
effectEnvironment.unsafeRunEffectAsync(
"Mebiusのドロップ時メッセージを再生する",
serviceRepository(player).makeSpeechIgnoringBlockage(
droppedMebiusProperty,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class MebiusInteractionResponder(implicit serviceRepository: PlayerDataRepositor

import cats.implicits._

effectEnvironment.runEffectAsync(
effectEnvironment.unsafeRunEffectAsync(
"Mebius破壊時のエフェクトを再生する",
MebiusMessages.onMebiusBreak.pickOne[SyncIO].toIO.flatMap { message =>
speechService.makeSpeechIgnoringBlockage(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class MebiusLevelUpTrialListener(implicit serviceRepository: PlayerDataRepositor
}

import cats.implicits._
effectEnvironment.runEffectAsync(
effectEnvironment.unsafeRunEffectAsync(
"Mebiusのレベルアップ時の通知を行う",
serviceRepository(player).makeSpeechIgnoringBlockage(
newMebiusProperty,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.github.unchama.seichiassist.subsystems.mebius.bukkit.listeners

import java.util.concurrent.TimeUnit

import cats.effect.{Effect, IO, SyncIO, Timer}
import com.github.unchama.datarepository.bukkit.player.PlayerDataRepository
import com.github.unchama.generic.effect.unsafe.EffectEnvironment
Expand All @@ -12,6 +10,7 @@ import com.github.unchama.targetedeffect.DelayEffect
import org.bukkit.event.player.PlayerJoinEvent
import org.bukkit.event.{EventHandler, EventPriority, Listener}

import java.util.concurrent.TimeUnit
import scala.concurrent.duration.FiniteDuration

class MebiusPlayerJoinGreeter[F[_] : Effect](implicit effectEnvironment: EffectEnvironment,
Expand All @@ -27,7 +26,7 @@ class MebiusPlayerJoinGreeter[F[_] : Effect](implicit effectEnvironment: EffectE
BukkitMebiusItemStackCodec
.decodePropertyOfOwnedMebius(player)(player.getInventory.getHelmet)
.foreach { property =>
effectEnvironment.runEffectAsync(
effectEnvironment.unsafeRunEffectAsync(
"参加時のMebiusのメッセージを送信する",
DelayEffect(FiniteDuration(500, TimeUnit.MILLISECONDS)).run(player) >>
speechServiceRepository(player)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import org.bukkit.event.{EventHandler, Listener}
import org.bukkit.inventory.EquipmentSlot
import org.bukkit.{Material, Sound, TreeType}

import java.time.LocalDate
import scala.jdk.CollectionConverters._
import scala.util.Random

Expand Down Expand Up @@ -51,7 +50,7 @@ class AnniversaryListener(implicit effectEnvironment: EffectEnvironment,
val playerData: PlayerData = SeichiAssist.playermap(player.getUniqueId)
if (playerData.anniversary) return

effectEnvironment.runAsyncTargetedEffect(player)(
effectEnvironment.unsafeRunAsyncTargetedEffect(player)(
SequentialEffect(
grantItemStacksEffect(mineHead),
MessageEffect(s"${BLUE}ギガンティック☆整地鯖${ANNIVERSARY_COUNT}周年の記念品を入手しました。"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class LimitedLoginBonusGifter(implicit ioOnMainThread: OnMinecraftServerThread[I
private def giveItem(itemName: String, amount: Int, item: ItemStack)(implicit player: Player): Unit = {
import cats.implicits._

DefaultEffectEnvironment.runEffectAsync(
DefaultEffectEnvironment.unsafeRunEffectAsync(
s"${itemName}を付与する",
List.fill(amount)(
grantItemStacksEffect(item)
Expand Down
Loading

0 comments on commit 535dcb0

Please sign in to comment.