From 7e8328da0a4c4eae394057fdfe35775cdcab4304 Mon Sep 17 00:00:00 2001 From: Krakenied Date: Fri, 26 May 2023 22:45:29 +0200 Subject: Add exact match option to brewing task type --- .../quests/bukkit/tasktype/type/BrewingTaskType.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'bukkit/src') diff --git a/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/BrewingTaskType.java b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/BrewingTaskType.java index ce4fcfde..7c3dcd8e 100644 --- a/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/BrewingTaskType.java +++ b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/BrewingTaskType.java @@ -40,6 +40,7 @@ public final class BrewingTaskType extends BukkitTaskType { super.addConfigValidator(TaskUtils.useIntegerConfigValidator(this, "amount")); super.addConfigValidator(TaskUtils.useItemStackConfigValidator(this, "ingredient")); super.addConfigValidator(TaskUtils.useIntegerConfigValidator(this, "data")); + super.addConfigValidator(TaskUtils.useBooleanConfigValidator(this, "exact-match")); } @Override @@ -105,18 +106,19 @@ public final class BrewingTaskType extends BukkitTaskType { super.debug("Player brewed " + eventAmount + " potions" + (ingredient != null ? " using " + ingredient.getType() : ""), quest.getId(), task.getId(), player.getUniqueId()); - if (!qi.compareItemStack(ingredient)) { + boolean exactMatch = TaskUtils.getConfigBoolean(task, "exact-match", true); + if (!qi.compareItemStack(ingredient, exactMatch)) { super.debug("Ingredient 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); @@ -124,5 +126,4 @@ public final class BrewingTaskType extends BukkitTaskType { } } } - } -- cgit v1.2.3-70-g09d2