package noppes.npcs.api.handler.data.actions; import noppes.npcs.api.handler.data.IAction; import java.util.function.Consumer; import java.util.function.Supplier; public interface IConditionalAction extends IAction { /** * @param condition supplier checked every tick, if it returns true, task is fired * @return */ IConditionalAction setCondition(Supplier condition); /** * @param terminateWhen supplier checked every tick, if it returns true, action is terminated (gets marked done) * @return this action */ IConditionalAction terminateWhen(Supplier terminateWhen); /** * @param onTermination code to run when the termination condition returns true * @return this action */ IConditionalAction onTermination(Consumer onTermination); /** * @return true if condition was satisfied and task ran (i.e can be called in termination task to see if original task was executed * then do code based on that, if not return early) */ boolean wasTaskExecuted(); /** * Note: Only for Conditional Actions * @return how many times this conditional action has tested its condition */ int getCheckCount(); /** * Note: Only for Conditional Actions * @return the maximum number of checks before auto‐expiring, or –1 if unlimited */ int getMaxChecks(); /** * @param maxChecks maximum times to test condition before auto‐cancelling * @return this action */ IConditionalAction setMaxChecks(int maxChecks); IConditionalAction after(IConditionalAction after); IConditionalAction after(Supplier condition, Consumer task); IConditionalAction after(String name, Supplier condition, Consumer task); IConditionalAction after(Supplier condition, Consumer task, Supplier terminate); IConditionalAction after(String name, Supplier condition, Consumer task, Supplier terminate); IConditionalAction after(Supplier condition, Consumer task, Supplier terminateWhen, Consumer onTermination); IConditionalAction after(String name, Supplier condition, Consumer task, Supplier terminateWhen, Consumer onTermination); }