diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoquests/EcoQuestsPlugin.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoquests/EcoQuestsPlugin.kt index 21b57cc..846a95a 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoquests/EcoQuestsPlugin.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoquests/EcoQuestsPlugin.kt @@ -1,6 +1,8 @@ package com.willfp.ecoquests import com.willfp.eco.core.command.impl.PluginCommand +import com.willfp.eco.core.placeholder.PlayerPlaceholder +import com.willfp.eco.core.placeholder.PlayerlessPlaceholder import com.willfp.ecoquests.commands.CommandEcoQuests import com.willfp.ecoquests.commands.CommandQuests import com.willfp.ecoquests.gui.PreviousQuestsGUI @@ -16,6 +18,20 @@ import org.bukkit.event.Listener class EcoQuestsPlugin : LibreforgePlugin() { + override fun handleEnable() { + PlayerlessPlaceholder(this, "quests_amount") { + Quests.values().size.toString() + } + + PlayerPlaceholder(this, "quests_completed") { + Quests.getCompletedQuests(it).size.toString() + } + + PlayerPlaceholder(this, "quests_active") { + Quests.getActiveQuests(it).size.toString() + } + } + override fun handleReload() { PreviousQuestsGUI.reload(this) QuestsGUI.reload(this) diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoquests/gui/QuestsGUI.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoquests/gui/QuestsGUI.kt index 760e70a..a97b262 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoquests/gui/QuestsGUI.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoquests/gui/QuestsGUI.kt @@ -20,7 +20,7 @@ object QuestsGUI { fun reload(plugin: EcoPlugin) { val questAreaComponent = QuestAreaComponent(plugin.configYml.getSubsection("gui.quest-area")) { - Quests.getCurrentlyActiveQuests(it) + Quests.getActiveQuests(it) } menu = menu(plugin.configYml.getInt("gui.rows")) { diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoquests/quests/Quest.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoquests/quests/Quest.kt index c241d84..9ba1321 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoquests/quests/Quest.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoquests/quests/Quest.kt @@ -8,9 +8,12 @@ import com.willfp.eco.core.data.profile import com.willfp.eco.core.gui.slot import com.willfp.eco.core.items.Items import com.willfp.eco.core.items.builder.modify +import com.willfp.eco.core.placeholder.PlayerPlaceholder +import com.willfp.eco.core.placeholder.PlayerlessPlaceholder import com.willfp.eco.core.placeholder.context.placeholderContext import com.willfp.eco.core.registry.KRegistrable import com.willfp.eco.util.formatEco +import com.willfp.eco.util.toNiceString import com.willfp.ecoquests.api.event.PlayerQuestCompleteEvent import com.willfp.ecoquests.api.event.PlayerQuestStartEvent import com.willfp.ecoquests.tasks.Tasks @@ -19,6 +22,7 @@ import com.willfp.libreforge.ViolationContext import com.willfp.libreforge.conditions.Conditions import com.willfp.libreforge.effects.Effects import com.willfp.libreforge.effects.executors.impl.NormalExecutorFactory +import jdk.tools.jlink.internal.plugins.PluginsResourceBundle.getDescription import org.bukkit.Bukkit import org.bukkit.entity.Player @@ -79,6 +83,24 @@ class Quest( ViolationContext(plugin, "quest $id start-conditions") ) + init { + PlayerPlaceholder(plugin, "quest_${id}_started") { + hasStarted(it).toNiceString() + } + + PlayerPlaceholder(plugin, "quest_${id}_completed") { + hasCompleted(it).toNiceString() + } + + PlayerlessPlaceholder(plugin, "quest_${id}_tasks") { + this.tasks.size.toNiceString() + } + + PlayerPlaceholder(plugin, "quest_${id}_tasks_completed") { + this.tasks.count { t -> t.hasCompleted(it) }.toNiceString() + } + } + fun hasCompleted(player: Player): Boolean { return player.profile.read(hasCompletedKey) } diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoquests/quests/Quests.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoquests/quests/Quests.kt index 573beda..9dade9e 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoquests/quests/Quests.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoquests/quests/Quests.kt @@ -21,7 +21,7 @@ object Quests : ConfigCategory("quest", "quests") { fun values(): Collection = registry.values() - fun getCurrentlyActiveQuests(player: Player): List { + fun getActiveQuests(player: Player): List { return values() .filter { it.hasStarted(player) } .filterNot { it.hasCompleted(player) } diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoquests/tasks/Task.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoquests/tasks/Task.kt index 180ca9e..901f656 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoquests/tasks/Task.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoquests/tasks/Task.kt @@ -5,6 +5,9 @@ import com.willfp.eco.core.config.interfaces.Config import com.willfp.eco.core.data.keys.PersistentDataKey import com.willfp.eco.core.data.keys.PersistentDataKeyType import com.willfp.eco.core.data.profile +import com.willfp.eco.core.integrations.placeholder.PlaceholderManager +import com.willfp.eco.core.placeholder.PlayerPlaceholder +import com.willfp.eco.core.placeholder.PlayerlessPlaceholder import com.willfp.eco.core.registry.KRegistrable import com.willfp.eco.util.formatEco import com.willfp.eco.util.lineWrap @@ -45,6 +48,24 @@ class Task( } } + init { + PlayerPlaceholder(plugin, "task_${id}_required_xp") { + getExperienceRequired(it).toNiceString() + } + + PlayerPlaceholder(plugin, "task_${id}_xp") { + getExperience(it).toNiceString() + } + + PlayerPlaceholder(plugin, "task_${id}_description") { + getDescription(it) + } + + PlayerPlaceholder(plugin, "task_${id}_completed") { + hasCompleted(it).toNiceString() + } + } + override fun onRegister() { for (counter in xpGainMethods) { counter.bind(accumulator)