Class BlueMapAPI
This API is thread-save, so you can use it async, off the main-server-thread, to save performance!
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGetter for the installed BlueMapAPI versionabstract StringGetter for the installed BlueMap versionstatic Optional<BlueMapAPI>Returns an instance ofBlueMapAPIif it is currently enabled, else an emptyOptionalis returned.abstract Optional<BlueMapMap>Getter for aBlueMapMaploaded by BlueMap with the given id.abstract Collection<BlueMapMap>getMaps()Getter for allBlueMapMaps loaded by BlueMap.abstract PluginGetter for thePluginabstract RenderManagerGetter for theRenderManager.abstract WebAppGetter for theWebApp.abstract Optional<BlueMapWorld>Getter for aBlueMapWorldloaded by BlueMap.abstract Collection<BlueMapWorld>Getter for allBlueMapWorlds loaded by BlueMap.static voidonDisable(Consumer<BlueMapAPI> consumer) Registers aConsumerthat will be called every time before BlueMap is being unloaded and stopped, after the consumer returns the API is no longer usable!
Unlike withonEnable(Consumer), ifBlueMapAPIis not enabled when this listener is registered the consumer will not be called.static voidonEnable(Consumer<BlueMapAPI> consumer) Registers aConsumerthat will be called every time BlueMap has just been loaded and started and the API is ready to use.
IfBlueMapAPIis already enabled when this listener is registered the consumer will be called immediately (once, on the same thread)!protected static booleanregisterInstance(BlueMapAPI instance) Used by BlueMap to register the API and call the listeners properly.protected static booleanunregisterInstance(BlueMapAPI instance) Used by BlueMap to unregister the API and call the listeners properly.static booleanunregisterListener(Consumer<BlueMapAPI> consumer)
-
Constructor Details
-
BlueMapAPI
public BlueMapAPI()
-
-
Method Details
-
getRenderManager
Getter for theRenderManager.- Returns:
- the
RenderManager
-
getWebApp
Getter for theWebApp.- Returns:
- the
WebApp
-
getPlugin
Getter for thePlugin- Returns:
- the
Plugin
-
getMaps
Getter for allBlueMapMaps loaded by BlueMap.- Returns:
- an unmodifiable collection of all loaded
BlueMapMaps
-
getWorlds
Getter for allBlueMapWorlds loaded by BlueMap.- Returns:
- an unmodifiable collection of all loaded
BlueMapWorlds
-
getWorld
Getter for aBlueMapWorldloaded by BlueMap.- Parameters:
world- Any object that BlueMap can use to identify a world.
This could be: ("Platform" here stands for the mod/plugin-loader or server-implementation you are using, e.g. Spigot, Forge, Fabric or Sponge)- Returns:
- an
Optionalwith theBlueMapWorldif it exists
-
getMap
Getter for aBlueMapMaploaded by BlueMap with the given id.- Parameters:
id- the map id (equivalent to the id configured in BlueMap's config- Returns:
- an
Optionalwith theBlueMapMapif it exists
-
getBlueMapVersion
Getter for the installed BlueMap version- Returns:
- the version-string
-
getAPIVersion
Getter for the installed BlueMapAPI version- Returns:
- the version-string
-
getInstance
Returns an instance ofBlueMapAPIif it is currently enabled, else an emptyOptionalis returned.- Returns:
- an
Optional<BlueMapAPI>
-
onEnable
Registers aConsumerthat will be called every time BlueMap has just been loaded and started and the API is ready to use.
IfBlueMapAPIis already enabled when this listener is registered the consumer will be called immediately (once, on the same thread)!The
Consumercan 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- theConsumer
-
onDisable
Registers aConsumerthat will be called every time before BlueMap is being unloaded and stopped, after the consumer returns the API is no longer usable!
Unlike withonEnable(Consumer), ifBlueMapAPIis not enabled when this listener is registered the consumer will not be called.The
Consumercan 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- theConsumer
-
unregisterListener
- Parameters:
consumer- theConsumerinstance that has been registered previously- Returns:
trueif a listener was removed as a result of this call
-
registerInstance
Used by BlueMap to register the API and call the listeners properly.- Parameters:
instance- theBlueMapAPI-instance- Returns:
trueif the instance has been registered,falseif there already was an instance registered- Throws:
ExecutionException- if a listener threw an exception during the registration
-
unregisterInstance
Used by BlueMap to unregister the API and call the listeners properly.- Parameters:
instance- theBlueMapAPIinstance- Returns:
trueif the instance was unregistered,falseif there was no or an other instance registered- Throws:
ExecutionException- if a listener threw an exception during the un-registration
-