diff --git a/java/noppes/npcs/api/handler/IActionManager.java b/java/noppes/npcs/api/handler/IActionManager.java index f9e2399..d636689 100644 --- a/java/noppes/npcs/api/handler/IActionManager.java +++ b/java/noppes/npcs/api/handler/IActionManager.java @@ -118,16 +118,35 @@ public interface IActionManager { */ IAction scheduleAction(IAction action); + /** + * Convenience for {@link #create(String, Consumer)} + enqueue. + * + * @param name a unique name for this action + * @param task code to execute each time the task "fires" + * @return the task scheduled + */ + IAction scheduleAction(String name, Consumer task); + + /** + * Convenience for {@link #create(String, int, Consumer)} + enqueue. + * + * @param name a unique name for this action + * @param startAfterTicks number of ticks to wait before the first task run + * @param task code to execute each time the task "fires" + * @return the task scheduled + */ + IAction scheduleAction(String name, int startAfterTicks, Consumer task); + /** * Convenience for {@link #create(String, int, int, Consumer)} + enqueue. * * @param name a unique name for this action * @param maxDuration the maximum lifetime of the action in ticks - * @param startAfterTicks number of ticks to wait before the first run - * @param action code to execute each time the action "fires" - * @return the action scheduled + * @param startAfterTicks number of ticks to wait before the first task run + * @param task code to execute each time the task "fires" + * @return the task scheduled */ - IAction scheduleAction(String name, int maxDuration, int startAfterTicks, Consumer action); + IAction scheduleAction(String name, int maxDuration, int startAfterTicks, Consumer task); /** * Insert an action at a specific position in the queue. diff --git a/java/noppes/npcs/api/handler/data/IAction.java b/java/noppes/npcs/api/handler/data/IAction.java index 35d0394..5d645b1 100644 --- a/java/noppes/npcs/api/handler/data/IAction.java +++ b/java/noppes/npcs/api/handler/data/IAction.java @@ -77,7 +77,8 @@ public interface IAction { boolean hasData(String key); /** - * @return how many ticks between each invocation of the action callback + * @return how many ticks between each execution of the action's task + * Default is 5 ticks (4 times per second) */ int getUpdateEveryXTick(); @@ -117,11 +118,13 @@ public interface IAction { /** * Resumes thread that was previously paused by {@link #pause()}, {@link #pauseUntil(Supplier)}, {@link #pauseFor(int)} or {@link #pauseFor(long)} + * Must be called from a different thread than the IAction one, as that one is paused, so it won't reach this function if it comes after any of the pausing functions. */ void resume(); /** * @return checks if IAction's getStartAfterTicks > 0, or if IAction's thread is paused if threaded + * Preferably called from a different thread than the IAction one if it's paused. */ boolean isPaused(); @@ -130,6 +133,12 @@ public interface IAction { */ IAction threadify(); + /** + * + * @return starts the IActionManager + */ + IAction start(); + /** * @return the next action in the queue (or null if none or at end) */