Class StructureAnimationRequestBuilder

java.lang.Object
nl.pim16aap2.animatedarchitecture.core.structures.StructureAnimationRequestBuilder

public class StructureAnimationRequestBuilder extends Object
Builder for StructureAnimationRequest instances implemented as a guided builder.

You can obtain an instance of this class using IAnimatedArchitecturePlatform.getStructureAnimationRequestBuilder().

Example usage:


 structureAnimationRequestBuilder
     .builder()
     .structure(structure) // Structures or their retrievers both work
     .structureActionCause(StructureActionCause.PLUGIN)
     .structureActionType(StructureActionType.TOGGLE)
     .responsible(player)
     .messageReceiver(player)
     .build()
     .execute()
     .thenAccept(structureToggleResult -> ...)
     .exceptionally(throwable -> ...);
 

The builder is implemented as a guided builder, which means that you can only call methods in a specific order until all required data is available. After that, there are additional options to specify optional data, such as the time the animation should take or the animation type.

One thing to note is that when the animation cause is set to StructureActionCause.PLAYER, the request requires the responsible player to be set using the otherwise-optional StructureAnimationRequestBuilder.IBuilder.responsible(IPlayer) method.

Even when providing a responsible player, the builder allows you to specify a message receiver. This is useful when a player is responsible for the animation, but any messages should be sent elsewhere. For example, you can ensure all messages are only sent to the server console by using StructureAnimationRequestBuilder.IBuilder.messageReceiverServer().