diff options
Diffstat (limited to 'common/src/main/java/com')
| -rw-r--r-- | common/src/main/java/com/leonardobishop/quests/common/tasktype/TaskTypeManager.java | 39 |
1 files changed, 23 insertions, 16 deletions
diff --git a/common/src/main/java/com/leonardobishop/quests/common/tasktype/TaskTypeManager.java b/common/src/main/java/com/leonardobishop/quests/common/tasktype/TaskTypeManager.java index e3ee82dc..3461ec6f 100644 --- a/common/src/main/java/com/leonardobishop/quests/common/tasktype/TaskTypeManager.java +++ b/common/src/main/java/com/leonardobishop/quests/common/tasktype/TaskTypeManager.java @@ -14,6 +14,7 @@ import java.util.Map; import java.util.Objects; import java.util.Set; import java.util.function.BooleanSupplier; +import java.util.function.Supplier; /** * The task type manager stores all registered task types and registers individual quests to each task type. @@ -68,28 +69,12 @@ public abstract class TaskTypeManager { * @param taskType the task type to register */ public boolean registerTaskType(@NotNull TaskType taskType) { - return registerTaskType(taskType, new BooleanSupplier[]{}); - } - - /** - * Register a task type with the task type manager. - * - * @param taskType the task type to register - * @param suppliers suppliers to check for task type compatibility - */ - public boolean registerTaskType(@NotNull TaskType taskType, @NotNull BooleanSupplier... suppliers) { Objects.requireNonNull(taskType, "taskType cannot be null"); if (!allowRegistrations) { throw new IllegalStateException("No longer accepting new task types (must be done before quests are loaded)"); } - for (BooleanSupplier supplier : suppliers) { - if (!supplier.getAsBoolean()) { - return false; - } - } - if (exclusions.contains(taskType.getType()) || taskTypes.containsKey(taskType.getType())) { skipped++; return false; @@ -104,6 +89,28 @@ public abstract class TaskTypeManager { } /** + * Register a task type with the task type manager. + * + * @param taskTypeSupplier supplier of the task type to register + * @param compatibilitySuppliers suppliers to check for task type compatibility + */ + public boolean registerTaskType(@NotNull Supplier<TaskType> taskTypeSupplier, @NotNull BooleanSupplier... compatibilitySuppliers) { + Objects.requireNonNull(taskTypeSupplier, "taskTypeSupplier cannot be null"); + + if (!allowRegistrations) { + throw new IllegalStateException("No longer accepting new task types (must be done before quests are loaded)"); + } + + for (BooleanSupplier supplier : compatibilitySuppliers) { + if (!supplier.getAsBoolean()) { + return false; + } + } + + return registerTaskType(taskTypeSupplier.get()); + } + + /** * Register a quest with its task types. This will register the quest to each task type it contains. * * @param quest the quest to register |
