mirror of
				https://github.com/GayPizzaSpecifications/foundation.git
				synced 2025-11-04 11:39:39 +00:00 
			
		
		
		
	Add toggles for start, shutdown, player join and quit events.
This commit is contained in:
		@ -63,9 +63,7 @@ class FoundationBifrostPlugin : JavaPlugin(), EventListener, Listener {
 | 
				
			|||||||
  override fun onEvent(e: GenericEvent) {
 | 
					  override fun onEvent(e: GenericEvent) {
 | 
				
			||||||
    when (e) {
 | 
					    when (e) {
 | 
				
			||||||
      is ReadyEvent -> {
 | 
					      is ReadyEvent -> {
 | 
				
			||||||
        val channel = getChannel() ?: return
 | 
					        onDiscordReady()
 | 
				
			||||||
        if (isDev) return
 | 
					 | 
				
			||||||
        channel.sendMessage(":white_check_mark: Server is ready!").queue()
 | 
					 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      is MessageReceivedEvent -> {
 | 
					      is MessageReceivedEvent -> {
 | 
				
			||||||
        // Prevent this bot from receiving its own messages and creating a feedback loop.
 | 
					        // Prevent this bot from receiving its own messages and creating a feedback loop.
 | 
				
			||||||
@ -97,6 +95,7 @@ class FoundationBifrostPlugin : JavaPlugin(), EventListener, Listener {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  @EventHandler
 | 
					  @EventHandler
 | 
				
			||||||
  private fun onPlayerJoin(e: PlayerJoinEvent) {
 | 
					  private fun onPlayerJoin(e: PlayerJoinEvent) {
 | 
				
			||||||
 | 
					    if (!config.channel.sendPlayerJoin) return
 | 
				
			||||||
    val channel = getChannel() ?: return
 | 
					    val channel = getChannel() ?: return
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    channel.sendMessage(message {
 | 
					    channel.sendMessage(message {
 | 
				
			||||||
@ -109,6 +108,7 @@ class FoundationBifrostPlugin : JavaPlugin(), EventListener, Listener {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  @EventHandler
 | 
					  @EventHandler
 | 
				
			||||||
  private fun onPlayerQuit(e: PlayerQuitEvent) {
 | 
					  private fun onPlayerQuit(e: PlayerQuitEvent) {
 | 
				
			||||||
 | 
					    if (!config.channel.sendPlayerQuit) return
 | 
				
			||||||
    val channel = getChannel() ?: return
 | 
					    val channel = getChannel() ?: return
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    channel.sendMessage(message {
 | 
					    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() {
 | 
					  private fun onServerStop() {
 | 
				
			||||||
 | 
					    if (!config.channel.sendShutdown) return
 | 
				
			||||||
    val channel = getChannel() ?: return
 | 
					    val channel = getChannel() ?: return
 | 
				
			||||||
    if (isDev) return
 | 
					    if (isDev) return
 | 
				
			||||||
    channel.sendMessage(":octagonal_sign: Server is stopping!").queue()
 | 
					    channel.sendMessage(":octagonal_sign: Server is stopping!").queue()
 | 
				
			||||||
 | 
				
			|||||||
@ -16,4 +16,8 @@ data class BifrostAuthentication(
 | 
				
			|||||||
@Serializable
 | 
					@Serializable
 | 
				
			||||||
data class BifrostChannel(
 | 
					data class BifrostChannel(
 | 
				
			||||||
  val id: String,
 | 
					  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
 | 
					  # 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".
 | 
					  # then be copied by right-clicking the channel and selecting "Copy ID".
 | 
				
			||||||
  id: 123456789
 | 
					  id: 123456789
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  # Toggles for common events that generate notifications that are sent to the channel.
 | 
				
			||||||
 | 
					  sendStart: true
 | 
				
			||||||
 | 
					  sendShutdown: true
 | 
				
			||||||
 | 
					  sendPlayerJoin: true
 | 
				
			||||||
 | 
					  sendPlayerQuit: true
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user