forked from MilkBowl/VaultAPI
-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/UUID support #6
Merged
creatorfromhell
merged 16 commits into
TheNewEconomy:master
from
LlmDl:feature/uuid_support
Jun 12, 2024
Merged
Feature/UUID support #6
creatorfromhell
merged 16 commits into
TheNewEconomy:master
from
LlmDl:feature/uuid_support
Jun 12, 2024
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This commit adds UUID support to Vault, allowing plugins to bypass the OfflinePlayer methods which result in Bukkit trying to resolve a player to associate with the OfflinePlayer (via the server playercache and if that player doesn't exist via Mojang.) This is incredibly useful for any plugin which wants to have an Economy account that isn't associated with a player. This includes Towny, Factions, Shops plugins and others. Most importantly: having UUID methods will give these plugins an avenue to update from using the String accountName methods deprecated since Vault 1.4, which doesn't result in slow OfflinePlayer creation. AbstractEconomy has been updated so that the various Economy plugins supported internally by Vault will have support for the new methods in the same manner as when the OfflinePlayer methods were added. Small javadoc typos have also been fixed up (extra {'s, an additional {@link, etc.)
These methods are meant for players, non-players and anything with a UUID.
To match the PR I have opened at the Vault repo, which has had the native economy plugin support removed, the VaultAPI plugin no longer requires the AbstractEconomy class. Removal means that this Pull Request no longer calls Bukkit.getOfflinePlayer(uuid), making this much safer.
Add jetbrains annotations & remove mention of specifc economy plugins.
All classes are the same as their v1 selves.
New methods include: - UUID-focused methods replacing the Name and OfflinePlayer methods. - getUUIDNameMap() which makes the economy plugin able to supply a Map of UUIDs and last-known-names on request. This will be used to replace the code in Vault which converts between economy plugins (and is currently only able to convert accounts belonging to players which have logged in.) The @nullable annotation is used here in order to declare that the last-known-name of the account is allowed to be null. - getAccountName(UUID) which will return the last-known-name of an account or null. Other Changes: - Minor changes to javadocs.
Co-authored-by: Morgan <[email protected]>
Co-authored-by: Morgan <[email protected]>
- Added renameAccount(UUID, String). - Remove @nullable annotation and remove repo/dependency from pom.xml. - Fixed typo in javadoc in Economy.
future. Major clean up of javadocs in the Economy class.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
from LlmDl
This is the second incarnation of my efforts to introduce Vault's Economy to UUIDs, and replace the OfflinePlayer used within Vault1's Economy.
For a breakdown of MilkBowl#112:
It has been established that using OfflinePlayers can result in laggy mojang name lookups when a plugin requires the use of FakePlayer Accounts.
Going forward, it makes sense for plugins to be using UUIDs in their databases and hence they should be able to use UUIDs in their economy calls.
With the acceptance of MilkBowl/Vault#863 we will see the end of built-in economy plugins and Vault calling its own now-deprecated API. We have also seen the concerns about EssentialsXEconomy addressed, as they have internalized their Vault support.
As per MilkBowl#112 (comment) this second incarnation has deprecated the contents of the Vault package, with notes making updating simple, and created a Vault2 package. As of yet, EconomyResponse, Chat, and Permission are untouched.
Economy has had a bit of an overhaul. It should still be familiar to anyone updating their Vault1 plugin though.
Most plugins already have something in them that will be using an OfflinePlayers UUID to store and read to/from their DB.
Aside from replacing their OfflinePlayer methods with UUID methods, they will see three new methods missing from my previous PR.
getUUIDNameMap()
getAccountName(UUID)
renameAccount(UUID uuid, String name)
getUUIDNameMap() is a method that they probably already have somewhere in their plugin. When Vault is asked, their plugin will supply a Map keyed to UUIDs of every account they have in their Economy. This will be used in Vault to convert between economies. More details in this commit message.
getAccountName(UUID) is a method that will be indispensable for error messaging and other feedbacks, allowing plugins to avoid using the UUID to get a OfflinePlayer to get the OP's Name.
renameAccount(UUID uuid, String name) is a method that allows a plugin to alter a name associated with an account.
December 2023 edit:
The PR now replaces the usage of doubles with BigDecimal, to better support fool proof math/prevent rounding errors.
The javadocs in the Economy class have had a complete overhaul.
Banks have had their methods UUID-ified and their amounts BigDecimal'd.