Interface AsyncActionHandler
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
What an action does, answering when its future completes: work on the thread of an entity or a
region (
ActionContext.entity(Entity, Supplier), ActionContext.region(Location, Supplier)), a database, a web service.
extension.asyncAction("heal", context -> {
Player player = context.player("player");
if (player == null) {
return CompletableFuture.completedFuture(Result.error("Not online"));
}
return context.entity(player, () -> {
player.setHealth(player.getAttribute(Attribute.MAX_HEALTH).getValue());
return Result.ok(player.getName() + " healed");
});
});
-
Method Summary
-
Method Details
-
handle
Starts the action. Its future has 30 seconds to complete.- Parameters:
context- who runs it, and the values that came with it- Returns:
- what the dashboard says and does next, when it is known
- Throws:
Exception- anything: the dashboard then says the action failed, and the console shows why
-