Skip to content

Commit

Permalink
feat: 参加・退出メッセージを出すsubsystemを実装
Browse files Browse the repository at this point in the history
  • Loading branch information
rito528 committed Dec 26, 2023
1 parent 28878b7 commit 31c93b5
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,9 @@ class SeichiAssist extends JavaPlugin() {
private lazy val gridRegionSystem: subsystems.gridregion.System[IO, Player, Location] =
subsystems.gridregion.System.wired[IO, SyncIO].unsafeRunSync()

private lazy val joinAndQuitMessenger: Subsystem[IO] =
subsystems.joinandquitmessenger.System.wired[IO]

private lazy val wiredSubsystems: List[Subsystem[IO]] = List(
mebiusSystem,
expBottleStackSystem,
Expand Down Expand Up @@ -534,7 +537,8 @@ class SeichiAssist extends JavaPlugin() {
consumeGachaTicketSystem,
openirontrapdoor.System.wired,
gridRegionSystem,
breakSkillTargetConfigSystem
breakSkillTargetConfigSystem,
joinAndQuitMessenger
)

private lazy val buildAssist: BuildAssist = {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.github.unchama.seichiassist.subsystems.joinandquitmessenger

import com.github.unchama.seichiassist.meta.subsystem.Subsystem
import com.github.unchama.seichiassist.subsystems.joinandquitmessenger.bukkit.JoinAndQuitListeners
import org.bukkit.event.Listener

object System {

def wired[F[_]]: Subsystem[F] = {
new Subsystem[F] {
override val listeners: Seq[Listener] = Seq(new JoinAndQuitListeners)
}
}

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

import com.github.unchama.seichiassist.subsystems.joinandquitmessenger.domain.Messages
import org.bukkit.ChatColor
import org.bukkit.event.Listener
import org.bukkit.event.player.{PlayerJoinEvent, PlayerQuitEvent}

class JoinAndQuitListeners extends Listener {

def onJoin(event: PlayerJoinEvent): Unit = {
event.setJoinMessage(s"${ChatColor.GRAY}${Messages.joinMessage(event.getPlayer.getName)}")
}

def onQuit(event: PlayerQuitEvent): Unit = {
event.setQuitMessage(Messages.quitMessage(event.getPlayer.getName))
}

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

object Messages {

def joinMessage(playerName: String): String = s"$playerName がログインしました"

// Note: 整地鯖では退出メッセージを表示しない
def quitMessage(playerName: String): String = ""

}

0 comments on commit 31c93b5

Please sign in to comment.