Class Plot

java.lang.Object
com.plotsquared.core.plot.Plot
Direct Known Subclasses:
SinglePlot

public class Plot extends Object
The plot class
[IMPORTANT] - Unclaimed plots will not have persistent information. - Any information set/modified in an unclaimed object may not be reflected in other instances - Using the `new` operator will create an unclaimed plot instance - Use the methods from the PlotArea/PS/Location etc to get existing plots
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static int
     
    int
    Deprecated.
    magical
  • Constructor Summary

    Constructors
    Constructor
    Description
    Plot​(@NonNull PlotArea area, @NonNull PlotId id)
    Constructor for an unowned plot.
    Plot​(@NonNull PlotId id, UUID owner, HashSet<UUID> trusted, HashSet<UUID> members, HashSet<UUID> denied, String alias, BlockLoc position, Collection<PlotFlag<?,​?>> flags, PlotArea area, boolean[] merged, long timestamp, int temp)
    Constructor for a saved plots (Used by the database manager when plots are fetched)
    Plot​(PlotArea area, @NonNull PlotId id, UUID owner)
    Constructor for a new plot.
    Plot​(PlotArea area, @NonNull PlotId id, UUID owner, int temp)
    Constructor for a temporary plot (use -1 for temp)
    The database will ignore any queries regarding temporary plots.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addDenied​(@NonNull UUID uuid)
    Denies a player from this plot.
    void
    addMember​(@NonNull UUID uuid)
    Add someone as a trusted user (updates database as well)
    boolean
    addRating​(UUID uuid, Rating rating)
    Sets a rating for a user
    - If the user has already rated, the following will return false
    int
    Returns true if a previous task was running
    void
    addTrusted​(@NonNull UUID uuid)
    Add someone as a helper (updates database as well)
    boolean
    canClaim​(@NonNull PlotPlayer<?> player)
    Check if a plot can be claimed by the provided player.
    boolean
    claim​(@NonNull PlotPlayer<?> player, boolean teleport, String schematic)
    Deprecated, for removal: This API element is subject to removal in a future version.
    boolean
    claim​(@NonNull PlotPlayer<?> player, boolean teleport, String schematic, boolean updateDB)
    Deprecated, for removal: This API element is subject to removal in a future version.
    boolean
    claim​(@NonNull PlotPlayer<?> player, boolean teleport, String schematic, boolean updateDB, boolean auto)
    Claim the plot
    void
     
    void
    Clear the ratings/likes for this plot
    int[]
    Count the entities in a plot
    void
    debug​(@NonNull String message)
     
    void
    deleteMeta​(@NonNull String key)
    Delete the metadata for a key
    - metadata is session only - deleting other plugin's metadata may cause issues
    boolean
    equals​(Object obj)
     
    format​(Caption iInfo, PlotPlayer<?> player, boolean full)
     
    static @Nullable Plot
    fromString​(@Nullable PlotArea defaultArea, @NonNull String string)
    Gets a plot from a string e.g.
    @NonNull String
    Gets the plot alias.
    getApplicableFlags​(boolean ignorePluginFlags)
    Get flags associated with the plot and the plot area that contains it.
    getApplicableFlags​(boolean plotOnly, boolean ignorePluginFlags)
    Get flags associated with the plot.
    @Nullable PlotArea
    Gets the plot world object for this plot
    - The generic PlotArea object can be casted to its respective class for more control (e.g.
    double
    Gets the average rating of the plot.
    @org.checkerframework.checker.nullness.qual.NonNull double[]
    If rating categories are enabled, get the average rating by category.
    - The index corresponds to the index of the category in the config
    getBasePlot​(boolean recalculate)
    The base plot is an arbitrary but specific connected plot.
    void
    getBiome​(Consumer<com.sk89q.worldedit.world.biome.BiomeType> result)
    Retrieve the biome of the plot.
    com.sk89q.worldedit.world.biome.BiomeType
    Deprecated.
    May cause synchronous chunk loads
    Deprecated.
    in favor of getCorners()[0];
    Returns the bottom location for the plot.
    void
     
    Deprecated.
    May cause synchronous chunk loads
    @Nullable PlotCluster
    Gets the cluster this plot is associated with
    This will return null if the plot hasn't been analyzed
    Gets a set of plots connected (and including) this plot
    - This result is cached globally
    Deprecated.
    as merged plots no longer need to be rectangular
    void
    getDefaultHome​(boolean member, Consumer<Location> result)
     
    void
    Gets the default home location for a plot
    - Ignores any home location set for that specific plot
    getDefaultHomeSynchronous​(boolean member)
    Deprecated.
    May cause synchronous chunk loads
    @NonNull HashSet<UUID>
    Gets the denied users.
    int
     
    Gets the bot loc of a plot (if mega, returns bot loc of that mega plot) - If you would like each plot treated as a small plot use getBottomAbs()
    Gets the top loc of a plot (if mega, returns top loc of that mega plot) - If you would like each plot treated as a small plot use getTopAbs()
    <T> @NonNull T
    getFlag​(@NonNull Class<? extends PlotFlag<T,​?>> flagClass)
    Get the value associated with the specified flag.
    <T,​ V extends PlotFlag<T,​ ?>>
    @NonNull T
    getFlag​(@NonNull V flag)
    Get the value associated with the specified flag.
    @NonNull FlagContainer
    Get the plot flag container
    Set<PlotFlag<?,​?>>
    Get an immutable view of all the flags associated with the plot.
    void
    Return the home location for the plot
    Deprecated.
    May cause synchronous chunk loading
    @NonNull PlotId
    Gets the PlotId of this plot.
    com.sk89q.worldedit.regions.CuboidRegion
    Attempt to find the largest rectangular region in a plot (as plots can form non rectangular shapes)
     
    @NonNull PlotManager
    Gets the plot manager object for this plot
    - The generic PlotManager object can be casted to its respective class for more control (e.g.
    @NonNull HashSet<UUID>
    Gets the members
    boolean[]
    Gets the merged array.
    @Nullable Object
    getMeta​(@NonNull String key)
    Gets the metadata for a key

    For persistent metadata use the flag system
    @Nullable UUID
    Get the plot owner of this particular sub-plot.
    @Nullable UUID
    Get the owner of this exact plot, as it is stored in the database.
    @NonNull Set<UUID>
    Gets a immutable set of owner UUIDs for a plot (supports multi-owner mega-plots).
    @NonNull List<PlotPlayer<?>>
    Efficiently get the players currently inside this plot
    - Will return an empty list if no players are in the plot
    - Remember, you can cast a PlotPlayer to its respective implementation (BukkitPlayer, SpongePlayer) to obtain the player object
    static @Nullable Plot
    getPlot​(@NonNull Location location)
    Return a new/cached plot object at a given location.
    Get the plot comment container.
    static @Nullable Plot
    getPlotFromString​(@Nullable PlotPlayer<?> player, @Nullable String arg, boolean message)
    Get the plot from a string.
    Get the plot modification manager
    Gets the set home location or 0,Integer#MIN_VALUE,0 if no location is set
    - Does not take the default home location into account - PlotSquared will internally find the correct place to teleport to if y = Integer#MIN_VALUE when teleporting to the plot.
    Gets the ratings associated with a plot
    - The rating object may contain multiple categories
    @NonNull Set<com.sk89q.worldedit.regions.CuboidRegion>
    This will combine each plot into effective rectangular regions
    - This result is cached globally
    - Useful for handling non rectangular shapes
    getRelative​(int x, int y)
    Gets the plot in a relative location
    Note: May be null if the partial plot area does not include the relative location
    @Nullable Plot
    getRelative​(@NonNull Direction direction)
    Gets the plot in a relative direction Note: May be null if the partial plot area does not include the relative location
    getRelative​(PlotArea area, int x, int y)
     
    int
    Gets the number of tracked running tasks for this plot
    - Used to track/limit the number of things a player can do on the plot at once
    @NonNull PlotSettings
    Gets or create plot settings.
    void
     
    Deprecated.
    May cause synchronous chunk loads
    long
    Gets the timestamp of when the plot was created (unreliable)
    - not accurate if the plot was created before this was implemented
    - Milliseconds since the epoch
    Deprecated.
    in favor of getCorners()[1];
    Returns the top location for the plot.
    @NonNull HashSet<UUID>
    Gets the trusted users.
    double
     
    @Nullable String
    Get the name of the world that the plot is in
    int
    Gets the plot hashcode
    Note: The hashcode is unique if:
    - Plots are in the same world
    - The x,z coordinates are between Short.MIN_VALUE and Short.MAX_VALUE
    boolean
    Checks if the plot has an owner.
    boolean
     
    boolean
    isAdded​(@NonNull UUID uuid)
    Checks if the player is either the owner or on the trusted/added list.
    boolean
    Returns true if the plot is not merged, or it is the base plot of multiple merged plots.
    boolean
    isDenied​(@NonNull UUID uuid)
    Checks if the player is not permitted on this plot.
    boolean
     
    boolean
    Checks if this plot is merged in any direction.
    boolean
    isMerged​(int dir)
    Gets if the plot is merged in a direction
    ------- Actual -------
    0 = north
    1 = east
    2 = south
    3 = west
    ----- Artificial -----
    4 = north-east
    5 = south-east
    6 = south-west
    7 = north-west
    ----------
    boolean
    isMerged​(@NonNull Direction direction)
    Check if the plot is merged in a given direction
    boolean
    Checks if the owner of this Plot is online.
    boolean
    isOwner​(@NonNull UUID uuid)
    Checks if a UUID is a plot owner (merged plots may have multiple owners)
    boolean
    isOwnerAbs​(@Nullable UUID uuid)
    Checks if the given UUID is the owner of this specific plot
    void
    mergeData​(Plot plot)
    Merge the plot settings
    - Used when a plot is merged
    void
    mergePlot​(Plot lesserPlot, boolean removeRoads, @Nullable QueueCoordinator queue)
    Merges two plots.
    boolean
    moveData​(Plot plot, Runnable whenDone)
    Moves the settings for a plot.
    void
    Do the plot entry tasks for each player in the plot
    - Usually called when the plot state changes (unclaimed/claimed/flag change etc)
    boolean
    removeDenied​(UUID uuid)
    Remove a denied player (use DBFunc as well)
    Using the * uuid will remove all users
    boolean
    removeFlag​(@NonNull PlotFlag<?,​?> flag)
    Remove a flag from this plot
    boolean
    removeFlag​(@NonNull Class<? extends PlotFlag<?,​?>> flag)
    Remove a flag from this plot
    boolean
    removeMember​(UUID uuid)
    Remove a trusted user (use DBFunc as well)
    Using the * uuid will remove all users
    int
    Decrement the number of tracked tasks this plot is running
    - Used to track/limit the number of things a player can do on the plot at once
    boolean
    Remove a helper (use DBFunc as well)
    Using the * uuid will remove all users
    void
    setAlias​(String alias)
    Sets the plot alias.
    void
    setArea​(@NonNull PlotArea area)
    Assigns this plot to a plot area.
    (Mostly used during startup when worlds are being created)
    void
    setDenied​(@NonNull Set<UUID> uuids)
    Sets the denied users for this plot.
    <V> boolean
    setFlag​(@NonNull PlotFlag<V,​?> flag)
    Sets a flag for the plot and stores it in the database.
    boolean
    setFlag​(@NonNull Class<?> flag, @NonNull String value)
    Parse the flag value into a flag instance based on the provided flag class, and store it in the database.
    void
    setHome​(BlockLoc location)
    Sets the home location
    void
    setId​(@NonNull PlotId id)
    Change the plot ID
    void
    setMembers​(@NonNull Set<UUID> uuids)
    Sets the members for this plot.
    void
    setMerged​(boolean[] merged)
    Sets the raw merge data
    - Updates DB
    - Does not modify terrain
    Gets if the plot is merged in a direction
    ----------
    0 = north
    1 = east
    2 = south
    3 = west
    ----------
    Note: Diagonal merging (4-7) must be done by merging the corresponding plots.
    void
    setMerged​(Direction direction, boolean value)
    Sets the raw merge data
    - Updates DB
    - Does not modify terrain
    void
    setMeta​(@NonNull String key, @NonNull Object value)
    Session only plot metadata (session is until the server stops)

    For persistent metadata use the flag system
    void
    setOwner​(@NonNull UUID owner)
    Sets the plot owner (and update the database)
    boolean
    setOwner​(UUID owner, PlotPlayer<?> initiator)
    Sets the plot owner (and update the database)
    void
    setOwnerAbs​(@Nullable UUID owner)
    Set the owner of this exact sub-plot.
    void
    setTrusted​(@NonNull Set<UUID> uuids)
    Sets the trusted users for this plot.
    swapData​(Plot plot)
    Swaps the settings for two plots.
    void
    teleportPlayer​(PlotPlayer<?> player, TeleportCause cause, Consumer<Boolean> resultConsumer)
    Teleport a player to a plot and send them the teleport message.
    void
    teleportPlayer​(PlotPlayer<?> player, Consumer<Boolean> result)
    Teleport a player to a plot and send them the teleport message.
    Gets plot display name.
    boolean
    Unclaim the plot (does not modify terrain).
    void
    Expands the world border to include this plot if it is beyond the current border.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • MAX_HEIGHT

      public static final int MAX_HEIGHT
      See Also:
      Constant Field Values
    • temp

      @Deprecated public int temp
      Deprecated.
      magical
      Represents whatever the database manager needs it to:
      - A value of -1 usually indicates the plot will not be stored in the DB
      - A value of 0 usually indicates that the DB manager hasn't set a value
  • Constructor Details

    • Plot

      public Plot(PlotArea area, @NonNull PlotId id, UUID owner)
      Constructor for a new plot. (Only changes after plot.create() will be properly set in the database)
      Parameters:
      area - the PlotArea where the plot is located
      id - the plot id
      owner - the plot owner
      See Also:
      for existing plots
    • Plot

      public Plot(@NonNull PlotArea area, @NonNull PlotId id)
      Constructor for an unowned plot. (Only changes after plot.create() will be properly set in the database)
      Parameters:
      area - the PlotArea where the plot is located
      id - the plot id
      See Also:
      for existing plots
    • Plot

      public Plot(PlotArea area, @NonNull PlotId id, UUID owner, int temp)
      Constructor for a temporary plot (use -1 for temp)
      The database will ignore any queries regarding temporary plots. Please note that some bulk plot management functions may still affect temporary plots (TODO: fix this)
      Parameters:
      area - the PlotArea where the plot is located
      id - the plot id
      owner - the owner of the plot
      temp - Represents whatever the database manager needs it to
      See Also:
      for existing plots
    • Plot

      public Plot(@NonNull PlotId id, UUID owner, HashSet<UUID> trusted, HashSet<UUID> members, HashSet<UUID> denied, String alias, BlockLoc position, Collection<PlotFlag<?,​?>> flags, PlotArea area, boolean[] merged, long timestamp, int temp)
      Constructor for a saved plots (Used by the database manager when plots are fetched)
      Parameters:
      id - the plot id
      owner - the plot owner
      trusted - the plot trusted players
      members - the plot added players
      denied - the plot denied players
      alias - the plot's alias
      position - plot home position
      flags - the plot's flags
      area - the plot's PlotArea
      merged - an array giving merged plots
      timestamp - when the plot was created
      temp - value representing whatever DBManager needs to to. Do not touch tbh.
      See Also:
      for existing plots
  • Method Details

    • getPlotFromString

      public static @Nullable Plot getPlotFromString(@Nullable PlotPlayer<?> player, @Nullable String arg, boolean message)
      Get the plot from a string.
      Parameters:
      player - Provides a context for what world to search in. Prefixing the term with 'world_name;' will override this context.
      arg - The search term
      message - If a message should be sent to the player if a plot cannot be found
      Returns:
      The plot if only 1 result is found, or null
    • fromString

      public static @Nullable Plot fromString(@Nullable PlotArea defaultArea, @NonNull String string)
      Gets a plot from a string e.g. [area];[id]
      Parameters:
      defaultArea - if no area is specified
      string - plot id/area + id
      Returns:
      New or existing plot object
    • getPlot

      public static @Nullable Plot getPlot(@NonNull Location location)
      Return a new/cached plot object at a given location.
      Parameters:
      location - the location of the plot
      Returns:
      plot at location or null
      See Also:
      if a player is expected here.
    • getOwnerAbs

      public @Nullable UUID getOwnerAbs()
      Get the owner of this exact plot, as it is stored in the database.

      If the plot is a mega-plot, then the method returns the owner of this particular subplot.

      Unlike getOwner() this method does not consider factors such as ServerPlotFlag that could alter the de facto owner of the plot.

      Returns:
      The plot owner of this particular (sub-)plot as stored in the database, if one exists. Else, null.
    • setOwnerAbs

      public void setOwnerAbs(@Nullable UUID owner)
      Set the owner of this exact sub-plot. This does not update the database.
      Parameters:
      owner - The new owner of this particular sub-plot.
    • getWorldName

      public @Nullable String getWorldName()
      Get the name of the world that the plot is in
      Returns:
      World name
    • setMeta

      public void setMeta(@NonNull String key, @NonNull Object value)
      Session only plot metadata (session is until the server stops)

      For persistent metadata use the flag system
      Parameters:
      key - metadata key
      value - metadata value
    • getMeta

      public @Nullable Object getMeta(@NonNull String key)
      Gets the metadata for a key

      For persistent metadata use the flag system
      Parameters:
      key - metadata key to get value for
      Returns:
      Object value
    • deleteMeta

      public void deleteMeta(@NonNull String key)
      Delete the metadata for a key
      - metadata is session only - deleting other plugin's metadata may cause issues
      Parameters:
      key - key to delete
    • getCluster

      public @Nullable PlotCluster getCluster()
      Gets the cluster this plot is associated with
      Returns:
      the PlotCluster object, or null
    • getPlayersInPlot

      public @NonNull List<PlotPlayer<?>> getPlayersInPlot()
      Efficiently get the players currently inside this plot
      - Will return an empty list if no players are in the plot
      - Remember, you can cast a PlotPlayer to its respective implementation (BukkitPlayer, SpongePlayer) to obtain the player object
      Returns:
      list of PlotPlayer(s) or an empty list
    • hasOwner

      public boolean hasOwner()
      Checks if the plot has an owner.
      Returns:
      true if there is an owner, else false
    • isOwner

      public boolean isOwner(@NonNull UUID uuid)
      Checks if a UUID is a plot owner (merged plots may have multiple owners)
      Parameters:
      uuid - Player UUID
      Returns:
      true if the provided uuid is the owner of the plot, else false
    • isOwnerAbs

      public boolean isOwnerAbs(@Nullable UUID uuid)
      Checks if the given UUID is the owner of this specific plot
      Parameters:
      uuid - Player UUID
      Returns:
      true if the provided uuid is the owner of the plot, else false
    • getOwner

      public @Nullable UUID getOwner()
      Get the plot owner of this particular sub-plot. (Merged plots can have multiple owners) Direct access is discouraged: use getOwners()
      Returns:
      Server if ServerPlot flag set, else getOwnerAbs()
      See Also:
      getOwnerAbs() to get the owner as stored in the database
    • setOwner

      public void setOwner(@NonNull UUID owner)
      Sets the plot owner (and update the database)
      Parameters:
      owner - uuid to set as owner
    • getOwners

      public @NonNull Set<UUID> getOwners()
      Gets a immutable set of owner UUIDs for a plot (supports multi-owner mega-plots).

      This method cannot be used to add or remove owners from a plot.

      Returns:
      Immutable view of plot owners
    • isAdded

      public boolean isAdded(@NonNull UUID uuid)
      Checks if the player is either the owner or on the trusted/added list.
      Parameters:
      uuid - uuid to check
      Returns:
      true if the player is added/trusted or is the owner, else false
    • isDenied

      public boolean isDenied(@NonNull UUID uuid)
      Checks if the player is not permitted on this plot.
      Parameters:
      uuid - uuid to check
      Returns:
      false if the player is allowed to enter the plot, else true
    • getId

      public @NonNull PlotId getId()
      Gets the PlotId of this plot.
      Returns:
      the PlotId for this plot
    • setId

      public void setId(@NonNull PlotId id)
      Change the plot ID
      Parameters:
      id - new plot ID
    • getArea

      public @Nullable PlotArea getArea()
      Gets the plot world object for this plot
      - The generic PlotArea object can be casted to its respective class for more control (e.g. HybridPlotWorld)
      Returns:
      PlotArea
    • setArea

      public void setArea(@NonNull PlotArea area)
      Assigns this plot to a plot area.
      (Mostly used during startup when worlds are being created)

      Do not use this unless you absolutely know what you are doing.

      Parameters:
      area - area to assign to
    • getManager

      public @NonNull PlotManager getManager()
      Gets the plot manager object for this plot
      - The generic PlotManager object can be casted to its respective class for more control (e.g. HybridPlotManager)
      Returns:
      PlotManager
    • getSettings

      public @NonNull PlotSettings getSettings()
      Gets or create plot settings.
      Returns:
      PlotSettings
    • isBasePlot

      public boolean isBasePlot()
      Returns true if the plot is not merged, or it is the base plot of multiple merged plots.
      Returns:
      Boolean
    • getBasePlot

      public Plot getBasePlot(boolean recalculate)
      The base plot is an arbitrary but specific connected plot. It is useful for the following:
      - Merged plots need to be treated as a single plot for most purposes
      - Some data such as home location needs to be associated with the group rather than each plot
      - If the plot is not merged it will return itself.
      - The result is cached locally
      Parameters:
      recalculate - whether to recalculate the merged plots to find the origin
      Returns:
      base Plot
    • isMerged

      public boolean isMerged()
      Checks if this plot is merged in any direction.
      Returns:
      true if this plot is merged, otherwise false
    • getTimestamp

      public long getTimestamp()
      Gets the timestamp of when the plot was created (unreliable)
      - not accurate if the plot was created before this was implemented
      - Milliseconds since the epoch
      Returns:
      the creation date of the plot
    • isMerged

      public boolean isMerged(int dir)
      Gets if the plot is merged in a direction
      ------- Actual -------
      0 = north
      1 = east
      2 = south
      3 = west
      ----- Artificial -----
      4 = north-east
      5 = south-east
      6 = south-west
      7 = north-west
      ----------

      Note: A plot that is merged north and east will not be merged northeast if the northeast plot is not part of the same group

      Parameters:
      dir - direction to check for merged plot
      Returns:
      true if merged in that direction, else false
    • getDenied

      public @NonNull HashSet<UUID> getDenied()
      Gets the denied users.
      Returns:
      a set of denied users
    • setDenied

      public void setDenied(@NonNull Set<UUID> uuids)
      Sets the denied users for this plot.
      Parameters:
      uuids - uuids to deny
    • getTrusted

      public @NonNull HashSet<UUID> getTrusted()
      Gets the trusted users.
      Returns:
      a set of trusted users
    • setTrusted

      public void setTrusted(@NonNull Set<UUID> uuids)
      Sets the trusted users for this plot.
      Parameters:
      uuids - uuids to trust
    • getMembers

      public @NonNull HashSet<UUID> getMembers()
      Gets the members
      Returns:
      a set of members
    • setMembers

      public void setMembers(@NonNull Set<UUID> uuids)
      Sets the members for this plot.
      Parameters:
      uuids - uuids to set member status for
    • addDenied

      public void addDenied(@NonNull UUID uuid)
      Denies a player from this plot. (updates database as well)
      Parameters:
      uuid - the uuid of the player to deny.
    • addTrusted

      public void addTrusted(@NonNull UUID uuid)
      Add someone as a helper (updates database as well)
      Parameters:
      uuid - the uuid of the player to trust
    • addMember

      public void addMember(@NonNull UUID uuid)
      Add someone as a trusted user (updates database as well)
      Parameters:
      uuid - the uuid of the player to add as a member
    • setOwner

      public boolean setOwner(UUID owner, PlotPlayer<?> initiator)
      Sets the plot owner (and update the database)
      Parameters:
      owner - uuid to set as owner
      initiator - player initiating set owner
      Returns:
      boolean
    • isLoaded

      public boolean isLoaded()
    • getComplexity

      public PlotAnalysis getComplexity(Settings.Auto_Clear settings)
      This will return null if the plot hasn't been analyzed
      Parameters:
      settings - The set of settings to obtain the analysis of
      Returns:
      analysis of plot
    • getFlags

      public Set<PlotFlag<?,​?>> getFlags()
      Get an immutable view of all the flags associated with the plot.
      Returns:
      Immutable set containing the flags associated with the plot
    • setFlag

      public <V> boolean setFlag(@NonNull PlotFlag<V,​?> flag)
      Sets a flag for the plot and stores it in the database.
      Type Parameters:
      V - flag value type
      Parameters:
      flag - Flag to set
      Returns:
      A boolean indicating whether or not the operation succeeded
    • setFlag

      public boolean setFlag(@NonNull Class<?> flag, @NonNull String value)
      Parse the flag value into a flag instance based on the provided flag class, and store it in the database.
      Parameters:
      flag - Flag type
      value - Flag value
      Returns:
      A boolean indicating whether or not the operation succeeded
    • removeFlag

      public boolean removeFlag(@NonNull Class<? extends PlotFlag<?,​?>> flag)
      Remove a flag from this plot
      Parameters:
      flag - the flag to remove
      Returns:
      success
    • getApplicableFlags

      public Collection<PlotFlag<?,​?>> getApplicableFlags(boolean plotOnly, boolean ignorePluginFlags)
      Get flags associated with the plot.
      Parameters:
      plotOnly - Whether or not to only consider the plot. If this parameter is set to true, the default values of the owning plot area will not be considered
      ignorePluginFlags - Whether or not to ignore internal flags
      Returns:
      Collection containing all the flags that matched the given criteria
    • getApplicableFlags

      public Collection<PlotFlag<?,​?>> getApplicableFlags(boolean ignorePluginFlags)
      Get flags associated with the plot and the plot area that contains it.
      Parameters:
      ignorePluginFlags - Whether or not to ignore internal flags
      Returns:
      Collection containing all the flags that matched the given criteria
    • removeFlag

      public boolean removeFlag(@NonNull PlotFlag<?,​?> flag)
      Remove a flag from this plot
      Parameters:
      flag - the flag to remove
      Returns:
      success
    • countEntities

      public int[] countEntities()
      Count the entities in a plot
      Returns:
      array of entity counts
      See Also:
      0 = Entity 1 = Animal 2 = Monster 3 = Mob 4 = Boat 5 = Misc
    • addRunning

      public int addRunning()
      Returns true if a previous task was running
      Returns:
      true if a previous task is running
    • removeRunning

      public int removeRunning()
      Decrement the number of tracked tasks this plot is running
      - Used to track/limit the number of things a player can do on the plot at once
      Returns:
      previous number of tasks (int)
    • getRunning

      public int getRunning()
      Gets the number of tracked running tasks for this plot
      - Used to track/limit the number of things a player can do on the plot at once
      Returns:
      number of tasks (int)
    • unclaim

      public boolean unclaim()
      Unclaim the plot (does not modify terrain). Changes made to this plot will not be reflected in unclaimed plot objects.
      Returns:
      false if the Plot has no owner, otherwise true.
    • getCenter

      public void getCenter(Consumer<Location> result)
    • getCenterSynchronous

      @Deprecated public Location getCenterSynchronous()
      Deprecated.
      May cause synchronous chunk loads
      Returns:
      Location of center
    • getSideSynchronous

      @Deprecated public Location getSideSynchronous()
      Deprecated.
      May cause synchronous chunk loads
      Returns:
      side where players should teleport to
    • getSide

      public void getSide(Consumer<Location> result)
    • getHomeSynchronous

      @Deprecated public Location getHomeSynchronous()
      Deprecated.
      May cause synchronous chunk loading
      Returns:
      the plot home location
    • getHome

      public void getHome(Consumer<Location> result)
      Return the home location for the plot
      Parameters:
      result - consumer to pass location to when found
    • setHome

      public void setHome(BlockLoc location)
      Sets the home location
      Parameters:
      location - location to set as home
    • getDefaultHome

      public void getDefaultHome(Consumer<Location> result)
      Gets the default home location for a plot
      - Ignores any home location set for that specific plot
      Parameters:
      result - consumer to pass location to when found
    • getDefaultHomeSynchronous

      @Deprecated public Location getDefaultHomeSynchronous(boolean member)
      Deprecated.
      May cause synchronous chunk loads
      Parameters:
      member - if to get the home for plot members
      Returns:
      location of home for members or visitors
    • getDefaultHome

      public void getDefaultHome(boolean member, Consumer<Location> result)
    • getVolume

      public double getVolume()
    • getAverageRating

      public double getAverageRating()
      Gets the average rating of the plot. This is the value displayed in /plot info
      Returns:
      average rating as double, Double.NaN of no ratings exist
    • addRating

      public boolean addRating(UUID uuid, Rating rating)
      Sets a rating for a user
      - If the user has already rated, the following will return false
      Parameters:
      uuid - uuid of rater
      rating - rating
      Returns:
      success
    • clearRatings

      public void clearRatings()
      Clear the ratings/likes for this plot
    • getLikes

      public Map<UUID,​Boolean> getLikes()
    • getRatings

      public HashMap<UUID,​Rating> getRatings()
      Gets the ratings associated with a plot
      - The rating object may contain multiple categories
      Returns:
      Map of user who rated to the rating
    • hasRatings

      public boolean hasRatings()
    • claim

      @Deprecated(forRemoval=true) public boolean claim(@NonNull PlotPlayer<?> player, boolean teleport, String schematic)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • claim

      @Deprecated(forRemoval=true) public boolean claim(@NonNull PlotPlayer<?> player, boolean teleport, String schematic, boolean updateDB)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • claim

      public boolean claim(@NonNull PlotPlayer<?> player, boolean teleport, String schematic, boolean updateDB, boolean auto)
      Claim the plot
      Parameters:
      player - The player to set the owner to
      teleport - If the player should be teleported
      schematic - The schematic name to paste on the plot
      updateDB - If the database should be updated
      auto - If the plot is being claimed by a /plot auto
      Returns:
      success
    • getBiome

      public void getBiome(Consumer<com.sk89q.worldedit.world.biome.BiomeType> result)
      Retrieve the biome of the plot.
      Parameters:
      result - consumer to pass biome to when found
    • getBiomeSynchronous

      @Deprecated public com.sk89q.worldedit.world.biome.BiomeType getBiomeSynchronous()
      Deprecated.
      May cause synchronous chunk loads
      Returns:
      biome at center of plot
    • getTopAbs

      public Location getTopAbs()
      Returns the top location for the plot.
      Returns:
      location of Absolute Top
    • getBottomAbs

      public Location getBottomAbs()
      Returns the bottom location for the plot.
      Returns:
      location of absolute bottom of plot
    • swapData

      public CompletableFuture<Boolean> swapData(Plot plot)
      Swaps the settings for two plots.
      Parameters:
      plot - the plot to swap data with
      Returns:
      Future containing the result
    • moveData

      public boolean moveData(Plot plot, Runnable whenDone)
      Moves the settings for a plot.
      Parameters:
      plot - the plot to move
      whenDone - task to run when settings have been moved
      Returns:
      success or not
    • getExtendedTopAbs

      public Location getExtendedTopAbs()
      Gets the top loc of a plot (if mega, returns top loc of that mega plot) - If you would like each plot treated as a small plot use getTopAbs()
      Returns:
      Location top of mega plot
    • getExtendedBottomAbs

      public Location getExtendedBottomAbs()
      Gets the bot loc of a plot (if mega, returns bot loc of that mega plot) - If you would like each plot treated as a small plot use getBottomAbs()
      Returns:
      Location bottom of mega plot
    • getCorners

      @Deprecated public Location[] getCorners()
      Deprecated.
      as merged plots no longer need to be rectangular
      Returns the top and bottom location.
      - If the plot is not connected, it will return its own corners
      - the returned locations will not necessarily correspond to claimed plots if the connected plots do not form a rectangular shape
      Returns:
      new Location[] { bottom, top }
    • getBottom

      @Deprecated public Location getBottom()
      Deprecated.
      in favor of getCorners()[0];
      Returns:
      bottom corner location
    • getTop

      @Deprecated public Location getTop()
      Deprecated.
      in favor of getCorners()[1];
      Returns:
      the top corner of the plot
    • toString

      public String toString()
      Gets plot display name.
      Overrides:
      toString in class Object
      Returns:
      alias if set, else id
    • removeDenied

      public boolean removeDenied(UUID uuid)
      Remove a denied player (use DBFunc as well)
      Using the * uuid will remove all users
      Parameters:
      uuid - uuid of player to remove from denied list
      Returns:
      success or not
    • removeTrusted

      public boolean removeTrusted(UUID uuid)
      Remove a helper (use DBFunc as well)
      Using the * uuid will remove all users
      Parameters:
      uuid - uuid of trusted player to remove
      Returns:
      success or not
    • removeMember

      public boolean removeMember(UUID uuid)
      Remove a trusted user (use DBFunc as well)
      Using the * uuid will remove all users
      Parameters:
      uuid - uuid of player to remove
      Returns:
      success or not
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Gets the plot hashcode
      Note: The hashcode is unique if:
      - Plots are in the same world
      - The x,z coordinates are between Short.MIN_VALUE and Short.MAX_VALUE
      Overrides:
      hashCode in class Object
      Returns:
      integer.
    • getAlias

      public @NonNull String getAlias()
      Gets the plot alias. - Returns an empty string if no alias is set
      Returns:
      The plot alias
    • setAlias

      public void setAlias(String alias)
      Sets the plot alias.
      Parameters:
      alias - The alias
    • setMerged

      public void setMerged(Direction direction, boolean value)
      Sets the raw merge data
      - Updates DB
      - Does not modify terrain
      Parameters:
      direction - direction to merge the plot in
      value - if the plot is merged or not
    • getMerged

      public boolean[] getMerged()
      Gets the merged array.
      Returns:
      boolean [ north, east, south, west ]
    • setMerged

      public void setMerged(boolean[] merged)
      Sets the raw merge data
      - Updates DB
      - Does not modify terrain
      Gets if the plot is merged in a direction
      ----------
      0 = north
      1 = east
      2 = south
      3 = west
      ----------
      Note: Diagonal merging (4-7) must be done by merging the corresponding plots.
      Parameters:
      merged - set the plot's merged plots
    • clearCache

      public void clearCache()
    • getPosition

      public BlockLoc getPosition()
      Gets the set home location or 0,Integer#MIN_VALUE,0 if no location is set
      - Does not take the default home location into account - PlotSquared will internally find the correct place to teleport to if y = Integer#MIN_VALUE when teleporting to the plot.
      Returns:
      home location
    • canClaim

      public boolean canClaim(@NonNull PlotPlayer<?> player)
      Check if a plot can be claimed by the provided player.
      Parameters:
      player - the claiming player
      Returns:
      if the given player can claim the plot
    • mergeData

      public void mergeData(Plot plot)
      Merge the plot settings
      - Used when a plot is merged
      Parameters:
      plot - plot to merge the data from
    • getRelative

      public Plot getRelative(int x, int y)
      Gets the plot in a relative location
      Note: May be null if the partial plot area does not include the relative location
      Parameters:
      x - relative id X
      y - relative id Y
      Returns:
      Plot
    • getRelative

      public Plot getRelative(PlotArea area, int x, int y)
    • getRelative

      public @Nullable Plot getRelative(@NonNull Direction direction)
      Gets the plot in a relative direction Note: May be null if the partial plot area does not include the relative location
      Parameters:
      direction - Direction
      Returns:
      the plot relative to this one
    • getConnectedPlots

      public Set<Plot> getConnectedPlots()
      Gets a set of plots connected (and including) this plot
      - This result is cached globally
      Returns:
      a Set of Plots connected to this Plot
    • getRegions

      public @NonNull Set<com.sk89q.worldedit.regions.CuboidRegion> getRegions()
      This will combine each plot into effective rectangular regions
      - This result is cached globally
      - Useful for handling non rectangular shapes
      Returns:
      all regions within the plot
    • getLargestRegion

      public com.sk89q.worldedit.regions.CuboidRegion getLargestRegion()
      Attempt to find the largest rectangular region in a plot (as plots can form non rectangular shapes)
      Returns:
      the plot's largest CuboidRegion
    • reEnter

      public void reEnter()
      Do the plot entry tasks for each player in the plot
      - Usually called when the plot state changes (unclaimed/claimed/flag change etc)
    • debug

      public void debug(@NonNull String message)
    • teleportPlayer

      public void teleportPlayer(PlotPlayer<?> player, Consumer<Boolean> result)
      Teleport a player to a plot and send them the teleport message.
      Parameters:
      player - the player
      result - Called with the result of the teleportation
    • teleportPlayer

      public void teleportPlayer(PlotPlayer<?> player, TeleportCause cause, Consumer<Boolean> resultConsumer)
      Teleport a player to a plot and send them the teleport message.
      Parameters:
      player - the player
      cause - the cause of the teleport
      resultConsumer - Called with the result of the teleportation
    • isOnline

      public boolean isOnline()
      Checks if the owner of this Plot is online.
      Returns:
      true if the owner of the Plot is online
    • getDistanceFromOrigin

      public int getDistanceFromOrigin()
    • updateWorldBorder

      public void updateWorldBorder()
      Expands the world border to include this plot if it is beyond the current border.
    • mergePlot

      public void mergePlot(Plot lesserPlot, boolean removeRoads, @Nullable QueueCoordinator queue)
      Merges two plots.
      - Assumes plots are directly next to each other
      - saves to DB
      Parameters:
      lesserPlot - the plot to merge into this plot instance
      removeRoads - if roads should be removed during the merge
      queue - Nullable QueueCoordinator. If null, creates own queue and enqueues, otherwise writes to the queue but does not enqueue.
    • isMerged

      public boolean isMerged(@NonNull Direction direction)
      Check if the plot is merged in a given direction
      Parameters:
      direction - Direction
      Returns:
      true if the plot is merged in the given direction
    • getFlag

      public <T> @NonNull T getFlag(@NonNull Class<? extends PlotFlag<T,​?>> flagClass)
      Get the value associated with the specified flag. This will first look at plot specific flag values, then at the containing plot area and its default values and at last, it will look at the default values stored in GlobalFlagContainer.
      Type Parameters:
      T - the flag value type
      Parameters:
      flagClass - The flag type (Class)
      Returns:
      The flag value
    • getFlag

      public <T,​ V extends PlotFlag<T,​ ?>> @NonNull T getFlag(@NonNull V flag)
      Get the value associated with the specified flag. This will first look at plot specific flag values, then at the containing plot area and its default values and at last, it will look at the default values stored in GlobalFlagContainer.
      Type Parameters:
      V - the flag type (Any instance of the flag)
      T - the flag's value type
      Parameters:
      flag - The flag type (Any instance of the flag)
      Returns:
      The flag value
    • format

      public CompletableFuture<Caption> format(Caption iInfo, PlotPlayer<?> player, boolean full)
    • getAverageRatings

      public @org.checkerframework.checker.nullness.qual.NonNull double[] getAverageRatings()
      If rating categories are enabled, get the average rating by category.
      - The index corresponds to the index of the category in the config
      Returns:
      Average ratings in each category
      See Also:
      Rating categories
    • getFlagContainer

      public @NonNull FlagContainer getFlagContainer()
      Get the plot flag container
      Returns:
      Flag container
    • getPlotCommentContainer

      public @NonNull PlotCommentContainer getPlotCommentContainer()
      Get the plot comment container. This can be used to manage and access plot comments
      Returns:
      Plot comment container
    • getPlotModificationManager

      public @NonNull PlotModificationManager getPlotModificationManager()
      Get the plot modification manager
      Returns:
      Plot modification manager