From a588062c987da70064abae05f5f7c9b6536dd227 Mon Sep 17 00:00:00 2001 From: bigguy345 Date: Wed, 2 Jul 2025 11:50:59 +0300 Subject: [PATCH] Added varargs chaining to IActions i.e schedule(act1,act2,act3...) --- .../npcs/api/handler/IActionManager.java | 34 +++++++++++++++++++ .../noppes/npcs/api/handler/data/IAction.java | 22 ++++++++++++ 2 files changed, 56 insertions(+) diff --git a/java/noppes/npcs/api/handler/IActionManager.java b/java/noppes/npcs/api/handler/IActionManager.java index b8e550d..80963ce 100644 --- a/java/noppes/npcs/api/handler/IActionManager.java +++ b/java/noppes/npcs/api/handler/IActionManager.java @@ -113,6 +113,14 @@ public interface IActionManager { */ void stop(); + /** + * Multiple actions chained one after another + * i.e schedule(act1,act2,act3,...) + * + * @param actions + */ + void schedule(IAction... actions); + /** * Schedule an existing action for execution. * @@ -121,6 +129,14 @@ public interface IActionManager { */ IAction schedule(IAction action); + /** + * Multiple tasks chained one after another + * i.e schedule(task1,task2,task3,...) + * + * @param tasks + */ + void schedule(Consumer... tasks); + /** * Convenience for {@link #create(Consumer)} + enqueue. * @@ -274,6 +290,14 @@ public interface IActionManager { */ IConditionalAction schedule(String name, Function condition, Consumer task, Function terminateWhen, Consumer onTermination); + /** + * Multiple conditionals + * i.e schedule(act1,act2,act3,...) + * + * @param actions + */ + void schedule(IConditionalAction... actions); + IConditionalAction schedule(IConditionalAction action); /** @@ -313,6 +337,14 @@ public interface IActionManager { */ boolean hasConditional(String name); + /** + * Multiple actions in parallel + * i.e scheduleParallel(act1,act2,act3,...) + * + * @param actions + */ + void scheduleParallel(IAction... actions); + /** * Schedules actions on the parallelQueue, where all actions are executed simultaneously * @@ -322,6 +354,8 @@ public interface IActionManager { IAction scheduleParallel(IAction action); + void scheduleParallel(Consumer... tasks); + IAction scheduleParallel(Consumer task); IAction scheduleParallel(int delay, Consumer task); diff --git a/java/noppes/npcs/api/handler/data/IAction.java b/java/noppes/npcs/api/handler/data/IAction.java index 9052f7d..c14c039 100644 --- a/java/noppes/npcs/api/handler/data/IAction.java +++ b/java/noppes/npcs/api/handler/data/IAction.java @@ -197,6 +197,22 @@ public interface IAction { */ IAction after(IAction after); + /** + * Multiple actions chained one after another + * i.e after(act1,act2,act3,...) + * + * @param actions + */ + void after(IAction... actions); + + /** + * Multiple tasks chained one after another + * i.e after(task1,task2,task3,...) + * + * @param tasks + */ + void after(Consumer... tasks); + IAction after(String name, int maxDuration, int delay, Consumer t); IAction after(String name, int delay, Consumer t); @@ -231,6 +247,8 @@ public interface IAction { */ IConditionalAction conditional(IConditionalAction after); + void conditional(IConditionalAction... actions); + IConditionalAction conditional(Function condition, Consumer task); IConditionalAction conditional(String name, Function condition, Consumer task); @@ -250,8 +268,12 @@ public interface IAction { */ IAction parallel(IAction after); + void parallel(IAction... actions); + IAction parallel(Consumer task); + void parallel(Consumer... tasks); + IAction parallel(int delay, Consumer task); IAction parallel(String name, Consumer task);