From 9aa600d33ef7537b472a552601a3b8204ce8a07d Mon Sep 17 00:00:00 2001 From: Krakenied Date: Wed, 11 Oct 2023 12:09:07 +0200 Subject: Add cancel commands Partially closes https://github.com/LMBishop/Quests/issues/558 --- .../com/leonardobishop/quests/common/quest/Quest.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'common/src') diff --git a/common/src/main/java/com/leonardobishop/quests/common/quest/Quest.java b/common/src/main/java/com/leonardobishop/quests/common/quest/Quest.java index 45dfde96..6af3fcf3 100644 --- a/common/src/main/java/com/leonardobishop/quests/common/quest/Quest.java +++ b/common/src/main/java/com/leonardobishop/quests/common/quest/Quest.java @@ -21,6 +21,7 @@ public class Quest implements Comparable { private List rewardString; private List startString; private List startCommands; + private List cancelCommands; private boolean repeatEnabled; private boolean cooldownEnabled; private int cooldown; @@ -161,6 +162,16 @@ public class Quest implements Comparable { return Collections.unmodifiableList(startCommands); } + /** + * Get the cancel commands for this quest. + * The cancel commands is a list of commands to be executed upon cancelling the quest. + * + * @return immutable list of commands + */ + public List getCancelCommands() { + return Collections.unmodifiableList(cancelCommands); + } + /** * Get if this quest can be repeated after completion. * @@ -294,6 +305,7 @@ public class Quest implements Comparable { private List rewardString = Collections.emptyList(); private List startString = Collections.emptyList(); private List startCommands = Collections.emptyList(); + private List cancelCommands = Collections.emptyList(); private boolean repeatEnabled = false; private boolean cooldownEnabled = false; private int cooldown = 0; @@ -337,6 +349,11 @@ public class Quest implements Comparable { return this; } + public Builder withCancelCommands(List cancelCommands) { + this.cancelCommands = cancelCommands; + return this; + } + public Builder withSortOrder(int sortOrder) { this.sortOrder = sortOrder; return this; @@ -410,6 +427,7 @@ public class Quest implements Comparable { quest.rewardString = this.rewardString; quest.startString = this.startString; quest.startCommands = this.startCommands; + quest.cancelCommands = this.cancelCommands; quest.repeatEnabled = this.repeatEnabled; quest.cooldownEnabled = this.cooldownEnabled; quest.cooldown = this.cooldown; -- cgit v1.2.3-70-g09d2