mirror of
https://github.com/KAMKEEL/CustomNPC-Plus-API.git
synced 2026-11-16 23:25:08 +00:00
Added termination task to ConditionalActions
(code that runs when task termination predicate is satisfied)
This commit is contained in:
1 parent
0bbb00f1e1
commit
06d73d7f11
2 files changed
+93
-15
No files matched your search
@@ -8,7 +8,30 @@ import java.util.function.Supplier;
|
||||
public interface IConditionalAction extends IAction {
|
||||
|
||||
/**
|
||||
*
|
||||
* @param predicate supplier checked every tick, if it returns true, task is fired
|
||||
* @return
|
||||
*/
|
||||
IConditionalAction setPredicate(Supplier<Boolean> predicate);
|
||||
|
||||
/**
|
||||
* @param terminateWhen supplier checked every tick, if it returns true, action is terminated (gets marked done)
|
||||
* @return this action
|
||||
*/
|
||||
IConditionalAction setTerminationPredicate(Supplier<Boolean> terminateWhen);
|
||||
|
||||
/**
|
||||
* @param onTermination code to run when the termination predicate returns true
|
||||
* @return this action
|
||||
*/
|
||||
IConditionalAction setTerminationTask(Consumer<IAction> onTermination);
|
||||
|
||||
/**
|
||||
* @return true if predicate 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();
|
||||
|
||||
/**
|
||||
* @param maxChecks maximum times to test predicate before auto‐cancelling
|
||||
* @return this action
|
||||
*/
|
||||
@@ -23,4 +46,8 @@ public interface IConditionalAction extends IAction {
|
||||
IConditionalAction after(Supplier<Boolean> predicate, Supplier<Boolean> terminate, Consumer<IAction> task);
|
||||
|
||||
IConditionalAction after(String name, Supplier<Boolean> predicate, Supplier<Boolean> terminate, Consumer<IAction> task);
|
||||
|
||||
IConditionalAction after(Supplier<Boolean> predicate, Supplier<Boolean> terminateWhen, Consumer<IAction> onTermination, Consumer<IAction> task);
|
||||
|
||||
IConditionalAction after(String name, Supplier<Boolean> predicate, Supplier<Boolean> terminateWhen, Consumer<IAction> onTermination, Consumer<IAction> task);
|
||||
}
|
||||
Reference in new issue
Block a user