diff options
| author | LMBishop <13875753+LMBishop@users.noreply.github.com> | 2023-08-07 19:25:35 +0100 |
|---|---|---|
| committer | LMBishop <13875753+LMBishop@users.noreply.github.com> | 2023-08-07 19:25:35 +0100 |
| commit | 86a365d4984ae8d5131d59eb993c471e44509dfb (patch) | |
| tree | fa7d23529884bbab7fe87abfac33077c5a3b2771 /bukkit/src | |
| parent | 0f5ccf8a0b7cf7e7e7ff999321af0ed7f08c3936 (diff) | |
Add allow negative progress option to mining task
Closes #530
Diffstat (limited to 'bukkit/src')
| -rw-r--r-- | bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/MiningTaskType.java | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/MiningTaskType.java b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/MiningTaskType.java index 18dab791..aadd5209 100644 --- a/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/MiningTaskType.java +++ b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/MiningTaskType.java @@ -35,6 +35,7 @@ public final class MiningTaskType extends BukkitTaskType { 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")); } @@ -171,6 +172,13 @@ public final class MiningTaskType extends BukkitTaskType { 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()); } |
