aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLMBishop <13875753+LMBishop@users.noreply.github.com>2023-08-07 19:25:35 +0100
committerLMBishop <13875753+LMBishop@users.noreply.github.com>2023-08-07 19:25:35 +0100
commit86a365d4984ae8d5131d59eb993c471e44509dfb (patch)
treefa7d23529884bbab7fe87abfac33077c5a3b2771
parent0f5ccf8a0b7cf7e7e7ff999321af0ed7f08c3936 (diff)
Add allow negative progress option to mining task
Closes #530
-rw-r--r--bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/MiningTaskType.java8
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());
}