Class BlueMapAPI
This API is thread-save, so you can use it async, off the main-server-thread, to save performance!
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionGetter for the installed BlueMapAPI versionabstract String
Getter for the installed BlueMap versionstatic Optional<BlueMapAPI>
Returns an instance ofBlueMapAPI
if it is currently enabled, else an emptyOptional
is returned.abstract Optional<BlueMapMap>
Getter for aBlueMapMap
loaded by BlueMap with the given id.abstract Collection<BlueMapMap>
getMaps()
Getter for allBlueMapMap
s loaded by BlueMap.abstract Plugin
Getter for thePlugin
abstract RenderManager
Getter for theRenderManager
.abstract WebApp
Getter for theWebApp
.abstract Optional<BlueMapWorld>
Getter for aBlueMapWorld
loaded by BlueMap.abstract Collection<BlueMapWorld>
Getter for allBlueMapWorld
s loaded by BlueMap.static void
onDisable
(Consumer<BlueMapAPI> consumer) Registers aConsumer
that 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)
, ifBlueMapAPI
is not enabled when this listener is registered the consumer will not be called.static void
onEnable
(Consumer<BlueMapAPI> consumer) Registers aConsumer
that will be called every time BlueMap has just been loaded and started and the API is ready to use.
IfBlueMapAPI
is already enabled when this listener is registered the consumer will be called immediately (once, on the same thread)!protected static boolean
registerInstance
(BlueMapAPI instance) Used by BlueMap to register the API and call the listeners properly.protected static boolean
unregisterInstance
(BlueMapAPI instance) Used by BlueMap to unregister the API and call the listeners properly.static boolean
unregisterListener
(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 allBlueMapMap
s loaded by BlueMap.- Returns:
- an unmodifiable collection of all loaded
BlueMapMap
s
-
getWorlds
Getter for allBlueMapWorld
s loaded by BlueMap.- Returns:
- an unmodifiable collection of all loaded
BlueMapWorld
s
-
getWorld
Getter for aBlueMapWorld
loaded 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
Optional
with theBlueMapWorld
if it exists
-
getMap
Getter for aBlueMapMap
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 theBlueMapMap
if 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 ofBlueMapAPI
if it is currently enabled, else an emptyOptional
is returned.- Returns:
- an
Optional
<BlueMapAPI
>
-
onEnable
Registers aConsumer
that will be called every time BlueMap has just been loaded and started and the API is ready to use.
IfBlueMapAPI
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
Consumer
s are guaranteed to be called in the order they were registered in.- Parameters:
consumer
- theConsumer
-
onDisable
Registers aConsumer
that 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)
, ifBlueMapAPI
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
Consumer
s are guaranteed to be called in the order they were registered in.- Parameters:
consumer
- theConsumer
-
unregisterListener
- Parameters:
consumer
- theConsumer
instance that has been registered previously- Returns:
true
if 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:
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
Used by BlueMap to unregister the API and call the listeners properly.- Parameters:
instance
- theBlueMapAPI
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
-