Skip to content

Treasury Services API

lokka30 edited this page Feb 17, 2022 · 7 revisions

Page Information

Page Completion Valid as of Notes
🟢 100% v1.1 None

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.