Package cloud.spawnery.agent.api
Class Spawnery
java.lang.Object
cloud.spawnery.agent.api.Spawnery
How a plugin gets a
SpawneryApi, in one line and the same line on
both platforms.
A static holder rather than each platform's service registry. The agent
calls install(cloud.spawnery.agent.api.SpawneryApi) once as it enables; everybody else calls
api().
-
Method Summary
Modifier and TypeMethodDescriptionstatic SpawneryApiapi()The API this server's agent installed.static voidinstall(SpawneryApi api) Installs the implementation.static booleanWhetherapi()would return rather than throw.static voidRemoves the installed API.
-
Method Details
-
api
The API this server's agent installed.- Throws:
SpawneryUnavailableException- if no agent has installed one -- see that type for the two ways that happens.
-
isAvailable
public static boolean isAvailable()Whetherapi()would return rather than throw. -
install
Installs the implementation. Called by the agent and by nothing else.Refuses a second install rather than replacing the first, which would leave plugins holding a handle to a dead agent.
- Throws:
IllegalStateException- if one is already installed
-
uninstall
public static void uninstall()Removes the installed API. For the agent's own shutdown, and for tests.
-