Class RegionContainer

java.lang.Object
com.sk89q.worldguard.protection.regions.RegionContainer

public abstract class RegionContainer extends Object
A region container creates RegionManagers for loaded worlds, which allows access to the region data of a world. Generally, only data is loaded for worlds that are loaded in the server.

This class is thread safe and its contents can be accessed from multiple concurrent threads.

  • Field Details

  • Constructor Details

    • RegionContainer

      public RegionContainer()
  • Method Details

    • initialize

      public void initialize()
      Initialize the region container.
    • unload

      public void unload()
      Save data and unload.
    • getDriver

      public RegionDriver getDriver()
      Get the region store driver.
      Returns:
      the driver
    • reload

      public void reload()
      Reload the region container.

      This method may block until the data for all loaded worlds has been unloaded and new data has been loaded.

    • get

      @Nullable public RegionManager get(com.sk89q.worldedit.world.World world)
      Get the region manager for a world if one exists.

      If you wish to make queries and performance is more important than accuracy, use createQuery() instead.

      This method may return null if region data for the given world has not been loaded, has failed to load, or support for regions has been disabled.

      Parameters:
      world - the world
      Returns:
      a region manager, or null if one is not available
    • getLoaded

      public List<RegionManager> getLoaded()
      Get an immutable list of loaded RegionManagers.
      Returns:
      a list of managers
    • getSaveFailures

      public Set<RegionManager> getSaveFailures()
      Get the a set of region managers that are failing to save.
      Returns:
      a set of region managers
    • createQuery

      public RegionQuery createQuery()
      Create a new region query.
      Returns:
      a new query
    • migrate

      public void migrate(Migration migration) throws MigrationException
      Execute a migration and block any loading of region data during the migration.
      Parameters:
      migration - the migration
      Throws:
      MigrationException - thrown by the migration on error
    • loadWorlds

      protected void loadWorlds()
      Try loading the region managers for all currently loaded worlds.
    • unload

      public void unload(com.sk89q.worldedit.world.World world)
      Unload the region data for a world.
      Parameters:
      world - a world
    • autoMigrate

      protected void autoMigrate()
      Execute auto-migration.
    • load

      @Nullable protected abstract RegionManager load(com.sk89q.worldedit.world.World world)
      Load the region data for a world if it has not been loaded already.
      Parameters:
      world - the world
      Returns:
      a region manager, either returned from the cache or newly loaded