Skip to content
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

Add OfflinePlayer and UUID support to Economy backend #7425

Merged
merged 25 commits into from
Oct 23, 2024

Conversation

Warriorrrr
Copy link
Member

@Warriorrrr Warriorrrr commented May 18, 2024

Description:

Refactors our economy code to pass both the town name & uuid to economy plugins for greater compatibility.

Using some reflection a proper OfflinePlayer is made for each bank account, a v2 uuid is used for non player accounts while select economy implementations are in use to indicate that these should be treated as NPC accounts, but most economy implementations will be sent a v4 uuid.

To avoid breaking stuff on existing servers, the economy provider is put into "legacy" mode using a config migration when upgrading. This will make the plugin continue using the name based methods for vault/reserve. Server admins can use the new /ta eco convert modern command to migrate all balances to the modern provider (recommended to not have any players on the server to avoid transactions during the split second of converting being undone). After conversion, the server will use the "new" methods from then on out.
New servers will automatically use the name & uuid methods, but they can choose to disable the option if they want.

Economy plugins that use the worldName variable will also be a bit more happier with Towny, previously the world that the player is in when the account is created would keep getting passed to vault, and it would not update when switching dimensions. This is now fixed, and the player's world (or first world on the server when offline) is now passed to it.


New Nodes/Commands/ConfigOptions:

Adds a new economy subcommand for the townyadmin command

  • The /ta depositall and resetbanks subcommands have been moved to it.
  • Adds a new convert command that can convert all the existing economy accounts to another economy implementation.

Relevant Towny Issue ticket:

Supersedes #4702


  • I have tested this pull request for defects on a server.

By making this pull request, I represent that I have the right to waive copyright and related rights to my contribution, and agree that all copyright and related rights in my contributions are waived, and I acknowledge that the TownyAdvanced organization has the copyright to use and modify my contribution under the Towny License for perpetuity.

@LlmDl LlmDl changed the title Economy UUID support Economy backend gains OfflinePlayer and UUID support Oct 23, 2024
@Warriorrrr Warriorrrr force-pushed the feat/vault-uuid-redux branch from 0bedfb4 to 949cf01 Compare October 23, 2024 14:43
@LlmDl LlmDl changed the title Economy backend gains OfflinePlayer and UUID support Add OfflinePlayer and UUID support to Economy backend Oct 23, 2024
@LlmDl LlmDl added this to the 0.100.5.0 milestone Oct 23, 2024
@LlmDl LlmDl merged commit 8bd09a4 into master Oct 23, 2024
4 checks passed
@LlmDl LlmDl deleted the feat/vault-uuid-redux branch October 23, 2024 18:35
LlmDl added a commit that referenced this pull request Oct 23, 2024
  - Add OfflinePlayer and UUID support to Economy backend, courtesy of
Warrior with PR #7425.
    - Adds a "modern" economy implementation for Vault and Reserve back
ends, while maintaining "legacy" implementations.
      - Already established servers will have their server set to
legacy, while new installs will begin using the modern system right
away.
    - The modern implementation makes use of Vault's OfflinePlayer
methods, making Towny better suited to newer economy plugins that might
not have fully implemented VaultAPI in their code.
    - Towny's Account class has been revamped with the Towny objects'
UUIDs being used.
    - In cases where a server is using EssentialsX Economy, Towny will
convert our non-player accounts' UUIDs into V2 UUIDs, allowing EssEco to
know they do not belong to players.
  - Changed command: /ta depositall has changed to /ta eco depositall
  - Changed command: /ta resetbanks has changed to /ta eco resetbanks
  - New Command: /ta eco info [TownyObject] {name}
    - Used to see information about a resident, town, nation, or the
Towny serveraccount's economy Account.
  - New Command: /ta eco convert modern
    - Will convert your Towny legacy accounts into modern accounts in
your Economy plugin.
  - New Command: /ta eco convert {economyplugin}
    - Will convert your Towny economy accounts from your existing
economy plugin, into the given economy plugin.
  - New Permission Node: towny.command.townyadmin.eco.*
    - A child node of towny.command.townyadmin.*, no changes required in
your permission plugin.
    - Child Nodes:
      - towny.command.townyadmin.eco.depositall
      - towny.command.townyadmin.eco.resetbanks
      - towny.command.townyadmin.eco.info
      - towny.command.townyadmin.eco.convert
  - New Config Option: economy.advanced.modern
    - Default: true (on existing installs this will default to false)
    - When enabled, Towny will use UUIDs when communicating with your
economy plugin.
    - Most users will never have to touch this, but for existing servers
this option will automatically be set to false.
    - If this option is disabled and you wish to avoid losing data, use
the `/townyadmin eco convert modern` command to convert.
  - New Config Option: economy.advanced.npc_uuid_version
    - Default: -1
    - The UUID version to use for non-player accounts. This is used so
that economy plugins can more easily differentiate between player and
NPC accounts.
    - The default is -1, which disables modifying npc uuids.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants