Class AsyncStructureGenerateEvent

java.lang.Object
org.bukkit.event.Event
org.bukkit.event.world.WorldEvent
org.bukkit.event.world.AsyncStructureGenerateEvent

@Experimental public class AsyncStructureGenerateEvent extends WorldEvent
This event will sometimes fire synchronously, depending on how it was triggered.

The constructor provides a boolean to indicate if the event was fired synchronously or asynchronously. When asynchronous, this event can be called from any thread, sans the main thread, and has limited access to the API.

If a Structure is naturally placed in a chunk of the world, this event will be asynchronous. If a player executes the '/place structure' command, this event will be synchronous. Allows to register transformers that can modify the blocks placed and entities spawned by the structure.

Care should be taken to check Event.isAsynchronous() and treat the event appropriately.

  • Constructor Details

  • Method Details

    • getCause

      @NotNull public AsyncStructureGenerateEvent.Cause getCause()
      Gets the event cause.
      Returns:
      the event cause
    • getBlockTransformer

      @Nullable public BlockTransformer getBlockTransformer(@NotNull NamespacedKey key)
      Gets a block transformer by key.
      Parameters:
      key - the key of the block transformer
      Returns:
      the block transformer or null
    • setBlockTransformer

      public void setBlockTransformer(@NotNull NamespacedKey key, @NotNull BlockTransformer transformer)
      Sets a block transformer to a key.
      Parameters:
      key - the key
      transformer - the block transformer
    • removeBlockTransformer

      public void removeBlockTransformer(@NotNull NamespacedKey key)
      Removes a block transformer.
      Parameters:
      key - the key of the block transformer
    • clearBlockTransformers

      public void clearBlockTransformers()
      Removes all block transformers.
    • getBlockTransformers

      @NotNull public Map<NamespacedKey,BlockTransformer> getBlockTransformers()
      Gets all block transformers in a unmodifiable map.
      Returns:
      the block transformers in a map
    • getEntityTransformer

      @Nullable public EntityTransformer getEntityTransformer(@NotNull NamespacedKey key)
      Gets a entity transformer by key.
      Parameters:
      key - the key of the entity transformer
      Returns:
      the entity transformer or null
    • setEntityTransformer

      public void setEntityTransformer(@NotNull NamespacedKey key, @NotNull EntityTransformer transformer)
      Sets a entity transformer to a key.
      Parameters:
      key - the key
      transformer - the entity transformer
    • removeEntityTransformer

      public void removeEntityTransformer(@NotNull NamespacedKey key)
      Removes a entity transformer.
      Parameters:
      key - the key of the entity transformer
    • clearEntityTransformers

      public void clearEntityTransformers()
      Removes all entity transformers.
    • getEntityTransformers

      @NotNull public Map<NamespacedKey,EntityTransformer> getEntityTransformers()
      Gets all entity transformers in a unmodifiable map.
      Returns:
      the entity transformers in a map
    • getStructure

      @NotNull public Structure getStructure()
      Get the structure reference that is generated.
      Returns:
      the structure
    • getBoundingBox

      @NotNull public BoundingBox getBoundingBox()
      Get the bounding box of the structure.
      Returns:
      the bounding box
    • getChunkX

      public int getChunkX()
      Get the x coordinate of the origin chunk of the structure.
      Returns:
      the chunk x coordinate
    • getChunkZ

      public int getChunkZ()
      Get the z coordinate of the origin chunk of the structure.
      Returns:
      the chunk z coordinate
    • getHandlers

      @NotNull public HandlerList getHandlers()
      Specified by:
      getHandlers in class Event
    • getHandlerList

      @NotNull public static HandlerList getHandlerList()