Adding some more methods for economy
Opened this issue ยท 9 comments
Hey,
until now I used Register for all my plugins and what I really liked was the huge amount of methods, the only reason why I am not changing to Vault now.
As I can see, the only way to modify a player's balance is the method withdrawPlayer() (Teach me otherwise if I am wrong).
Could you add methods like add(), subtract(), multiply(), divide() and set() for a player's balance?
That would speed up work a lot!
Oh, thanks :) But you said many economy plugins does not support this
method. So does it work only for a few plugins?
Am Dienstag, 10. Januar 2012 09:05:27 schrieb Nick Minkler:
added hasAccount
Reply to this email directly or view it on GitHub:
#41 (comment)
@Schwarzer-Zylinder - it should work for all of them, though it's only usefull for really checking if you have the correct player name or if the player has never joined the server. Like I said, most economy plugins auto-create an account for the player when they login.
add/subtract are identical to withdraw/deposit. - What's the reasoning for divide/multiple? - you could just get the balance, multiple it and add the difference back or less etc. You don't technically need to multiple directly through the API. And I'm not sure if it would be a good idea, econ plugins don't contain these methods either so you'd have to write the methods for it even if you were linked to them.
Oh, I thought deposit is only for banks.
But a set command would really helpful or a set0 command.
Just like Sleaker stated, you can write your own convenience function with the available methods. Here's your set0() method in semi-pseudo code:
public void set0(String name) {
withdrawPlayer(name, getBalance(name));
}
Of course I could do it myself. But it's easier if the method is written one time in the API, instead of 100 times from each developer. he set method would look like this:
public void set(String name, double newBalance) {
withdrawPlayer(name, getBalance(name) - newBalance);
}
Quite complicating I think.
Just a moment ago I found a lack of a VERY important method: hasAccount()
For now, you can just get an account, and if it doesn't exist, a new one will be created.
I have to work with the balances of offline players, so I can't test, if the player is on the server and every time you type a wrong name, a new account is been created :(