From 581cf4268b0af6a1e6cbb60ccac343cfced8ca13 Mon Sep 17 00:00:00 2001 From: bigguy345 Date: Sun, 27 Apr 2025 07:33:50 +0300 Subject: [PATCH] Added terminateWhen predicate for ConditionalAction --- java/noppes/npcs/api/handler/IActionManager.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/java/noppes/npcs/api/handler/IActionManager.java b/java/noppes/npcs/api/handler/IActionManager.java index 7da42c2..7b01079 100644 --- a/java/noppes/npcs/api/handler/IActionManager.java +++ b/java/noppes/npcs/api/handler/IActionManager.java @@ -103,6 +103,18 @@ public interface IActionManager { */ void scheduleConditionalAction(String name, int checkIntervalTicks, Supplier predicate, Consumer task, int maxChecks); + /** + * Schedule a conditional action that gives up after at most maxChecks attempts. + * + * @param name unique name + * @param checkIntervalTicks ticks between predicate tests + * @param predicate supplier returning true when it should fire + * @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 + */ + void scheduleConditionalAction(String name, int checkIntervalTicks, Supplier predicate, Supplier terminateWhen, Consumer task, int maxChecks); + /** * Cancel (remove) the first queued action with the given name. *