MilkBowl / VaultAPI

API Component of Vault
GNU Lesser General Public License v3.0
274 stars 108 forks source link

EconomyResponse boolean representation #124

Closed lokka30 closed 2 years ago

lokka30 commented 2 years ago

Hey, question here:

How do we respond with a boolean representation of the EconomyResponse object in Economy#bankHas?

Currently I assume we use FAILURE and SUCCESS response types but I feel quite uncomfortable using those since it doesn't seem to be the intended use. Is there any standard?

if(balance >= val) {
    return new EconomyResponse(val, balance, EconomyResponse.ResponseType.SUCCESS, "N/A");
} else {
    return new EconomyResponse(val, balance, EconomyResponse.ResponseType.FAILURE, "N/A");
}

Also, a little side question - what standard is in place of what to use for the errorMessage in EconomyResponse if the operation is successful? Can we use null Strings?

lokka30 commented 2 years ago

This also branches into a suggestion - the javadocs need some upgrading. I can work on it if wanted, but communicating through GH issues might make that too difficult.

Sleaker commented 2 years ago

@lokka30 Vault is an API, that means the implementation is left up to the economy itself. Some economies don't implement all features, that means they need some way to communicate that the support isn't there if a call is made to a method that won't do the intended thing.

The docs describe what you're questioning: https://github.com/MilkBowl/VaultAPI/blob/af58e675c37ff9bd3a219e48571065845bcb8806/src/main/java/net/milkbowl/vault/economy/EconomyResponse.java#L68