Class PlotQuery

java.lang.Object
com.plotsquared.core.util.query.PlotQuery
All Implemented Interfaces:
Iterable<Plot>

public final class PlotQuery extends Object implements Iterable<Plot>
This represents a plot query, and can be used to search for plots matching certain criteria.

The queries can be reused as no results are stored in the query itself

  • Method Details

    • newQuery

      public static PlotQuery newQuery()
      Create a new plot query instance
      Returns:
      New query
    • inArea

      public @NonNull PlotQuery inArea(@NonNull PlotArea area)
      Query for plots in a single area
      Parameters:
      area - Area
      Returns:
      The query instance
    • inWorld

      public @NonNull PlotQuery inWorld(@NonNull String world)
      Query for plots in all areas in a world
      Parameters:
      world - World name
      Returns:
      The query instance
    • inAreas

      public @NonNull PlotQuery inAreas(@NonNull Collection<PlotArea> areas)
      Query for plots in specific areas
      Parameters:
      areas - Plot areas
      Returns:
      The query instance
    • expiredPlots

      public @NonNull PlotQuery expiredPlots()
      Query for expired plots
      Returns:
      The query instance
    • allPlots

      public @NonNull PlotQuery allPlots()
      Query for all plots
      Returns:
      The query instance
    • noPlots

      public @NonNull PlotQuery noPlots()
      Don't query at all
      Returns:
      The query instance
    • plotsBySearch

      public @NonNull PlotQuery plotsBySearch(@NonNull String searchTerm)
      Query for plots based on a search term
      Parameters:
      searchTerm - search term to use (uuid, plotID, username)
      Returns:
      The query instance
    • withPlot

      public @NonNull PlotQuery withPlot(@NonNull Plot plot)
      Query with a pre-defined result
      Parameters:
      plot - to return when Query is searched
      Returns:
      The query instance
    • whereBasePlot

      public @NonNull PlotQuery whereBasePlot()
      Query for base plots only
      Returns:
      The query instance
    • ownedBy

      public @NonNull PlotQuery ownedBy(@NonNull UUID owner)
      Query for plots owned by a specific player
      Parameters:
      owner - Owner UUID
      Returns:
      The query instance
    • ownedBy

      public @NonNull PlotQuery ownedBy(@NonNull PlotPlayer<?> owner)
      Query for plots owned by a specific player
      Parameters:
      owner - Owner
      Returns:
      The query instance
    • ownersInclude

      public @NonNull PlotQuery ownersInclude(@NonNull UUID owner)
      Query for base plots where one of the merged plots is owned by a specific player
      Parameters:
      owner - Owner UUID
      Returns:
      The query instance
      Since:
      6.1.0
    • ownersInclude

      public @NonNull PlotQuery ownersInclude(@NonNull PlotPlayer<?> owner)
      Query for base plots where one of the merged plots is owned by a specific player
      Parameters:
      owner - Owner
      Returns:
      The query instance
      Since:
      6.1.0
    • withAlias

      public @NonNull PlotQuery withAlias(@NonNull String alias)
      Query for plots with a specific alias
      Parameters:
      alias - Plot alias
      Returns:
      The query instance
    • withMember

      public @NonNull PlotQuery withMember(@NonNull UUID member)
      Query for plots with a specific member (added/trusted/owner)
      Parameters:
      member - Member UUID
      Returns:
      The query instance
    • thatPasses

      public @NonNull PlotQuery thatPasses(@NonNull Predicate<Plot> predicate)
      Query for plots that passes a given predicate
      Parameters:
      predicate - Predicate
      Returns:
      The query instance
    • withSortingStrategy

      public @NonNull PlotQuery withSortingStrategy(@NonNull SortingStrategy strategy)
      Specify the sorting strategy that will decide how to sort the results. This only matters if you use asList()
      Parameters:
      strategy - Strategy
      Returns:
      The query instance
    • sorted

      public @NonNull PlotQuery sorted(@NonNull Comparator<Plot> comparator)
      Use a custom comparator to sort the results
      Parameters:
      comparator - Comparator
      Returns:
      The query instance
    • relativeToArea

      public @NonNull PlotQuery relativeToArea(@NonNull PlotArea plotArea)
      Defines the area around which plots may be sorted, depending on the sorting strategy
      Parameters:
      plotArea - Plot area
      Returns:
      The query instance
    • asStream

      public @NonNull Stream<Plot> asStream()
      Get all plots that match the given criteria
      Returns:
      Matching plots
    • asList

      public @NonNull List<Plot> asList()
      Get all plots that match the given criteria
      Returns:
      Matching plots as a mutable
    • asSet

      public @NonNull Set<Plot> asSet()
      Get all plots that match the given criteria
      Returns:
      Matching plots as a mutable set
    • getPaginated

      public @NonNull PaginatedPlotResult getPaginated(int pageSize)
      Get all plots that match the given criteria in the form of a PaginatedPlotResult
      Parameters:
      pageSize - The size of the pages. Must be positive.
      Returns:
      Paginated plot result
    • asCollection

      public @NonNull Collection<Plot> asCollection()
      Get all plots that match the given criteria
      Returns:
      Matching plots as an immutable collection
    • count

      public int count()
      Get the amount of plots contained in the query result
      Returns:
      Result count
    • anyMatch

      public boolean anyMatch()
      Get whether any provided plot matches the given filters. If no plot was provided, false will be returned.
      Returns:
      true if any provided plot matches the filters.
    • iterator

      public @NonNull Iterator<Plot> iterator()
      Specified by:
      iterator in interface Iterable<Plot>