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.
This is an experimental draft of an API similar to Sponge (see #2) mixed with the ideas I worked out before. There are a few additions, especially the
Transaction
stuff. It allows to handle money transfer between players/accounts atomically.In the current state, there's not much documentation but if you agree with the overall design, I'll add that too.
TransactionContexts
I'm also not sure about the current usage of the TransactionContexts. From my understandings, that could be used to have e.g. world contexts, but if that's the case there is no way to transfer money from player A world X to player B world Y (?).
If you have any kind of feedback, please let me know (feel free to contact me on discord,
SirYwell#0815
).Edit (2020-10-29)
A few other things I came up with in the last days:
Texts
When e.g. declining a transaction, people likely want to know why. It would help to have some kind of texts provided through the API. This might also apply for something like currency name.
To make this future-proof, we need to allow translatable strings (per player in best case), with support for different text formattings. On Sponge, we could simply use adventure for this, but I'm not sure if we want to force people to implement adventure in their economy plugin.
It also might help to make a TransactionCondition return something similar to the
TransactionResult
. This way, the message why a transaction was declined could be coming directly from that check.Thread safety and asynchrounous transaction execution
Currently, any of transfer/withdraw/deposit directly returns the result. As some implementations might want to handle transactions on a separate thread, it might be better to return a Future instead.