mirror of
				https://github.com/GayPizzaSpecifications/foundation.git
				synced 2025-11-04 11:39:39 +00:00 
			
		
		
		
	Bifrost: Implement player advancement notifications. Oh my god this was hard and it still is ugly.
This commit is contained in:
		@ -3,6 +3,7 @@ package cloud.kubelet.foundation.bifrost
 | 
			
		||||
import cloud.kubelet.foundation.bifrost.model.BifrostConfig
 | 
			
		||||
import cloud.kubelet.foundation.core.FoundationCorePlugin
 | 
			
		||||
import cloud.kubelet.foundation.core.Util
 | 
			
		||||
import cloud.kubelet.foundation.core.util.AdvancementTitleCache
 | 
			
		||||
import com.charleskorn.kaml.Yaml
 | 
			
		||||
import io.papermc.paper.event.player.AsyncChatEvent
 | 
			
		||||
import net.dv8tion.jda.api.EmbedBuilder
 | 
			
		||||
@ -19,6 +20,7 @@ import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer
 | 
			
		||||
import org.bukkit.event.EventHandler
 | 
			
		||||
import org.bukkit.event.EventPriority
 | 
			
		||||
import org.bukkit.event.entity.PlayerDeathEvent
 | 
			
		||||
import org.bukkit.event.player.PlayerAdvancementDoneEvent
 | 
			
		||||
import org.bukkit.event.player.PlayerJoinEvent
 | 
			
		||||
import org.bukkit.event.player.PlayerQuitEvent
 | 
			
		||||
import org.bukkit.plugin.java.JavaPlugin
 | 
			
		||||
@ -162,6 +164,17 @@ class FoundationBifrostPlugin : JavaPlugin(), DiscordEventListener, BukkitEventL
 | 
			
		||||
    sendEmbedMessage(Color.YELLOW, deathMessage)
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  @EventHandler(priority = EventPriority.MONITOR)
 | 
			
		||||
  private fun onPlayerAdvancementDone(e: PlayerAdvancementDoneEvent) {
 | 
			
		||||
    if (!config.channel.sendPlayerAdvancement) return
 | 
			
		||||
    if (e.advancement.key.key.contains("recipe/")) {
 | 
			
		||||
      return
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    val display = AdvancementTitleCache.of(e.advancement) ?: return
 | 
			
		||||
    sendEmbedMessage(Color.CYAN, "${e.player.name} completed the advancement '${display}'")
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private fun onDiscordReady() {
 | 
			
		||||
    if (!config.channel.sendStart) return
 | 
			
		||||
    if (isDev) return
 | 
			
		||||
 | 
			
		||||
@ -22,5 +22,6 @@ data class BifrostChannel(
 | 
			
		||||
  val sendShutdown: Boolean = true,
 | 
			
		||||
  val sendPlayerJoin: Boolean = true,
 | 
			
		||||
  val sendPlayerQuit: Boolean = true,
 | 
			
		||||
  val sendPlayerDeath: Boolean = true
 | 
			
		||||
  val sendPlayerDeath: Boolean = true,
 | 
			
		||||
  val sendPlayerAdvancement: Boolean = true
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
@ -19,6 +19,7 @@ channel:
 | 
			
		||||
  sendPlayerJoin: true
 | 
			
		||||
  sendPlayerQuit: true
 | 
			
		||||
  sendPlayerDeath: true
 | 
			
		||||
  sendPlayerAdvancement: true
 | 
			
		||||
 | 
			
		||||
# Enables logging of what is sent to Discord.
 | 
			
		||||
enableDebugLog: false
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user