Class PlotModificationManager

java.lang.Object
com.plotsquared.core.plot.PlotModificationManager

public final class PlotModificationManager extends Object
Manager that handles Plot modifications
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    autoMerge(@NonNull Direction dir, int max, @NonNull UUID uuid, @Nullable PlotPlayer<?> actor, boolean removeRoads)
    Auto merge a plot in a specific direction.
    boolean
    clear(boolean checkRunning, boolean isDelete, @Nullable PlotPlayer<?> actor, @Nullable Runnable whenDone)
    Clear the plot
    void
    clear(@Nullable Runnable whenDone)
    Clear the plot
    copy(@NonNull Plot destination, @Nullable PlotPlayer<?> actor)
    Copy a plot to a location, both physically and the settings
    boolean
    Register a plot and create it in the database
    - The plot will not be created if the owner is null
    - Any setting from before plot creation will not be saved until the server is stopped properly.
    boolean
    create(@NonNull UUID uuid, boolean notify)
    Register a plot and create it in the database
    - The plot will not be created if the owner is null
    - Any setting from before plot creation will not be saved until the server is stopped properly.
    boolean
    deletePlot(@Nullable PlotPlayer<?> actor, Runnable whenDone)
    Delete a plot (use null for the runnable if you don't need to be notified on completion)
    move(@NonNull Plot destination, @Nullable PlotPlayer<?> actor, @NonNull Runnable whenDone)
    Moves the plot to an empty location
    - The location must be empty
    move(@NonNull Plot destination, @Nullable PlotPlayer<?> actor, @NonNull Runnable whenDone, boolean allowSwap)
    Moves a plot physically, as well as the corresponding settings.
    void
    Resend all chunks inside the plot to nearby players
    This should not need to be called
    void
    Remove the east road section of a plot
    - Used when a plot is merged
    void
    Remove the south road section of a plot
    - Used when a plot is merged
    void
    Remove the SE road (only effects terrain)
    void
    Remove the plot sign if it is set.
    void
    setBiome(@Nullable BiomeType biome, @NonNull Runnable whenDone)
    Sets the biome for a plot asynchronously.
    boolean
    setComponent(@NonNull String component, @NonNull Pattern blocks, @Nullable PlotPlayer<?> actor, @Nullable QueueCoordinator queue)
    Sets a component for a plot to the provided blocks
    - E.g.
    boolean
    setComponent(String component, String blocks, @Nullable PlotPlayer<?> actor, @Nullable QueueCoordinator queue)
    Deprecated.
    void
    Sets the plot sign if plot signs are enabled.
    void
    setSign(@NonNull String name)
    Sets the sign for a plot to a specific name
    swap(@NonNull Plot destination, @Nullable PlotPlayer<?> actor, @NonNull Runnable whenDone)
    Swap the plot contents and settings with another location
    - The destination must correspond to a valid plot of equal dimensions
    boolean
    Unlink a plot and remove the roads
    boolean
    unlinkPlot(boolean createRoad, boolean createSign)
    Unlink the plot and all connected plots.
    boolean
    unlinkPlot(boolean createRoad, boolean createSign, Runnable whenDone)
    Unlink the plot and all connected plots.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • copy

      public CompletableFuture<Boolean> copy(@NonNull Plot destination, @Nullable PlotPlayer<?> actor)
      Copy a plot to a location, both physically and the settings
      Parameters:
      destination - destination plot
      actor - the actor associated with the copy
      Returns:
      Future that completes with true if the copy was successful, else false
    • clear

      public void clear(@Nullable Runnable whenDone)
      Clear the plot

      Use deletePlot(PlotPlayer, Runnable) to clear and delete a plot

      Parameters:
      whenDone - A runnable to execute when clearing finishes, or null
      See Also:
    • clear

      public boolean clear(boolean checkRunning, boolean isDelete, @Nullable PlotPlayer<?> actor, @Nullable Runnable whenDone)
      Clear the plot

      Use deletePlot(PlotPlayer, Runnable) to clear and delete a plot

      Parameters:
      checkRunning - Whether or not already executing tasks should be checked
      isDelete - Whether or not the plot is being deleted
      actor - The actor clearing the plot
      whenDone - A runnable to execute when clearing finishes, or null
    • setBiome

      public void setBiome(@Nullable BiomeType biome, @NonNull Runnable whenDone)
      Sets the biome for a plot asynchronously.
      Parameters:
      biome - The biome e.g. "forest"
      whenDone - The task to run when finished, or null
    • unlinkPlot

      public boolean unlinkPlot(boolean createRoad, boolean createSign)
      Unlink the plot and all connected plots.
      Parameters:
      createRoad - whether to recreate road
      createSign - whether to recreate signs
      Returns:
      success/!cancelled
    • unlinkPlot

      public boolean unlinkPlot(boolean createRoad, boolean createSign, Runnable whenDone)
      Unlink the plot and all connected plots.
      Parameters:
      createRoad - whether to recreate road
      createSign - whether to recreate signs
      whenDone - Task to run when unlink is complete
      Returns:
      success/!cancelled
      Since:
      6.10.9
    • setSign

      public void setSign(@NonNull String name)
      Sets the sign for a plot to a specific name
      Parameters:
      name - name
    • refreshChunks

      public void refreshChunks()
      Resend all chunks inside the plot to nearby players
      This should not need to be called
    • removeSign

      public void removeSign()
      Remove the plot sign if it is set.
    • setSign

      public void setSign()
      Sets the plot sign if plot signs are enabled.
    • create

      public boolean create()
      Register a plot and create it in the database
      - The plot will not be created if the owner is null
      - Any setting from before plot creation will not be saved until the server is stopped properly. i.e. Set any values/options after plot creation.
      Returns:
      true if plot was created successfully
    • create

      public boolean create(@NonNull UUID uuid, boolean notify)
      Register a plot and create it in the database
      - The plot will not be created if the owner is null
      - Any setting from before plot creation will not be saved until the server is stopped properly. i.e. Set any values/options after plot creation.
      Parameters:
      uuid - the uuid of the plot owner
      notify - notify
      Returns:
      true if plot was created successfully, else false
    • autoMerge

      public boolean autoMerge(@NonNull Direction dir, int max, @NonNull UUID uuid, @Nullable PlotPlayer<?> actor, boolean removeRoads)
      Auto merge a plot in a specific direction.
      Parameters:
      dir - the direction to merge
      max - the max number of merges to do
      uuid - the UUID it is allowed to merge with
      actor - The actor executing the task
      removeRoads - whether to remove roads
      Returns:
      true if a merge takes place, else false
    • move

      public @NonNull CompletableFuture<Boolean> move(@NonNull Plot destination, @Nullable PlotPlayer<?> actor, @NonNull Runnable whenDone, boolean allowSwap)
      Moves a plot physically, as well as the corresponding settings.
      Parameters:
      destination - Plot moved to
      actor - The actor executing the task
      whenDone - task when done
      allowSwap - whether to swap plots
      Returns:
      true if the move was successful, else false
    • unlink

      public boolean unlink()
      Unlink a plot and remove the roads
      Returns:
      true if plot was linked
      See Also:
    • swap

      public @NonNull CompletableFuture<Boolean> swap(@NonNull Plot destination, @Nullable PlotPlayer<?> actor, @NonNull Runnable whenDone)
      Swap the plot contents and settings with another location
      - The destination must correspond to a valid plot of equal dimensions
      Parameters:
      destination - The other plot to swap with
      actor - The actor executing the task
      whenDone - A task to run when finished, or null
      Returns:
      Future that completes with true if the swap was successful, else false
    • move

      public @NonNull CompletableFuture<Boolean> move(@NonNull Plot destination, @Nullable PlotPlayer<?> actor, @NonNull Runnable whenDone)
      Moves the plot to an empty location
      - The location must be empty
      Parameters:
      destination - Where to move the plot
      actor - The actor executing the task
      whenDone - A task to run when done, or null
      Returns:
      Future that completes with true if the move was successful, else false
    • setComponent

      public boolean setComponent(@NonNull String component, @NonNull Pattern blocks, @Nullable PlotPlayer<?> actor, @Nullable QueueCoordinator queue)
      Sets a component for a plot to the provided blocks
      - E.g. floor, wall, border etc.
      - The available components depend on the generator being used
      Parameters:
      component - Component to set
      blocks - Pattern to use the generation
      actor - The actor executing the task
      queue - Nullable QueueCoordinator. If null, creates own queue and enqueues, otherwise writes to the queue but does not enqueue.
      Returns:
      true if the component was set successfully, else false
    • deletePlot

      public boolean deletePlot(@Nullable PlotPlayer<?> actor, Runnable whenDone)
      Delete a plot (use null for the runnable if you don't need to be notified on completion)

      Use clear(boolean, boolean, PlotPlayer, Runnable) to simply clear a plot

      Parameters:
      actor - The actor executing the task
      whenDone - task to run when plot has been deleted. Nullable
      Returns:
      true if the deletion was successful, false if not
      See Also:
    • setComponent

      @Deprecated public boolean setComponent(String component, String blocks, @Nullable PlotPlayer<?> actor, @Nullable QueueCoordinator queue)
      Deprecated.
      Sets components such as border, wall, floor. (components are generator specific)
      Parameters:
      component - component to set
      blocks - string of block(s) to set component to
      actor - The player executing the task
      queue - Nullable QueueCoordinator. If null, creates own queue and enqueues, otherwise writes to the queue but does not enqueue.
      Returns:
      true if the update was successful, false if not
    • removeRoadSouth

      public void removeRoadSouth(@Nullable QueueCoordinator queue)
      Remove the south road section of a plot
      - Used when a plot is merged
      Parameters:
      queue - Nullable QueueCoordinator. If null, creates own queue and enqueues, otherwise writes to the queue but does not enqueue.
    • removeRoadEast

      public void removeRoadEast(@Nullable QueueCoordinator queue)
      Remove the east road section of a plot
      - Used when a plot is merged
      Parameters:
      queue - Nullable QueueCoordinator. If null, creates own queue and enqueues, otherwise writes to the queue but does not enqueue.
    • removeRoadSouthEast

      public void removeRoadSouthEast(@Nullable QueueCoordinator queue)
      Remove the SE road (only effects terrain)
      Parameters:
      queue - Nullable QueueCoordinator. If null, creates own queue and enqueues, otherwise writes to the queue but does not enqueue.