Class PlotSquared

java.lang.Object
com.plotsquared.core.PlotSquared

public class PlotSquared extends Object
An implementation of the core, with a static getter for easy access.
  • Field Details

  • Constructor Details

    • PlotSquared

      public PlotSquared(@NonNull PlotPlatform<?> iPlotMain, @NonNull String platform)
      Initialize PlotSquared with the desired Implementation class.
      Parameters:
      iPlotMain - Implementation of PlotPlatform used
      platform - The platform being used
  • Method Details

    • get

      public static @NonNull PlotSquared get()
      Gets an instance of PlotSquared.
      Returns:
      instance of PlotSquared
    • platform

      public static @NonNull PlotPlatform<?> platform()
      Get the platform specific implementation of PlotSquared
      Returns:
      Platform implementation
    • loadCaptionMap

      public void loadCaptionMap() throws Exception
      Throws:
      Exception
    • getPlotAreaManager

      public @NonNull PlotAreaManager getPlotAreaManager()
      Get the platform specific PlotAreaManager instance
      Returns:
      Plot area manager
    • startExpiryTasks

      public void startExpiryTasks()
    • isMainThread

      public boolean isMainThread(@NonNull Thread thread)
    • checkVersion

      public boolean checkVersion(int[] version, int... version2)
      Check if `version` is >= `version2`.
      Parameters:
      version - First version
      version2 - Second version
      Returns:
      true if `version` is >= `version2`
    • getVersion

      public @NonNull PlotVersion getVersion()
      Gets the current PlotSquared version.
      Returns:
      current version in config or null
    • getPlatform

      public @NonNull String getPlatform()
      Gets the server platform this plugin is running on this is running on.

      This will be either Bukkit or Sponge

      Returns:
      the server implementation
    • addPlotArea

      public void addPlotArea(@NonNull PlotArea plotArea)
      Add a global reference to a plot world.
      Parameters:
      plotArea - the PlotArea to add.
      See Also:
      To remove the reference
    • removePlotArea

      public void removePlotArea(@NonNull PlotArea area)
      Remove a plot world reference.
      Parameters:
      area - the PlotArea to remove
    • removePlotAreas

      public void removePlotAreas(@NonNull String world)
    • getClusters

      public Set<PlotCluster> getClusters(@NonNull String world)
    • sortPlotsByTemp

      public List<Plot> sortPlotsByTemp(Collection<Plot> plots)
    • sortPlots

      public @NonNull List<Plot> sortPlots(@NonNull Collection<Plot> plots, @NonNull PlotSquared.SortType type, @Nullable PlotArea priorityArea)
      Sort a collection of plots by world (with a priority world), then by hashcode.
      Parameters:
      plots - the plots to sort
      type - The sorting method to use for each world (timestamp, or hash)
      priorityArea - Use null, "world", or "gibberish" if you want default world order
      Returns:
      ArrayList of plot
    • setPlots

      public void setPlots(@NonNull Map<String,​HashMap<PlotId,​Plot>> plots)
    • removePlot

      public boolean removePlot(@NonNull Plot plot, boolean callEvent)
      Unregisters a plot from local memory without calling the database.
      Parameters:
      plot - the plot to remove
      callEvent - If to call an event about the plot being removed
      Returns:
      true if plot existed | false if it didn't
    • loadWorld

      public void loadWorld(@NonNull String world, @Nullable GeneratorWrapper<?> baseGenerator)
      This method is called by the PlotGenerator class normally.
      • Initializes the PlotArea and PlotManager classes
      • Registers the PlotArea and PlotManager classes
      • Loads (and/or generates) the PlotArea configuration
      • Sets up the world border if configured

      If loading an augmented plot world:

      • Creates the AugmentedPopulator classes
      • Injects the AugmentedPopulator classes if required
      Parameters:
      world - the world to load
      baseGenerator - The generator for that world, or null
    • setupPlotWorld

      public boolean setupPlotWorld(@NonNull String world, @Nullable String args, @NonNull IndependentPlotGenerator generator)
      Setup the configuration for a plot world based on world arguments. e.g. /mv create <world> normal -g PlotSquared:<args>
      Parameters:
      world - The name of the world
      args - The arguments
      generator - the plot generator
      Returns:
      boolean | if valid arguments were provided
    • copyFile

      public void copyFile(@NonNull String file, @NonNull String folder)
      Copies a file from inside the jar to a location
      Parameters:
      file - Name of the file inside PlotSquared.jar
      folder - The output location relative to /plugins/PlotSquared/
    • disable

      public void disable()
      Safely closes the database connection.
    • setupDatabase

      public void setupDatabase()
      Setup the database connection.
    • setupConfig

      public void setupConfig()
      Setup the default configuration.
    • setupConfigs

      public boolean setupConfigs()
      Setup all configuration files
      - Config: settings.yml
      - Storage: storage.yml
      Returns:
      success or not
    • getConfigurationVersion

      public @NonNull String getConfigurationVersion()
    • setConfigurationVersion

      public void setConfigurationVersion(@NonNull String newVersion) throws IOException
      Throws:
      IOException
    • forEachPlotRaw

      public void forEachPlotRaw(@NonNull Consumer<Plot> consumer)
    • isNonStandardGeneration

      public boolean isNonStandardGeneration(@NonNull String world, @NonNull com.sk89q.worldedit.math.BlockVector2 chunkCoordinates)
      Check if the chunk uses vanilla/non-PlotSquared generation
      Parameters:
      world - World name
      chunkCoordinates - Chunk coordinates
      Returns:
      True if the chunk uses non-standard generation, false if not
    • getConfig

      public @NonNull YamlConfiguration getConfig()
    • getImpromptuUUIDPipeline

      public @NonNull UUIDPipeline getImpromptuUUIDPipeline()
    • getBackgroundUUIDPipeline

      public @NonNull UUIDPipeline getBackgroundUUIDPipeline()
    • getWorldEdit

      public @NonNull com.sk89q.worldedit.WorldEdit getWorldEdit()
    • getConfigFile

      public @NonNull File getConfigFile()
    • getWorldsFile

      public @NonNull File getWorldsFile()
    • getWorldConfiguration

      public @NonNull YamlConfiguration getWorldConfiguration()
    • getCaptionMap

      public @NonNull CaptionMap getCaptionMap(@NonNull String namespace)
      Get the caption map belonging to a namespace. If none exists, a dummy caption map will be returned.
      Parameters:
      namespace - Namespace
      Returns:
      Map instance
      See Also:
      To register a caption map
    • registerCaptionMap

      public void registerCaptionMap(@NonNull String namespace, @NonNull CaptionMap captionMap)
      Register a caption map. The namespace needs be equal to the namespace used for the TranslatableCaptions inside the map.
      Parameters:
      namespace - Namespace
      captionMap - Map instance
    • getEventDispatcher

      public @NonNull EventDispatcher getEventDispatcher()
    • getPlotListener

      public @NonNull PlotListener getPlotListener()