Class BlueMapAPI

java.lang.Object
de.bluecolored.bluemap.api.BlueMapAPI

public abstract class BlueMapAPI extends Object
An API to control the running instance of BlueMap.

This API is thread-save, so you can use it async, off the main-server-thread, to save performance!

  • Constructor Details

    • BlueMapAPI

      public BlueMapAPI()
  • Method Details

    • getRenderManager

      public abstract RenderManager getRenderManager()
      Getter for the RenderManager.
      Returns:
      the RenderManager
    • getWebApp

      public abstract WebApp getWebApp()
      Getter for the WebApp.
      Returns:
      the WebApp
    • getPlugin

      public abstract Plugin getPlugin()
      Getter for the Plugin
      Returns:
      the Plugin
    • getMaps

      public abstract Collection<BlueMapMap> getMaps()
      Getter for all BlueMapMaps loaded by BlueMap.
      Returns:
      an unmodifiable collection of all loaded BlueMapMaps
    • getWorlds

      public abstract Collection<BlueMapWorld> getWorlds()
      Getter for all BlueMapWorlds loaded by BlueMap.
      Returns:
      an unmodifiable collection of all loaded BlueMapWorlds
    • getWorld

      public abstract Optional<BlueMapWorld> getWorld(Object world)
      Getter for a BlueMapWorld loaded by BlueMap.
      Parameters:
      world - Any object that BlueMap can use to identify a world.
      This could be:
      • A String that is the id of the world
      • A Path that is the path to the world-folder
      • A Resource-Key object, UUID or anything that your platform uses to identify worlds
      • The actual world-object, any object directly representing the a world on your platform
      ("Platform" here stands for the mod/plugin-loader or server-implementation you are using, e.g. Spigot, Forge, Fabric or Sponge)
      Returns:
      an Optional with the BlueMapWorld if it exists
    • getMap

      public abstract Optional<BlueMapMap> getMap(String id)
      Getter for a BlueMapMap loaded by BlueMap with the given id.
      Parameters:
      id - the map id (equivalent to the id configured in BlueMap's config
      Returns:
      an Optional with the BlueMapMap if it exists
    • getBlueMapVersion

      public abstract String getBlueMapVersion()
      Getter for the installed BlueMap version
      Returns:
      the version-string
    • getAPIVersion

      public String getAPIVersion()
      Getter for the installed BlueMapAPI version
      Returns:
      the version-string
    • getInstance

      public static Optional<BlueMapAPI> getInstance()
      Returns an instance of BlueMapAPI if it is currently enabled, else an empty Optional is returned.
      Returns:
      an Optional<BlueMapAPI>
    • onEnable

      public static void onEnable(Consumer<BlueMapAPI> consumer)
      Registers a Consumer that will be called every time BlueMap has just been loaded and started and the API is ready to use.
      If BlueMapAPI is already enabled when this listener is registered the consumer will be called immediately (once, on the same thread)!

      The Consumer can be called multiple times if BlueMap disables and enables again, e.g. if BlueMap gets reloaded!

      (Note: The consumer will likely be called asynchronously, not on the server-thread!)

      Remember to unregister the consumer when you no longer need it using unregisterListener(Consumer).

      The Consumers are guaranteed to be called in the order they were registered in.

      Parameters:
      consumer - the Consumer
    • onDisable

      public static void onDisable(Consumer<BlueMapAPI> consumer)
      Registers a Consumer that will be called every time before BlueMap is being unloaded and stopped, after the consumer returns the API is no longer usable!
      Unlike with onEnable(Consumer), if BlueMapAPI is not enabled when this listener is registered the consumer will not be called.

      The Consumer can be called multiple times if BlueMap disables and enables again, e.g. if BlueMap gets reloaded!

      (Note: The consumer will likely be called asynchronously, not on the server-thread!)

      Remember to unregister the consumer when you no longer need it using unregisterListener(Consumer).

      The Consumers are guaranteed to be called in the order they were registered in.

      Parameters:
      consumer - the Consumer
    • unregisterListener

      public static boolean unregisterListener(Consumer<BlueMapAPI> consumer)
      Removes a Consumer that has been registered using onEnable(Consumer) or onDisable(Consumer).
      Parameters:
      consumer - the Consumer instance that has been registered previously
      Returns:
      true if a listener was removed as a result of this call
    • registerInstance

      protected static boolean registerInstance(BlueMapAPI instance) throws ExecutionException
      Used by BlueMap to register the API and call the listeners properly.
      Parameters:
      instance - the BlueMapAPI-instance
      Returns:
      true if the instance has been registered, false if there already was an instance registered
      Throws:
      ExecutionException - if a listener threw an exception during the registration
    • unregisterInstance

      protected static boolean unregisterInstance(BlueMapAPI instance) throws ExecutionException
      Used by BlueMap to unregister the API and call the listeners properly.
      Parameters:
      instance - the BlueMapAPI instance
      Returns:
      true if the instance was unregistered, false if there was no or an other instance registered
      Throws:
      ExecutionException - if a listener threw an exception during the un-registration