Skip to content

Treasury Services API

Lachlan edited this page Jun 25, 2023 · 7 revisions

This page is incomplete and invalid as of Treasury v2.0.0.


⚠️ This page has not been updated for Treasury v2 ⚠️

Whilst we're working on updating all the documentation to the new API, please contact us if you have any questions.


Description

The way of retrieving any of the other Treasury API's (at the date of writing, the Treasury Economy API) is the Treasury Service API. It needed to be created because we aim the whole Treasury API to be completely platform independent. It is inspired by Bukkit's service api, but there are some QOL (quality-of-life) differences.

NOTE: The Treasury Service API is not limited to only providing Treasury's APIs, you have a green pass on using it for your custom APIs on platforms which don't provide a service API, or on platforms which do if you really wish to.

Fundamental systems

Treasury's Service API has 2 components which are completely necessary for it to function.

Services

A Service is where from you are going to retrieve instance of a registered class service.

ServiceRegistry

The ServiceRegistry is the way you are going to register/retrieve services.

Sub system: ServicePriority

The ServicePriority is the way of binding a priority to a service. Higher priority means whenever there is a request of the registered service it will be more likely to be provided.

Sub system: Service events

Please see the Events wiki page to understand how Treasury's Events API works.

ServiceRegisteredEvent

The ServiceRegisteredEvent is called whenever a Service has been registered.

ServiceUnregisteredEvent

The ServiceUnregisteredEvent is called whenever a Service has been unregistered.