Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = 3.11.2
version = 3.11.4
preset=IntelliJ
runner.dialect = scala3

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,12 @@ object ReloadingButton {
ctx: LayoutPreparationContext,
onMainThread: OnMinecraftServerThread[IO]
): Button = {
button.withAnotherEffect(
ButtonEffect(scope => {
val clicker = scope.event.getWhoClicked.asInstanceOf[Player]
Kleisli.liftF(for {
newLayout <- menu.computeMenuLayout(clicker)
_ <- scope.overwriteCurrentViewBy(newLayout)
} yield ())
})
)
button.withAnotherEffect(ButtonEffect(scope => {
val clicker = scope.event.getWhoClicked.asInstanceOf[Player]
Kleisli.liftF(for {
newLayout <- menu.computeMenuLayout(clicker)
_ <- scope.overwriteCurrentViewBy(newLayout)
} yield ())
}))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,10 @@ object SeichiAssistCommand {

private val reloadConfigExecutor = ContextualExecutorBuilder
.beginConfiguration
.buildWithEffectAsExecution(
UnfocusedEffect {
SeichiAssist.seichiAssistConfig = Config.loadFrom(SeichiAssist.instance)
MessageEffect("config.ymlの設定値を再読み込みしました")
}
)
.buildWithEffectAsExecution(UnfocusedEffect {
SeichiAssist.seichiAssistConfig = Config.loadFrom(SeichiAssist.instance)
MessageEffect("config.ymlの設定値を再読み込みしました")
})

private val toggleDebugExecutor = ContextualExecutorBuilder
.beginConfiguration
Expand Down Expand Up @@ -62,16 +60,14 @@ object SeichiAssistCommand {
private val setAnniversaryFlagExecutor = ContextualExecutorBuilder
.beginConfiguration
.refineSenderWithError[ConsoleCommandSender]("コンソール専用コマンドです")
.buildWithEffectAsExecution(
UnfocusedEffect {
SeichiAssist
.databaseGateway
.playerDataManipulator
.setAnniversary(anniversary = true, null)
.buildWithEffectAsExecution(UnfocusedEffect {
SeichiAssist
.databaseGateway
.playerDataManipulator
.setAnniversary(anniversary = true, null)

MessageEffect("Anniversaryアイテムの配布を開始しました。")
}
)
MessageEffect("Anniversaryアイテムの配布を開始しました。")
})

val executor: TabExecutor = BranchedExecutor(
Map(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,14 @@ class PlayerSettings {
} yield {
broadcastMutingSettings = nextSettings
})
val toggleHalfBreakFlag: TargetedEffect[Player] = DeferredEffect(
IO {
allowBreakingHalfBlocks = !allowBreakingHalfBlocks
val toggleHalfBreakFlag: TargetedEffect[Player] = DeferredEffect(IO {
allowBreakingHalfBlocks = !allowBreakingHalfBlocks

val newStatus = if (allowBreakingHalfBlocks) s"${GREEN}破壊可能" else s"${RED}破壊不可能"
val responseMessage = s"現在ハーフブロックは$newStatus${RESET}です."
val newStatus = if (allowBreakingHalfBlocks) s"${GREEN}破壊可能" else s"${RED}破壊不可能"
val responseMessage = s"現在ハーフブロックは$newStatus${RESET}です."

MessageEffect(responseMessage)
}
)
MessageEffect(responseMessage)
})

/**
* 複数ブロック同時破壊のON/OFFを切り替える[UnforcedEffect]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -356,15 +356,13 @@ class PlayerBlockBreakListener(
.tryIntoMineStack(player, amalgamatedDrops)
_ <- PluginExecutionContexts
.onMainThread
.runAction(
SyncIO {
event.setDropItems(false)
intoMineStackResult
._1
.filterNot(_.getType == Material.AIR)
.foreach(player.getWorld.dropItemNaturally(player.getLocation, _))
}
)
.runAction(SyncIO {
event.setDropItems(false)
intoMineStackResult
._1
.filterNot(_.getType == Material.AIR)
.foreach(player.getWorld.dropItemNaturally(player.getLocation, _))
})
} yield ()

// NOTE: Spigot 1.18.2のAPIではチェストの中身のドロップを計算することは不可能である。
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,16 +178,14 @@ case class NicknameCombinationMenu(pageIndex: Int = 0, nicknamePart: NicknamePar
LeftClickButtonEffect(
SequentialEffect(
FocusedSoundEffect(Sound.BLOCK_STONE_BUTTON_CLICK_ON, 1.0f, 1.0f),
DeferredEffect(
IO {
nicknamePart match {
case Head => playerdata.updateNickname(id1 = archivementId)
case Middle => playerdata.updateNickname(id2 = archivementId)
case Tail => playerdata.updateNickname(id3 = archivementId)
}
MessageEffect(s"${nicknamePart.displayName}パーツ「${nickname}」をセットしました。")
DeferredEffect(IO {
nicknamePart match {
case Head => playerdata.updateNickname(id1 = archivementId)
case Middle => playerdata.updateNickname(id2 = archivementId)
case Tail => playerdata.updateNickname(id3 = archivementId)
}
)
MessageEffect(s"${nicknamePart.displayName}パーツ「${nickname}」をセットしました。")
})
)
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,10 @@ case class NicknameShopMenu(val pageIndex: Int = 0) extends Menu {
LeftClickButtonEffect(
SequentialEffect(
FocusedSoundEffect(Sound.BLOCK_STONE_BUTTON_CLICK_ON, 1.0f, 1.0f),
DeferredEffect(
IO {
playerdata.recalculateAchievePoint()
ioCanOpenNicknameShopMenu.open(NicknameShopMenu(pageIndex))
}
)
DeferredEffect(IO {
playerdata.recalculateAchievePoint()
ioCanOpenNicknameShopMenu.open(NicknameShopMenu(pageIndex))
})
)
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,20 +257,18 @@ object SecondPage extends Menu {
FilteredButtonEffect(ClickEventFilter.LEFT_CLICK) { _ =>
SequentialEffect(
playerData.settings.toggleDeathMessageMutingSettings,
DeferredEffect(
IO {
val (soundPitch, message) =
if (playerData.settings.shouldDisplayDeathMessages)
(1.0f, s"${GREEN}死亡メッセージ:表示")
else
(0.5f, s"${RED}死亡メッセージ:隠す")

SequentialEffect(
MessageEffect(message),
FocusedSoundEffect(Sound.BLOCK_STONE_BUTTON_CLICK_ON, 1.0f, soundPitch)
)
}
)
DeferredEffect(IO {
val (soundPitch, message) =
if (playerData.settings.shouldDisplayDeathMessages)
(1.0f, s"${GREEN}死亡メッセージ:表示")
else
(0.5f, s"${RED}死亡メッセージ:隠す")

SequentialEffect(
MessageEffect(message),
FocusedSoundEffect(Sound.BLOCK_STONE_BUTTON_CLICK_ON, 1.0f, soundPitch)
)
})
)
}
)
Expand Down Expand Up @@ -303,20 +301,18 @@ object SecondPage extends Menu {
FilteredButtonEffect(ClickEventFilter.LEFT_CLICK) { _ =>
SequentialEffect(
playerData.settings.toggleWorldGuardLogEffect,
DeferredEffect(
IO {
val (soundPitch, message) =
if (playerData.settings.shouldDisplayWorldGuardLogs)
(1.0f, s"${GREEN}ワールドガード保護メッセージ:表示")
else
(0.5f, s"${RED}ワールドガード保護メッセージ:隠す")

SequentialEffect(
FocusedSoundEffect(Sound.BLOCK_STONE_BUTTON_CLICK_ON, 1.0f, soundPitch),
MessageEffect(message)
)
}
)
DeferredEffect(IO {
val (soundPitch, message) =
if (playerData.settings.shouldDisplayWorldGuardLogs)
(1.0f, s"${GREEN}ワールドガード保護メッセージ:表示")
else
(0.5f, s"${RED}ワールドガード保護メッセージ:隠す")

SequentialEffect(
FocusedSoundEffect(Sound.BLOCK_STONE_BUTTON_CLICK_ON, 1.0f, soundPitch),
MessageEffect(message)
)
})
)
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,10 @@ class GrantBukkitFastDiggingEffect[F[_]: OnMinecraftServerThread]
val potionEffect = new PotionEffect(PotionEffectType.FAST_DIGGING, 40, amount, false, false)

// ポーション効果の削除及び付与はメインスレッドでのみ許可される(Spigot 1.12)
OnMinecraftServerThread[F].runAction(
SyncIO[Unit] {
player.removePotionEffect(PotionEffectType.FAST_DIGGING)
player.addPotionEffect(potionEffect)
}
)
OnMinecraftServerThread[F].runAction(SyncIO[Unit] {
player.removePotionEffect(PotionEffectType.FAST_DIGGING)
player.addPotionEffect(potionEffect)
})
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -325,17 +325,15 @@ object BreakUtil {

_ <- PluginExecutionContexts
.onMainThread
.runAction(
SyncIO {
// アイテムドロップは非同期スレッドで行ってはならない
itemsToBeDropped
.filterNot(_.getType == Material.AIR)
.foreach(dropLocation.getWorld.dropItemNaturally(dropLocation, _))
breakResults._2.foreach { location =>
location.getWorld.spawnEntity(location, EntityType.SILVERFISH)
}
.runAction(SyncIO {
// アイテムドロップは非同期スレッドで行ってはならない
itemsToBeDropped
.filterNot(_.getType == Material.AIR)
.foreach(dropLocation.getWorld.dropItemNaturally(dropLocation, _))
breakResults._2.foreach { location =>
location.getWorld.spawnEntity(location, EntityType.SILVERFISH)
}
)
})
} yield ()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,23 +50,21 @@ object LaunchFireWorksEffect {
// 爆発後に尾を引くかをランダムに決める
effect.trail(rand.nextBoolean())

OnMinecraftServerThread[F].runAction(
SyncIO {
// 花火を作る
val firework = loc.getWorld.spawn(loc, classOf[Firework])
OnMinecraftServerThread[F].runAction(SyncIO {
// 花火を作る
val firework = loc.getWorld.spawn(loc, classOf[Firework])

// 花火の設定情報オブジェクトを取り出す
val meta = firework.getFireworkMeta
// 花火の設定情報オブジェクトを取り出す
val meta = firework.getFireworkMeta

// 打ち上げ高さを1以上4以内でランダムに決める
meta.setPower(1 + rand.nextInt(4))
// 打ち上げ高さを1以上4以内でランダムに決める
meta.setPower(1 + rand.nextInt(4))

// 花火の設定情報を花火に設定
meta.addEffect(effect.build())
// 花火の設定情報を花火に設定
meta.addEffect(effect.build())

firework.setFireworkMeta(meta)
}
)
firework.setFireworkMeta(meta)
})
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,20 @@ object PlayerEffects {
)(implicit onMainThread: OnMinecraftServerThread[IO]): TargetedEffect[Player] =
Kleisli { player =>
// BungeeCordのサーバ移動はサーバスレッドでなければならない(Spigot 1.12.2)
onMainThread.runAction(
SyncIO {

import com.google.common.io.ByteStreams

val byteArrayDataOutput = ByteStreams.newDataOutput()
import byteArrayDataOutput._
writeUTF("Connect")
writeUTF(serverIdentifier)
player.sendPluginMessage(
SeichiAssist.instance,
"BungeeCord",
byteArrayDataOutput.toByteArray
)
}
)
onMainThread.runAction(SyncIO {

import com.google.common.io.ByteStreams

val byteArrayDataOutput = ByteStreams.newDataOutput()
import byteArrayDataOutput._
writeUTF("Connect")
writeUTF(serverIdentifier)
player.sendPluginMessage(
SeichiAssist.instance,
"BungeeCord",
byteArrayDataOutput.toByteArray
)
})
}

}