diff --git a/build.gradle.kts b/build.gradle.kts index bafeff0..bdb4367 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -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().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:.*")) } } diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..0d6aa7b --- /dev/null +++ b/gradle.properties @@ -0,0 +1 @@ +kotlin.stdlib.default.dependency=false diff --git a/libs/GxUI-OG b/libs/GxUI-OG index e606c9d..cc77691 160000 --- a/libs/GxUI-OG +++ b/libs/GxUI-OG @@ -1 +1 @@ -Subproject commit e606c9d638fc31eae18884b211703851333b0d8e +Subproject commit cc77691f2e5979532988b692dab844468bf50120 diff --git a/src/main/kotlin/net/trueog/questsOG/ClaimQuest.kt b/src/main/kotlin/net/trueog/questsOG/ClaimQuest.kt index 233f865..e219850 100644 --- a/src/main/kotlin/net/trueog/questsOG/ClaimQuest.kt +++ b/src/main/kotlin/net/trueog/questsOG/ClaimQuest.kt @@ -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?): Boolean { + override fun onCommand(sender: CommandSender, command: Command, label: String, args: Array): Boolean { val debug = QuestsOG.config.debug if (debug) QuestsOG.plugin.logger.info("/claimquest invoked by ${sender.name}") if (sender !is Player) { diff --git a/src/main/kotlin/net/trueog/questsOG/QuestGuiCommand.kt b/src/main/kotlin/net/trueog/questsOG/QuestGuiCommand.kt index 3c4b377..fabead5 100644 --- a/src/main/kotlin/net/trueog/questsOG/QuestGuiCommand.kt +++ b/src/main/kotlin/net/trueog/questsOG/QuestGuiCommand.kt @@ -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?): Boolean { + override fun onCommand(sender: CommandSender, command: Command, label: String, args: Array): 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 } } diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 2c1e220..ea8b0cf 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -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