Skip to content

Commit

Permalink
Add allow negative progress option to mining task
Browse files Browse the repository at this point in the history
Closes #530
  • Loading branch information
LMBishop committed Aug 7, 2023
1 parent 0f5ccf8 commit 86a365d
Showing 1 changed file with 8 additions and 0 deletions.
Expand Up @@ -35,6 +35,7 @@ public MiningTaskType(BukkitQuestsPlugin plugin) {
super.addConfigValidator(TaskUtils.useBooleanConfigValidator(this, "check-coreprotect"));
super.addConfigValidator(TaskUtils.useIntegerConfigValidator(this, "check-coreprotect-time"));
super.addConfigValidator(TaskUtils.useBooleanConfigValidator(this, "reverse-if-placed"));
super.addConfigValidator(TaskUtils.useBooleanConfigValidator(this, "allow-negative-progress"));
super.addConfigValidator(TaskUtils.useBooleanConfigValidator(this, "allow-silk-touch"));
}

Expand Down Expand Up @@ -171,6 +172,13 @@ public void onBlockPlace(BlockPlaceEvent event) {
continue;
}

boolean allowNegativeProgress = TaskUtils.getConfigBoolean(task, "allow-negative-progress", true);
int currentProgress = TaskUtils.getIntegerTaskProgress(taskProgress);
if (currentProgress <= 0 && !allowNegativeProgress) {
super.debug("Task progress is already at zero and negative progress is disabled, skipping decrement", quest.getId(), task.getId(), player.getUniqueId());
continue;
}

int progress = TaskUtils.decrementIntegerTaskProgress(taskProgress);
super.debug("Decrementing task progress (now " + progress + ")", quest.getId(), task.getId(), player.getUniqueId());
}
Expand Down

0 comments on commit 86a365d

Please sign in to comment.