diff --git a/foundation-bifrost/src/main/kotlin/cloud/kubelet/foundation/bifrost/FoundationBifrostPlugin.kt b/foundation-bifrost/src/main/kotlin/cloud/kubelet/foundation/bifrost/FoundationBifrostPlugin.kt index 9453650..9e876b7 100644 --- a/foundation-bifrost/src/main/kotlin/cloud/kubelet/foundation/bifrost/FoundationBifrostPlugin.kt +++ b/foundation-bifrost/src/main/kotlin/cloud/kubelet/foundation/bifrost/FoundationBifrostPlugin.kt @@ -63,9 +63,7 @@ class FoundationBifrostPlugin : JavaPlugin(), EventListener, Listener { override fun onEvent(e: GenericEvent) { when (e) { is ReadyEvent -> { - val channel = getChannel() ?: return - if (isDev) return - channel.sendMessage(":white_check_mark: Server is ready!").queue() + onDiscordReady() } is MessageReceivedEvent -> { // Prevent this bot from receiving its own messages and creating a feedback loop. @@ -97,6 +95,7 @@ class FoundationBifrostPlugin : JavaPlugin(), EventListener, Listener { @EventHandler private fun onPlayerJoin(e: PlayerJoinEvent) { + if (!config.channel.sendPlayerJoin) return val channel = getChannel() ?: return channel.sendMessage(message { @@ -109,6 +108,7 @@ class FoundationBifrostPlugin : JavaPlugin(), EventListener, Listener { @EventHandler private fun onPlayerQuit(e: PlayerQuitEvent) { + if (!config.channel.sendPlayerQuit) return val channel = getChannel() ?: return channel.sendMessage(message { @@ -131,7 +131,15 @@ class FoundationBifrostPlugin : JavaPlugin(), EventListener, Listener { } } + private fun onDiscordReady() { + if (!config.channel.sendStart) return + val channel = getChannel() ?: return + if (isDev) return + channel.sendMessage(":white_check_mark: Server is ready!").queue() + } + private fun onServerStop() { + if (!config.channel.sendShutdown) return val channel = getChannel() ?: return if (isDev) return channel.sendMessage(":octagonal_sign: Server is stopping!").queue() diff --git a/foundation-bifrost/src/main/kotlin/cloud/kubelet/foundation/bifrost/model/BifrostConfig.kt b/foundation-bifrost/src/main/kotlin/cloud/kubelet/foundation/bifrost/model/BifrostConfig.kt index 8b9f6b9..40464e3 100644 --- a/foundation-bifrost/src/main/kotlin/cloud/kubelet/foundation/bifrost/model/BifrostConfig.kt +++ b/foundation-bifrost/src/main/kotlin/cloud/kubelet/foundation/bifrost/model/BifrostConfig.kt @@ -16,4 +16,8 @@ data class BifrostAuthentication( @Serializable data class BifrostChannel( val id: String, + val sendStart: Boolean = true, + val sendShutdown: Boolean = true, + val sendPlayerJoin: Boolean = true, + val sendPlayerQuit: Boolean = true, ) diff --git a/foundation-bifrost/src/main/resources/bifrost.yaml b/foundation-bifrost/src/main/resources/bifrost.yaml index 63338cb..13384f4 100644 --- a/foundation-bifrost/src/main/resources/bifrost.yaml +++ b/foundation-bifrost/src/main/resources/bifrost.yaml @@ -8,3 +8,9 @@ channel: # Channel ID, can be copied by turning on Developer Mode in User Settings -> Advanced. The ID can # then be copied by right-clicking the channel and selecting "Copy ID". id: 123456789 + + # Toggles for common events that generate notifications that are sent to the channel. + sendStart: true + sendShutdown: true + sendPlayerJoin: true + sendPlayerQuit: true