mirror of
https://github.com/GayPizzaSpecifications/foundation.git
synced 2025-08-02 13:10:55 +00:00
Add toggles for start, shutdown, player join and quit events.
This commit is contained in:
parent
4439fe74a6
commit
b8c8097f58
@ -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()
|
||||
|
@ -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,
|
||||
)
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user