Skip to content
Lachlan edited this page Jun 29, 2023 · 19 revisions

This page is complete and is valid as of Treasury v2.0.0.

What is Treasury?

Simple Explanation

Treasury is a plugin offering a stable form of communication ('API') between plugins on your server, which makes it far easier for plugins using Treasury to interact with each other.

Most commonly, Treasury is used by plugins which interact with your server's economy. For instance, your Shop plugin and Economy plugin may both use Treasury, allowing the Shop plugin to easily talk to your Economy plugin so players can buy and sell items for virtual currency on your server.

Technical Explanation

Treasury is a multi-platform plugin offering a unified suite of APIs for economies, events, services, and more. It aims to be a modern alternative to Vault, offering features such as concurrency support (which is rapidly increasing in importance, especially with technology such as PaperMC's Folia).

Our Mission

Vault has served us all well for a decade now, gathering more than 8 million downloads, and has been the choice for economy plugins. However, its APIs have increasingly become outdated and neglected, due to the stagnant development inflicted by the author's strong conservatism for the project. If you want to propose a change to Vault that breaks a plugin that hasn't been updated for 7 years, forget it.

Treasury was created to try offer a greater alternative to Vault due to the ever growing demands of server owners and plugins to just achieve more with their server, where plugin feature potential is limited by Vault's APIs and compatibility. We are also interested in adding other APIs, such as for land protection, to bring greater integration between the plugins on Minecraft servers.

Treasury receives frequent development and review by its maintainers and various kind contributors from across the community. Our hope is that we can improve the opportunity for all server owners using Treasury in some capacity to improve their server, by allowing plugins which implement it to seamlessly integrate to a greater extent.

If you wish to see our own comparison of Vault against Treasury, please click here.

Who made Treasury possible?

Please view the Credits page to see the list of awesome individuals that made Treasury what it is today.

Major Features

Novice-Friendly

Through creating concise documentation and straightforward designs, we hope to ensure Treasury is accessible by the majority of plugin developers on this platform, just as Vault is.

Multi-Platform

We aim to make Treasury run on different server software. Treasury can currently run on Bukkit servers (CraftBukkit, Spigot, Paper, Purpur, ...), although we aim to expand into offering compatibility with Sponge, Bungee, Velocity and possibly other platforms. The code has been future-proofed via Maven modules and platform-independent classes to make it seamless to do so with no API changes required with each new platform supported.

Improved Concurrency

If you're using Vault with an economy plugin that needs to query a database, your server will freeze whilst it waits for the request to arrive. With Treasury, we use CompletableFutures to make a plugin purposely try if it wanted to lock the main thread.

Multi-Currency

Treasury makes it very simple to create multiple currencies and convert between them. There are is also a utility to parse money amounts (e.g. $2500 as a command argument). The Currency class also contains other information and utilities such as its character (e.g. $) and an amount formatter (e.g. 5.2513516 -> 5 dollars and 25 cents).

Player Accounts

Each player is entitled to their own player account, where they can have balances in multiple different currencies, e.g. Notch has 5 VoteTokens and $200 billion dollars.

UUIDs

Treasury's Economy API utilizes UUIDs instead of player names or the OfflinePlayer class. This provides advantages such as platform independence, name change support, no pointless Mojang profile lookups (which lock the main thread), and being (realistically) impossible for ID duplication to occur, for better stability.

Non-Player Accounts

Like player accounts, non-player accounts can have balances in multiple different currencies. However, non-player accounts are not owned by any sole entity, rather, they can be controlled by any amount of account members.

Each account member has their own set of account permissions allocated to manage what they are allowed to do with the non-player account. For example, Jeff could only have the BALANCE permission so they can view the non-player account's balance, but Jane has all of the account permissions so they can deposit, withdraw, etc.

Note that Treasury does not take any control over account permissions, it only facilitates these features for economy providers and consumers. Thus, it is up to the consumer plugins to ensure a user has adequate permissions to make certain transactions for non-player accounts.

Non-player accounts are very useful for land protection plugins such as Factions and Towny as these can store a pool of money, which can also be controlled by multiple players.

Transactions

Transactions can store information about a specific transaction. An example transaction: the server deposits $50 in Dinnerbone's account due to reaching a new playtime goal. Later on, he withdraws this amount after he buys some iron ingots from the Shop GUI.

Treasury offers Transaction Events which can be optionally made available by the economy provider. If utilized, this allows plugins to spy on transactions and cancel them from happening at their choice. Currently, Transaction Events are only available for the Bukkit implementation of Treasury, but we aim to add this feature for other platforms which also have events.

'Why do we need a Vault competitor?'

The ever-popular question: to that, we have answers! To avoid bloating this post with the answer, please view the Comparison Wiki page where I (@lokka30) explain my own comparison of Treasury against Vault. πŸ˜ƒ

License

The MIT License, which is a very popular choice for open source software like Treasury, bringing many freedoms to those who wish to utilize the resource.

Clone this wiki locally