From d9d2ed48e57b0cd6792ec9a669d989b91e1f131b Mon Sep 17 00:00:00 2001 From: Krakenied Date: Fri, 26 May 2023 22:49:59 +0200 Subject: Add exact match option to smithing task type --- .../quests/bukkit/tasktype/type/SmithingTaskType.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'bukkit/src') diff --git a/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/SmithingTaskType.java b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/SmithingTaskType.java index 70f97d17..55acba16 100644 --- a/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/SmithingTaskType.java +++ b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/SmithingTaskType.java @@ -33,6 +33,7 @@ public final class SmithingTaskType extends BukkitTaskType { super.addConfigValidator(TaskUtils.useRequiredConfigValidator(this, "item")); super.addConfigValidator(TaskUtils.useItemStackConfigValidator(this, "item")); super.addConfigValidator(TaskUtils.useIntegerConfigValidator(this, "data")); + super.addConfigValidator(TaskUtils.useBooleanConfigValidator(this, "exact-match")); } @Override @@ -85,17 +86,18 @@ public final class SmithingTaskType extends BukkitTaskType { super.debug("Player smithed " + eventAmount + " of " + item.getType(), quest.getId(), task.getId(), player.getUniqueId()); - if (!qi.compareItemStack(item)) { + boolean exactMatch = TaskUtils.getConfigBoolean(task, "exact-match", true); + if (!qi.compareItemStack(item, exactMatch)) { super.debug("Item does not match, continuing...", quest.getId(), task.getId(), player.getUniqueId()); continue; } - int amount = (int) task.getConfigValue("amount"); - int progress = TaskUtils.getIntegerTaskProgress(taskProgress); taskProgress.setProgress(progress + eventAmount); super.debug("Updating task progress (now " + (progress + eventAmount) + ")", quest.getId(), task.getId(), player.getUniqueId()); + int amount = (int) task.getConfigValue("amount"); + if ((int) taskProgress.getProgress() >= amount) { super.debug("Marking task as complete", quest.getId(), task.getId(), player.getUniqueId()); taskProgress.setProgress(amount); -- cgit v1.2.3-70-g09d2