Resource [Released] Treasury - Economy API

Discussion in 'Spigot Plugin Development' started by lokka30, Sep 30, 2021.

  1. Thank you very much for your reply!
    I'm glad to have JitPack as well so long we can automate it along with the other maven repositories. It will definitely not be the primary maven repository though.
     
  2. I'm okay with it not beign the primary one but I'd like it to be one of the repositoryes we use
     
    • Like Like x 1
  3. Hi everyone, it's almost been a week so here's an update on what's going on. :)

    Treasury v1.0.0 is almost complete!

    We are just working on some finishing touches, being:

    At the current stage, you can put Treasury on your server, run it, even start developing with it. Of course, these are currently snapshots so we recommend you wait until the release. A good idea is to start preparing the code in your plugin(s) so that you can easily add in Treasury support.
     
  4. Have you considered using Mockito?
     
    • Agree Agree x 1
  5. I'd rather try make a real-world-like economy provider plugin to test it. It'll be very basic and not usable by server owners.
     
  6. Mockito is something I don't fully understand. I will really appreciate if someone contributes tests, but I'm not going to write anything with it.
     
  7. Hi - I know I've not activily participated in the development of your api, but here's my 2 cents:

    I don't think you need an economy provider plugin in order to test your api. All your abstractions don't use any bukkit types right? so then you could just create an implementation for your api that can just be invoked by junit - it does not need a server environment.
    One thing you do need to take into account is asynchronicity - tests methods do need to wait until economy responses complete. but you can work around that by having your test-economyprovider-implementation only create responses that complete instantly.
    You could ask yourself what you are still testing then at that point.. the api? or the implementation of the api? I kinda get now why Vault doesn't have any tests.
    The economy api only specifies the 'contract'. Implementations ("providers") need to adhere to this. So if you want to have tests, the only useful that I can come up with for testing is that an implementation obeys the the rules of the contract. It doesn't make much sense to 'test' an abstraction layer just on its own.

    What seems way more useful to me is to create a test suite that implementations can use, to test whether they adhere to the rules of the api.
     
    #127 Jannyboy11, Jan 20, 2022
    Last edited: Jan 21, 2022
    • Like Like x 1
    • Agree Agree x 1
  8. I fully agree with this. We have JUnit in the repository because at some point it had a class for which I wanted a test, but that was basically it. Now that class is gone.

    We need to test the plugin part though and if you want to participate, you can download a jar here.
     
  9. You're correct, the API itself does not need any testing. But, as Ivan said, Treasury is also a plugin, so the plugin side of things needs to be tested to ensure it is reliable.
    I think the last thing to test is the /treasury economy migrate command. I would have tested the migration command a few days ago, but it requires at least 2 economy providers to be installed. There are currently have zero in existence :p
    I don't believe there are any issues with the rest of the plugin, from what I was able to gather. Only a few typos with the messages which Ivan kindly fixed.

    I understand that we can use various testing software to test the API. However, I want to create a plugin, 'TestEconomy', which mimics real-world usage of Treasury, of course in a very basic way.
    Not only can this aid in testing Treasury, but it is moreso helpful that it can be used to show how the Treasury API is used. Not in a standard Wiki 'here's a code snippet' way, rather, here is a real plugin with the methods put into practice.
    I will also be able to support all of Treasury's features within this plugin, something I doubt most economy providers will be able to, e.g. transaction history, non-player accounts with members and permissions, and Bukkit transaction events.

    This is completely fine! We are interested in everyone's opinions on various matters, regardless of their past participation.
     
    • Like Like x 1
  10. upload_2022-1-21_10-44-19.png
    This can be done in a custom plugin, and as for the "events", they are not in Vault for performance reasons, because for example various jobs in the plugin send money to the player's account when an action is triggered (in a couple of cases constantly) - this could overload the server with higher usage.

    EDIT:
    upload_2022-1-21_10-46-38.png
    And this functionality can also be created in a custom plugin (admittedly more difficult, but it can be done.)
     
  11. Actually, I think economy events are not in Vault for historical and compatibility reasons. The only reason Vault could gain popularity was because out of the box they support a bunch of different economy providers. Not all of these providers have transaction hooks, so the behaviour of Vault would be ill-defined when running with a plugin without such hooks. Vault's abstraction layer is the 'intersection' of features that economy plugins had at the time, not the 'union'.
    I don't see a performance problem here either. Calling events is cheap. Heck even CraftBukkit itself calls a PlayerMoveEvent every time a player moves (which happens A LOT). It only becomes a performance issue if an event listener does a computation that is not constant-time.
     
    • Like Like x 2
  12. Either way calling the events is a optional api feature, an economy provider may choose not to call them if they don't want to.
     
    • Like Like x 2
  13. Events are an optional feature and since it's the economy provider the one who decides when to call them it can decide to not call them. As said by @Jannyboy11 events aren't that expensive.
    And what do you mean with "This can be done in a custom plugin"? I don't see how a custom plugin solves the problems we are trying to solve
     
  14. Via custom Economy provider & in-game commands / plugin dev. api
     
  15. Amazing project. Finally an (better) alternative to Vault.
    Deluxecombat will definitely support Treasury as an currency provider (for PvP points) and in general (for money rewards on kill etc.)!

    keep it up :)
     
    • Like Like x 2
    • Winner Winner x 1
  16. That would defeat the purpose of having an abstraction layer.
     
    • Agree Agree x 1
  17. Yeah that's sorta what I've been saying this whole time, lol.
     
    • Funny Funny x 1
  18. Haha, ah well, that was pretty easy to set up to say the least. Cheers ;)
     
    • Funny Funny x 1
  19. I have been working on these changes to the API, check that discussion out if you want to view these and feel free to leave any feedback you have. :)