Interface WorldEditApi<C>

Type Parameters:
C - the WorldEdit clipboard type for the specific version being used

public interface WorldEditApi<C>
Version-specific API interface for WorldEdit integration across different Minecraft versions.

This interface provides a unified abstraction layer for WorldEdit operations that may vary between different WorldEdit and Minecraft versions. It handles clipboard operations, schematic loading, and structure pasting with support for transformations and positioning.

The generic type C represents the WorldEdit clipboard type, which varies between WorldEdit versions (e.g., Clipboard in newer versions vs CuboidClipboard in older versions).

  • Method Summary

    Modifier and Type
    Method
    Description
    getClipboardByFile(@NotNull World world, @NotNull File file)
    Loads a schematic file into a WorldEdit clipboard object.
    boolean
    pasteByFile(@NotNull File file, @NotNull Location location, int rotation)
    Loads and pastes a schematic file directly to the specified location.
    boolean
    pasteClipboard(@NotNull World world, C clipboard, @NotNull Vector origin, int rotation, int xOffset, int yOffset, int zOffset, boolean flipX, boolean flipZ)
    Pastes a WorldEdit clipboard into the specified world with transformations.
  • Method Details

    • pasteClipboard

      boolean pasteClipboard(@NotNull @NotNull World world, @NotNull C clipboard, @NotNull @NotNull Vector origin, int rotation, int xOffset, int yOffset, int zOffset, boolean flipX, boolean flipZ)
      Pastes a WorldEdit clipboard into the specified world with transformations.

      This method places the contents of a WorldEdit clipboard at the specified origin point with optional rotation, translation, and mirroring transformations applied. The paste operation respects WorldEdit's standard behavior for block placement and entity handling.

      The rotation is applied counterclockwise around the Y-axis, and offsets are applied after rotation. Flipping operations are applied in the clipboard's local coordinate system before rotation and translation.

      Parameters:
      world - the World to paste the clipboard into
      clipboard - the WorldEdit clipboard object containing the blocks to paste
      origin - the Vector position where the clipboard should be pasted
      rotation - the degree rotation to apply counterclockwise around the Y-axis
      xOffset - the X-axis offset to apply after rotation
      yOffset - the Y-axis offset to apply after rotation
      zOffset - the Z-axis offset to apply after rotation
      flipX - whether to flip the clipboard along the X-axis before rotation
      flipZ - whether to flip the clipboard along the Z-axis before rotation
      Returns:
      true if the paste operation completed without WorldEdit errors, false if WorldEdit encountered issues during pasting
    • pasteByFile

      boolean pasteByFile(@NotNull @NotNull File file, @NotNull @NotNull Location location, int rotation) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException, InstantiationException
      Loads and pastes a schematic file directly to the specified location.

      This convenience method loads a schematic file from disk and immediately pastes it at the specified location with the given rotation. This is useful for one-time paste operations where clipboard management is not needed.

      The rotation is applied counterclockwise around the Y-axis at the paste location.

      Parameters:
      file - the schematic File to load and paste
      location - the Location where the schematic should be pasted
      rotation - the degree rotation to apply counterclockwise around the Y-axis
      Returns:
      true if the paste operation completed without WorldEdit errors, false if WorldEdit encountered issues during loading or pasting
      Throws:
      NoSuchMethodException - if the required WorldEdit methods are not available
      InvocationTargetException - if WorldEdit method invocation fails
      IllegalAccessException - if WorldEdit method access is denied
      InstantiationException - if WorldEdit object instantiation fails
    • getClipboardByFile

      @Nullable C getClipboardByFile(@NotNull @NotNull World world, @NotNull @NotNull File file)
      Loads a schematic file into a WorldEdit clipboard object.

      This method loads a schematic file from disk and creates a WorldEdit clipboard object that can be used for multiple paste operations or clipboard manipulation. The returned clipboard contains all block data, entity data, and metadata from the original schematic.

      The world parameter is required for some WorldEdit versions to properly initialize the clipboard with the correct world context.

      Parameters:
      world - the World context for loading the clipboard
      file - the schematic File to load into a clipboard
      Returns:
      the loaded WorldEdit clipboard object, or null if loading failed