Skip to content

Commit

Permalink
Add exact match option to crafting task type
Browse files Browse the repository at this point in the history
  • Loading branch information
Krakenied committed May 26, 2023
1 parent ada3f9a commit 5b587a8
Showing 1 changed file with 5 additions and 3 deletions.
Expand Up @@ -33,6 +33,7 @@ public CraftingTaskType(BukkitQuestsPlugin plugin) {
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
Expand Down Expand Up @@ -94,17 +95,18 @@ public void onCraftItem(CraftItemEvent event) {

super.debug("Player crafted " + 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);
Expand Down

0 comments on commit 5b587a8

Please sign in to comment.