mirror of
https://github.com/KAMKEEL/CustomNPC-Plus-API.git
synced 2026-11-15 21:54:44 +00:00
Canged all the IConditionalAction Supplier<Boolean> instances (condition,terminateWhen,pauseUntil) to Function<IAction,Boolean>
This commit is contained in:
1 parent
283e3a864d
commit
f998e8feb4
3 files changed
+51
-50
No files matched your search
@@ -7,7 +7,8 @@ import noppes.npcs.api.handler.data.actions.IConditionalAction;
|
||||
import java.util.List;
|
||||
import java.util.Queue;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.function.Function;
|
||||
|
||||
|
||||
/**
|
||||
* Manages a queue of {@link IAction} instances, allowing scheduling of delayed,
|
||||
@@ -41,65 +42,65 @@ public interface IActionManager {
|
||||
/**
|
||||
* Schedule a conditional action that gives up after at most maxChecks attempts.
|
||||
*
|
||||
* @param condition supplier checked every tick, if it returns true, task is fired
|
||||
* @param condition checked every tick, if it returns true, task is fired
|
||||
* @param task code to run once condition first becomes true
|
||||
* @return the action scheduled
|
||||
*/
|
||||
IConditionalAction create(Supplier<Boolean> condition, Consumer<IAction> task);
|
||||
IConditionalAction create(Function<IAction, Boolean> condition, Consumer<IAction> task);
|
||||
|
||||
/**
|
||||
* Schedule a conditional action that gives up after at most maxChecks attempts.
|
||||
*
|
||||
* @param name unique name
|
||||
* @param condition supplier checked every tick, if it returns true, task is fired
|
||||
* @param condition checked every tick, if it returns true, task is fired
|
||||
* @param task code to run once condition first becomes true
|
||||
* @return the action scheduled
|
||||
*/
|
||||
IConditionalAction create(String name, Supplier<Boolean> condition, Consumer<IAction> task);
|
||||
IConditionalAction create(String name, Function<IAction, Boolean> condition, Consumer<IAction> task);
|
||||
|
||||
/**
|
||||
* Schedule a conditional action that gives up after at most maxChecks attempts.
|
||||
*
|
||||
* @param condition supplier checked every tick, if it returns true, task is fired
|
||||
* @param condition checked every tick, if it returns true, task is fired
|
||||
* @param task code to run once condition first becomes true
|
||||
* @param terminateWhen supplier checked every tick, if it returns true, action is terminated (gets marked done)
|
||||
* @param terminateWhen checked every tick, if it returns true, action is terminated (gets marked done)
|
||||
* @return the action scheduled
|
||||
*/
|
||||
IConditionalAction create(Supplier<Boolean> condition, Consumer<IAction> task, Supplier<Boolean> terminateWhen);
|
||||
IConditionalAction create(Function<IAction, Boolean> condition, Consumer<IAction> task, Function<IAction, Boolean> terminateWhen);
|
||||
|
||||
/**
|
||||
* Schedule a conditional action that gives up after at most maxChecks attempts.
|
||||
*
|
||||
* @param name unique name
|
||||
* @param condition supplier checked every tick, if it returns true, task is fired
|
||||
* @param condition checked every tick, if it returns true, task is fired
|
||||
* @param task code to run once condition first becomes true
|
||||
* @param terminateWhen supplier checked every tick, if it returns true, action is terminated (gets marked done)
|
||||
* @param terminateWhen checked every tick, if it returns true, action is terminated (gets marked done)
|
||||
* @return the action scheduled
|
||||
*/
|
||||
IConditionalAction create(String name, Supplier<Boolean> condition, Consumer<IAction> task, Supplier<Boolean> terminateWhen);
|
||||
IConditionalAction create(String name, Function<IAction, Boolean> condition, Consumer<IAction> task, Function<IAction, Boolean> terminateWhen);
|
||||
|
||||
/**
|
||||
* Schedule a conditional action that gives up after at most maxChecks attempts.
|
||||
*
|
||||
* @param condition supplier checked every tick, if it returns true, task is fired
|
||||
* @param condition checked every tick, if it returns true, task is fired
|
||||
* @param task code to run once condition first becomes true
|
||||
* @param terminateWhen supplier checked every tick, if it returns true, action is terminated (gets marked done)
|
||||
* @param terminateWhen checked every tick, if it returns true, action is terminated (gets marked done)
|
||||
* @param onTermination code to run when the termination condition returns true
|
||||
* @return the action scheduled
|
||||
*/
|
||||
IConditionalAction create(Supplier<Boolean> condition, Consumer<IAction> task, Supplier<Boolean> terminateWhen, Consumer<IAction> onTermination);
|
||||
IConditionalAction create(Function<IAction, Boolean> condition, Consumer<IAction> task, Function<IAction, Boolean> terminateWhen, Consumer<IAction> onTermination);
|
||||
|
||||
/**
|
||||
* Schedule a conditional action that gives up after at most maxChecks attempts.
|
||||
*
|
||||
* @param name unique name
|
||||
* @param condition supplier checked every tick, if it returns true, task is fired
|
||||
* @param condition checked every tick, if it returns true, task is fired
|
||||
* @param task code to run once condition first becomes true
|
||||
* @param terminateWhen supplier checked every tick, if it returns true, action is terminated (gets marked done)
|
||||
* @param terminateWhen checked every tick, if it returns true, action is terminated (gets marked done)
|
||||
* @param onTermination code to run when the termination condition returns true
|
||||
* @return the action scheduled
|
||||
*/
|
||||
IConditionalAction create(String name, Supplier<Boolean> condition, Consumer<IAction> task, Supplier<Boolean> terminateWhen, Consumer<IAction> onTermination);
|
||||
IConditionalAction create(String name, Function<IAction, Boolean> condition, Consumer<IAction> task, Function<IAction, Boolean> terminateWhen, Consumer<IAction> onTermination);
|
||||
|
||||
/**
|
||||
* Begin processing scheduled actions. Must be called once.
|
||||
@@ -213,65 +214,65 @@ public interface IActionManager {
|
||||
/**
|
||||
* Schedule a conditional action that gives up after at most maxChecks attempts.
|
||||
*
|
||||
* @param condition supplier checked every tick, if it returns true, task is fired
|
||||
* @param condition checked every tick, if it returns true, task is fired
|
||||
* @param task code to run once condition first becomes true
|
||||
* @return the action scheduled
|
||||
*/
|
||||
IConditionalAction scheduleAction(Supplier<Boolean> condition, Consumer<IAction> task);
|
||||
IConditionalAction scheduleAction(Function<IAction, Boolean> condition, Consumer<IAction> task);
|
||||
|
||||
/**
|
||||
* Schedule a conditional action that gives up after at most maxChecks attempts.
|
||||
*
|
||||
* @param condition supplier checked every tick, if it returns true, task is fired
|
||||
* @param condition checked every tick, if it returns true, task is fired
|
||||
* @param task code to run once condition first becomes true
|
||||
* @param terminateWhen supplier checked every tick, if it returns true, action is terminated (gets marked done)
|
||||
* @param terminateWhen checked every tick, if it returns true, action is terminated (gets marked done)
|
||||
* @return the action scheduled
|
||||
*/
|
||||
IConditionalAction scheduleAction(Supplier<Boolean> condition, Consumer<IAction> task, Supplier<Boolean> terminateWhen);
|
||||
IConditionalAction scheduleAction(Function<IAction, Boolean> condition, Consumer<IAction> task, Function<IAction, Boolean> terminateWhen);
|
||||
|
||||
/**
|
||||
* Schedule a conditional action that gives up after at most maxChecks attempts.
|
||||
*
|
||||
* @param condition supplier checked every tick, if it returns true, task is fired
|
||||
* @param condition checked every tick, if it returns true, task is fired
|
||||
* @param task code to run once condition first becomes true
|
||||
* @param terminateWhen supplier checked every tick, if it returns true, action is terminated (gets marked done)
|
||||
* @param terminateWhen checked every tick, if it returns true, action is terminated (gets marked done)
|
||||
* @param onTermination code to run when the termination condition returns true
|
||||
* @return the action scheduled
|
||||
*/
|
||||
IConditionalAction scheduleAction(Supplier<Boolean> condition, Consumer<IAction> task, Supplier<Boolean> terminateWhen, Consumer<IAction> onTermination);
|
||||
IConditionalAction scheduleAction(Function<IAction, Boolean> condition, Consumer<IAction> task, Function<IAction, Boolean> terminateWhen, Consumer<IAction> onTermination);
|
||||
|
||||
/**
|
||||
* Schedule a conditional action that gives up after at most maxChecks attempts.
|
||||
*
|
||||
* @param name unique name
|
||||
* @param condition supplier checked every tick, if it returns true, task is fired
|
||||
* @param condition checked every tick, if it returns true, task is fired
|
||||
* @param task code to run once condition first becomes true
|
||||
* @return the action scheduled
|
||||
*/
|
||||
IConditionalAction scheduleAction(String name, Supplier<Boolean> condition, Consumer<IAction> task);
|
||||
IConditionalAction scheduleAction(String name, Function<IAction, Boolean> condition, Consumer<IAction> task);
|
||||
|
||||
/**
|
||||
* Schedule a conditional action that gives up after at most maxChecks attempts.
|
||||
*
|
||||
* @param name unique name
|
||||
* @param condition supplier checked every tick, if it returns true, task is fired
|
||||
* @param condition checked every tick, if it returns true, task is fired
|
||||
* @param task code to run once condition first becomes true
|
||||
* @param terminateWhen supplier checked every tick, if it returns true, action is terminated (gets marked done)
|
||||
* @param terminateWhen checked every tick, if it returns true, action is terminated (gets marked done)
|
||||
* @return the action scheduled
|
||||
*/
|
||||
IConditionalAction scheduleAction(String name, Supplier<Boolean> condition, Consumer<IAction> task, Supplier<Boolean> terminateWhen);
|
||||
IConditionalAction scheduleAction(String name, Function<IAction, Boolean> condition, Consumer<IAction> task, Function<IAction, Boolean> terminateWhen);
|
||||
|
||||
/**
|
||||
* Schedule a conditional action that gives up after at most maxChecks attempts.
|
||||
*
|
||||
* @param name unique name
|
||||
* @param condition supplier checked every tick, if it returns true, task is fired
|
||||
* @param condition checked every tick, if it returns true, task is fired
|
||||
* @param task code to run once condition first becomes true
|
||||
* @param terminateWhen supplier checked every tick, if it returns true, action is terminated (gets marked done)
|
||||
* @param terminateWhen checked every tick, if it returns true, action is terminated (gets marked done)
|
||||
* @param onTermination code to run when the termination condition returns true
|
||||
* @return the action scheduled
|
||||
*/
|
||||
IConditionalAction scheduleAction(String name, Supplier<Boolean> condition, Consumer<IAction> task, Supplier<Boolean> terminateWhen, Consumer<IAction> onTermination);
|
||||
IConditionalAction scheduleAction(String name, Function<IAction, Boolean> condition, Consumer<IAction> task, Function<IAction, Boolean> terminateWhen, Consumer<IAction> onTermination);
|
||||
|
||||
IConditionalAction scheduleAction(IConditionalAction action);
|
||||
|
||||
@@ -342,14 +343,14 @@ public interface IActionManager {
|
||||
/**
|
||||
* Convenience: create & enqueue a conditional task that re-checks forever.
|
||||
*/
|
||||
default IConditionalAction addConditionalTask(String name, Supplier<Boolean> condition, Consumer<IAction> task) {
|
||||
default IConditionalAction addConditionalTask(String name, Function<IAction, Boolean> condition, Consumer<IAction> task) {
|
||||
return scheduleAction(name, condition, task);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience: create & enqueue a conditional task that gives up after maxChecks.
|
||||
*/
|
||||
default IConditionalAction addConditionalTask(String name, Supplier<Boolean> condition, Consumer<IAction> task, Supplier<Boolean> terminateWhen) {
|
||||
default IConditionalAction addConditionalTask(String name, Function<IAction, Boolean> condition, Consumer<IAction> task, Function<IAction, Boolean> terminateWhen) {
|
||||
return scheduleAction(name, condition, task, terminateWhen);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user