diff options
4 files changed, 28 insertions, 7 deletions
diff --git a/bukkit/src/main/java/com/leonardobishop/quests/bukkit/hook/papi/QuestsPlaceholders.java b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/hook/papi/QuestsPlaceholders.java index 3da9db44..f4a778ea 100644 --- a/bukkit/src/main/java/com/leonardobishop/quests/bukkit/hook/papi/QuestsPlaceholders.java +++ b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/hook/papi/QuestsPlaceholders.java @@ -11,6 +11,7 @@ import com.leonardobishop.quests.common.player.questprogressfile.QuestProgress; import com.leonardobishop.quests.common.player.questprogressfile.QuestProgressFile; import com.leonardobishop.quests.common.quest.Category; import com.leonardobishop.quests.common.quest.Quest; +import com.leonardobishop.quests.common.quest.Task; import me.clip.placeholderapi.expansion.Cacheable; import me.clip.placeholderapi.expansion.PlaceholderExpansion; import org.bukkit.entity.Player; @@ -76,7 +77,7 @@ public class QuestsPlaceholders extends PlaceholderExpansion implements Cacheabl if (qPlayer == null) return Messages.PLACEHOLDERAPI_DATA_NOT_LOADED.getMessageLegacyColor(); String split = args[args.length - 1]; - String result = "null"; + String result; if (!args[0].contains(":") && !args[0].equalsIgnoreCase("tracked")) { if (args.length > 1 && split.equals(args[1])) split = ","; @@ -233,6 +234,11 @@ public class QuestsPlaceholders extends PlaceholderExpansion implements Cacheabl case "c": result = String.valueOf(questProgress.getTaskProgress(t[1]).isCompleted() ? Messages.PLACEHOLDERAPI_TRUE.getMessageLegacyColor() : Messages.PLACEHOLDERAPI_FALSE.getMessageLegacyColor()); break; + case "goal": + case "g": + final Task task = quest.getTaskById(t[1]); + result = (task != null ? String.valueOf(plugin.getTaskTypeManager().getTaskType(task.getType()).getGoal(task)) : "0"); + break; default: return args[0] + "_" + args[1] + "_" + args[2] + " is not a valid placeholder"; } diff --git a/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/PlaytimeTaskType.java b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/PlaytimeTaskType.java index 3ca75a16..ea6cb339 100644 --- a/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/PlaytimeTaskType.java +++ b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/PlaytimeTaskType.java @@ -14,6 +14,8 @@ import com.leonardobishop.quests.common.quest.Quest; import com.leonardobishop.quests.common.quest.Task; import org.bukkit.Bukkit; import org.bukkit.entity.Player; +import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.Nullable; public final class PlaytimeTaskType extends BukkitTaskType { @@ -104,4 +106,9 @@ public final class PlaytimeTaskType extends BukkitTaskType { // this.poll.cancel(); // } } + + @Override + public @Nullable Object getGoal(final @NonNull Task task) { + return task.getConfigValue("minutes"); + } } diff --git a/common/src/main/java/com/leonardobishop/quests/common/tasktype/TaskType.java b/common/src/main/java/com/leonardobishop/quests/common/tasktype/TaskType.java index 7e294c55..dd3e1058 100644 --- a/common/src/main/java/com/leonardobishop/quests/common/tasktype/TaskType.java +++ b/common/src/main/java/com/leonardobishop/quests/common/tasktype/TaskType.java @@ -194,6 +194,13 @@ public abstract class TaskType { } /** + * Returns the goal of a task. + */ + public @Nullable Object getGoal(final Task task) { + return task.getConfigValue("amount", "-"); + } + + /** * A functional interface for validating task configuration. */ @FunctionalInterface diff --git a/docs/tools/placeholderapi.md b/docs/tools/placeholderapi.md index c75a9522..40f377c7 100644 --- a/docs/tools/placeholderapi.md +++ b/docs/tools/placeholderapi.md @@ -78,6 +78,7 @@ The eCloud extension called 'Quests' is not for this plugin, do not download it! | `%quests_quest:<quest-id>_meetsrequirements%` | Returns **true/false** on whether or not the player has completed the required quests for the quest **`<quest-id>`**. | | `%quests_quest:<quest-id>_task:<task-id>_progress%` | Returns the **progress** of task **`task-id`** on the quest **`<quest-id>`**. | | `%quests_quest:<quest-id>_task:<task-id>_completed%` | Returns **true/false** on whether or not the task **`task-id`** on the quest **`<quest-id>`** is completed by the player. | +| `%quests_quest:<quest-id>_task:<task-id>_goal%` | Returns the **goal** of task **`task-id`** on the quest **`<quest-id>`**. | | `%quests_quest:<quest-id>_p:<placeholder>%` | Returns the **local quest placeholder `<placeholder>`** for the quest **`<quest-id>`**. | | Placeholder | Description | @@ -108,12 +109,12 @@ The eCloud extension called 'Quests' is not for this plugin, do not download it! ### Per-category quest lists -|Placeholder|Description| -|---|---| -|`%quests_category:<category-id>_all_list%`|Returns a **comma-seperated\*\* list** of quest **names** on the server.| -|`%quests_category:<category-id>_completed_list%`|\* Returns a **comma-seperated\*\* list** of quest **names** in the category **`<category-id>`** the player has completed.| -|`%quests_category:<category-id>_completedbefore_list%`|Returns a **comma-seperated\*\* list** of quest **names** in the category **`<category-id>`** the player has completed **at least once**.| -|`%quests_category:<category-id>_started_list%`|Returns a **comma-seperated\*\* list** of quest **names** in the category **`<category-id>`** which are active for the player.| +| Placeholder | Description | +|--------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------| +| `%quests_category:<category-id>_all_list%` | Returns a **comma-seperated\*\* list** of quest **names** on the server. | +| `%quests_category:<category-id>_completed_list%` | \* Returns a **comma-seperated\*\* list** of quest **names** in the category **`<category-id>`** the player has completed. | +| `%quests_category:<category-id>_completedbefore_list%` | Returns a **comma-seperated\*\* list** of quest **names** in the category **`<category-id>`** the player has completed **at least once**. | +| `%quests_category:<category-id>_started_list%` | Returns a **comma-seperated\*\* list** of quest **names** in the category **`<category-id>`** which are active for the player. | ### Per-category quest ID lists |
