New progress API

This commit is contained in:
NotAlexNoyle committed 2026-07-20 01:02:03 -04:00
1 parent 13c9b0ce44
commit aebd49e51a
6 files changed
+73 -22

No files matched your search

+15 -4
View File
@@ -1,5 +1,6 @@
/* This is free and unencumbered software released into the public domain */
import com.github.jengelman.gradle.plugins.shadow.internal.RelocationUtil
import java.io.BufferedReader
import org.gradle.kotlin.dsl.provideDelegate
@@ -72,8 +73,10 @@ repositories {
dependencies {
compileOnly("org.purpurmc.purpur:purpur-api:1.19.4-R0.1-SNAPSHOT") // Declare Purpur API version to be packaged.
compileOnly("net.luckperms:api:5.5") // Import the LuckPerms API.
implementation("org.jetbrains.kotlin:kotlin-stdlib") // Import Kotlin standard library.
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.2") // Import Kotlin async library.
compileOnly("org.jetbrains.kotlin:kotlin-stdlib") // Provided by DiamondBank-OG's shaded Kotlin runtime.
compileOnly(
"org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.2"
) // Provided by DiamondBank-OG's shaded coroutine runtime.
implementation("io.lettuce:lettuce-core:7.2.0.RELEASE") // Import Lettuce API for keydb.
implementation("org.slf4j:slf4j-nop:2.0.17") // Provide SLF4J NOP provider to suppress missing-provider warning.
implementation("org.slf4j:slf4j-api:2.0.17") // Bundle a relocated SLF4J API for shaded dependencies.
@@ -83,7 +86,12 @@ dependencies {
compileOnlyApi(project(":libs:DiamondBank-OG")) {
attributes { attribute(kotlinAttribute, true) }
} // Import TrueOG network DiamondBank-OG Kotlin API (from source).
implementation(project(":libs:GxUI-OG")) // Shade TrueOG Network GxUI-OG advancement menu API into this plugin.
implementation(project(":libs:GxUI-OG")) // Shade TrueOG Network GxUI-OG progress menu API into this plugin.
}
configurations.runtimeClasspath {
exclude(group = "org.jetbrains.kotlin")
exclude(group = "org.jetbrains.kotlinx")
}
/* ---------------------- Reproducible jars ---------------------------- */
@@ -95,8 +103,11 @@ tasks.withType<AbstractArchiveTask>().configureEach { // Ensure reproducible .ja
/* ----------------------------- Shadow -------------------------------- */
tasks.shadowJar {
archiveClassifier.set("") // Use empty string instead of null.
isEnableRelocation = true
isEnableRelocation = false
relocationPrefix = "${project.group}.shadow"
relocate("kotlin", "net.trueog.diamondbankog.shadow.kotlin")
relocate("kotlinx", "net.trueog.diamondbankog.shadow.kotlinx")
doFirst { RelocationUtil.configureRelocation(this@shadowJar, relocationPrefix) }
mergeServiceFiles()
minimize { exclude(dependency("org.slf4j:slf4j-nop:.*")) }
}
+1
View File
@@ -0,0 +1 @@
kotlin.stdlib.default.dependency=false
@@ -9,7 +9,7 @@ import org.bukkit.command.CommandSender
import org.bukkit.entity.Player
class ClaimQuest : CommandExecutor {
override fun onCommand(sender: CommandSender, command: Command, label: String, args: Array<out String>?): Boolean {
override fun onCommand(sender: CommandSender, command: Command, label: String, args: Array<out String>): Boolean {
val debug = QuestsOG.config.debug
if (debug) QuestsOG.plugin.logger.info("/claimquest invoked by ${sender.name}")
if (sender !is Player) {
@@ -1,17 +1,17 @@
package net.trueog.questsOG
import kotlinx.coroutines.launch
import net.trueog.gxui.advancements.AdvancementMenu
import net.trueog.gxui.advancements.AdvancementState
import net.trueog.gxui.progress.ProgressMenu
import net.trueog.questsOG.progression.HomesProgression
import net.trueog.questsOG.quests.Quest
import org.bukkit.Material
import org.bukkit.command.Command
import org.bukkit.command.CommandExecutor
import org.bukkit.command.CommandSender
import org.bukkit.entity.Player
class QuestGuiCommand : CommandExecutor {
override fun onCommand(sender: CommandSender, command: Command, label: String, args: Array<out String>?): Boolean {
override fun onCommand(sender: CommandSender, command: Command, label: String, args: Array<out String>): Boolean {
val debug = QuestsOG.config.debug
if (debug) QuestsOG.plugin.logger.info("/questgui invoked by ${sender.name}")
if (sender !is Player) {
@@ -24,22 +24,28 @@ class QuestGuiCommand : CommandExecutor {
if (debug) QuestsOG.plugin.logger.info("/questgui coroutine entered for ${sender.name}")
val nextQuest = HomesProgression.getNextQuest(sender)
if (debug) QuestsOG.plugin.logger.info("/questgui nextQuest=${nextQuest?.javaClass?.simpleName}")
val builder = AdvancementMenu.builder(QuestsOG.plugin, sender, "&aHome Quests")
val builder = ProgressMenu.builder(QuestsOG.plugin, sender, "&aHome Quests")
HomesProgression.quests.forEach { quest ->
builder.add(questName(quest), stateFor(quest, nextQuest))
builder.section(questName(quest), stateFor(quest, nextQuest))
quest.getRequirements(sender)?.forEach { requirement ->
when (requirement) {
is ProgressRequirement ->
builder.progress(requirement.name, requirement.current, requirement.target)
is BooleanRequirement -> builder.bool(requirement.name, requirement.met)
builder.progress(
materialFor(requirement),
requirement.name,
requirement.current,
requirement.target,
)
is BooleanRequirement ->
builder.goal(materialFor(requirement), requirement.name, requirement.met)
}
}
if (quest == nextQuest) builder.footer("&7Use &e/claimquest &7when ready.")
if (quest == nextQuest) builder.description("&7Use &e/claimquest &7when ready.")
}
if (debug) QuestsOG.plugin.logger.info("/questgui dispatching builder.open on main thread")
MainThreadBlock.runOnMainThread { builder.open(args) }
MainThreadBlock.runOnMainThread { builder.open() }
if (debug) QuestsOG.plugin.logger.info("/questgui done")
} catch (t: Throwable) {
QuestsOG.plugin.logger.severe("/questgui failed: ${t.message}")
@@ -52,12 +58,45 @@ class QuestGuiCommand : CommandExecutor {
private fun questName(quest: Quest): String = "Home ${HomesProgression.getHomeCount(quest)} Quest"
private fun stateFor(quest: Quest, nextQuest: Quest?): AdvancementState =
private fun stateFor(quest: Quest, nextQuest: Quest?): ProgressMenu.State =
when {
nextQuest == null -> AdvancementState.COMPLETE
quest == nextQuest -> AdvancementState.IN_PROGRESS
nextQuest == null -> ProgressMenu.State.COMPLETE
quest == nextQuest -> ProgressMenu.State.IN_PROGRESS
HomesProgression.quests.indexOf(quest) < HomesProgression.quests.indexOf(nextQuest) ->
AdvancementState.COMPLETE
else -> AdvancementState.LOCKED
ProgressMenu.State.COMPLETE
else -> ProgressMenu.State.NOT_STARTED
}
private fun materialFor(requirement: Requirement): Material =
when (requirement.name) {
"Total Shards" -> Material.DIAMOND
"Hours Played",
"Days Played" -> Material.CLOCK
"Blocks Travelled" -> Material.LEATHER_BOOTS
"Levels" -> Material.EXPERIENCE_BOTTLE
"Duels Wins" -> Material.IRON_SWORD
"Beaconator" -> Material.BEACON
"A Furious Cocktail" -> Material.POTION
"Serious Dedication" -> Material.NETHERITE_HOE
"Died to \"death.fell.accident.water\"" -> Material.WATER_BUCKET
"Blocks Travelled on Pig" -> Material.CARROT_ON_A_STICK
"Blocks Travelled on Strider" -> Material.WARPED_FUNGUS_ON_A_STICK
"Dolphins Killed" -> Material.DOLPHIN_SPAWN_EGG
"Zoglins Killed" -> Material.ZOGLIN_SPAWN_EGG
"The Cutest Predator" -> Material.AXOLOTL_BUCKET
"Two by Two" -> Material.WHEAT
"A Complete Catalogue" -> Material.CAT_SPAWN_EGG
"Monsters Hunted" -> Material.DIAMOND_SWORD
"Died to \"fell while climbing\"" -> Material.LADDER
"Died to \"walked into the danger zone due to Zoglin\"" -> Material.MAGMA_BLOCK
"Fish Caught" -> Material.FISHING_ROD
"Has Villager Head" -> Material.PLAYER_HEAD
"Blocks Walked on Water" -> Material.ICE
"Blocks Walked Under Water" -> Material.PRISMARINE
"Music Discs" -> Material.JUKEBOX
"Finished Advancements" -> Material.RED_CONCRETE
"Obsidian Mined" -> Material.OBSIDIAN
"Dragon Eggs" -> Material.DRAGON_EGG
else -> Material.PAPER
}
}
+2 -2
View File
@@ -11,5 +11,5 @@ commands:
description: Claims a quest, duh
usage: /claimquest
questgui:
description: Open the homes quest menu. Optional page argument (e.g. /questgui 2).
usage: /questgui [page]
description: Open the layered homes quest menu.
usage: /questgui