From a98fad73f94314f7d7a50dccac0d4bb06e5a3335 Mon Sep 17 00:00:00 2001 From: bigguy345 Date: Mon, 28 Apr 2025 06:47:33 +0300 Subject: [PATCH] made schedule methods return IAction --- .../npcs/api/handler/IActionManager.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/java/noppes/npcs/api/handler/IActionManager.java b/java/noppes/npcs/api/handler/IActionManager.java index c7690d8..609f589 100644 --- a/java/noppes/npcs/api/handler/IActionManager.java +++ b/java/noppes/npcs/api/handler/IActionManager.java @@ -39,8 +39,9 @@ public interface IActionManager { * Schedule an existing action for execution. * * @param action the action to enqueue + * @return the action scheduled */ - void scheduleAction(IAction action); + IAction scheduleAction(IAction action); /** * Convenience for {@link #create(String, int, int, Consumer)} + enqueue. @@ -49,16 +50,18 @@ public interface IActionManager { * @param maxDuration the maximum lifetime of the action in ticks * @param startAfterTicks number of ticks to wait before the first run * @param action logic to execute each time the action “fires” + * @return the action scheduled */ - void scheduleAction(String name, int maxDuration, int startAfterTicks, Consumer action); + IAction scheduleAction(String name, int maxDuration, int startAfterTicks, Consumer action); /** * Insert an action at a specific position in the queue. * * @param index zero-based queue position to insert at * @param action the action to insert + * @return the action scheduled */ - void scheduleActionAt(int index, IAction action); + IAction scheduleActionAt(int index, IAction action); /** * Get the zero-based position of an action in the queue. @@ -90,8 +93,9 @@ public interface IActionManager { * @param checkIntervalTicks number of ticks between each predicate check * @param predicate no-arg boolean supplier deciding when to fire * @param action logic to execute once when predicate first becomes true + * @return the action scheduled */ - void scheduleConditionalAction(String name, int checkIntervalTicks, Supplier predicate, Consumer action); + IAction scheduleConditionalAction(String name, int checkIntervalTicks, Supplier predicate, Consumer action); /** * Schedule a conditional action that gives up after at most maxChecks attempts. @@ -101,8 +105,9 @@ public interface IActionManager { * @param predicate supplier returning true when it should fire * @param task logic to run once when predicate first becomes true * @param maxChecks maximum times to test predicate before auto‐cancelling + * @return the action scheduled */ - void scheduleConditionalAction(String name, int checkIntervalTicks, Supplier predicate, Consumer task, int maxChecks); + IAction scheduleConditionalAction(String name, int checkIntervalTicks, Supplier predicate, Consumer task, int maxChecks); /** * Schedule a conditional action that gives up after at most maxChecks attempts. @@ -113,8 +118,9 @@ public interface IActionManager { * @param terminateWhen supplier returning true when it should terminate (gets marked done) * @param task logic to run once when predicate first becomes true * @param maxChecks maximum times to test predicate before auto‐cancelling + * @return the action scheduled */ - void scheduleConditionalAction(String name, int checkIntervalTicks, Supplier predicate, Supplier terminateWhen, Consumer task, int maxChecks); + IAction scheduleConditionalAction(String name, int checkIntervalTicks, Supplier predicate, Supplier terminateWhen, Consumer task, int maxChecks); /** * Cancel (remove) the first queued action with the given name.