fix improper formatting on gringotts, and incorrect jdocs. Jdocs are

not to be used in implementing classes as the return values MUST match
what the jdoc/parent class defines.
This commit is contained in:
Sleaker 2012-08-08 20:44:27 -07:00
parent 54252e65a6
commit deefa25dfb

View File

@ -33,7 +33,6 @@ import org.bukkit.plugin.Plugin;
import org.gestern.gringotts.Account; import org.gestern.gringotts.Account;
import org.gestern.gringotts.AccountHolder; import org.gestern.gringotts.AccountHolder;
import org.gestern.gringotts.Gringotts; import org.gestern.gringotts.Gringotts;
import org.gestern.gringotts.PlayerAccountHolder;
public class Economy_Gringotts implements Economy { public class Economy_Gringotts implements Economy {
@ -86,80 +85,42 @@ public class Economy_Gringotts implements Economy {
} }
} }
/** @Override
* Checks if economy method is enabled.
* @return Success or Failure
*/
public boolean isEnabled(){ public boolean isEnabled(){
return gringotts != null && gringotts.isEnabled(); return gringotts != null && gringotts.isEnabled();
} }
/** @Override
* Gets name of permission method
* @return Name of Permission Method
*/
public String getName() { public String getName() {
return name; return name;
} }
/** @Override
* Returns true if the given implementation supports banks.
* @return true if the implementation supports banks
*/
public boolean hasBankSupport(){ public boolean hasBankSupport(){
return false; return false;
} }
/** @Override
* Some economy plugins round off after a certain number of digits.
* This function returns the number of digits the plugin keeps
* or -1 if no rounding occurs.
* @return number of digits after the decimal point kept
*/
public int fractionalDigits(){ public int fractionalDigits(){
return 2; return 2;
} }
/** @Override
* Format amount into a human readable String This provides translation into
* economy specific formatting to improve consistency between plugins.
*
* @param amount
* @return Human readable string describing amount
*/
public String format(double amount) { public String format(double amount) {
// TODO 2-digit formatting
return Double.toString(amount); return Double.toString(amount);
} }
/** @Override
* Returns the name of the currency in plural form.
* If the economy being used does not support currency names then an empty string will be returned.
*
* @return name of the currency (plural)
*/
public String currencyNamePlural(){ public String currencyNamePlural(){
return org.gestern.gringotts.Configuration.config.currencyNamePlural; return org.gestern.gringotts.Configuration.config.currencyNamePlural;
} }
@Override
/**
* Returns the name of the currency in singular form.
* If the economy being used does not support currency names then an empty string will be returned.
*
* @return name of the currency (singular)
*/
public String currencyNameSingular(){ public String currencyNameSingular(){
return org.gestern.gringotts.Configuration.config.currencyNameSingular; return org.gestern.gringotts.Configuration.config.currencyNameSingular;
} }
/** @Override
* Checks if this player or entity has an account on the server yet.
* This will always return true if the player has joined the server at least once
* as all major economy plugins auto-generate a player account when the player joins the server.
* @param playerName
* @return if the player has an account
*/
public boolean hasAccount(String playerName) { public boolean hasAccount(String playerName) {
AccountHolder owner = gringotts.accountHolderFactory.getAccount(playerName); AccountHolder owner = gringotts.accountHolderFactory.getAccount(playerName);
if (owner == null) return false; if (owner == null) return false;
@ -167,12 +128,7 @@ public class Economy_Gringotts implements Economy {
return gringotts.accounting.getAccount(owner) != null; return gringotts.accounting.getAccount(owner) != null;
} }
@Override
/**
* Gets balance of a player
* @param playerName
* @return Amount currently held in players account
*/
public double getBalance(String playerName){ public double getBalance(String playerName){
AccountHolder owner = gringotts.accountHolderFactory.getAccount(playerName); AccountHolder owner = gringotts.accountHolderFactory.getAccount(playerName);
if (owner == null) return 0; if (owner == null) return 0;
@ -180,25 +136,12 @@ public class Economy_Gringotts implements Economy {
return account.balance(); return account.balance();
} }
/** @Override
* Checks if the player account has the amount - DO NOT USE NEGATIVE AMOUNTS
*
* @param playerName
* @param amount
* @return
* @throws UserDoesNotExistException
*/
public boolean has(String playerName, double amount) { public boolean has(String playerName, double amount) {
return getBalance(playerName) >= amount; return getBalance(playerName) >= amount;
} }
/** @Override
* Withdraw an amount from a player - DO NOT USE NEGATIVE AMOUNTS
*
* @param playerName Name of player
* @param amount Amount to withdraw
* @return Detailed response of transaction
*/
public EconomyResponse withdrawPlayer(String playerName, double amount) { public EconomyResponse withdrawPlayer(String playerName, double amount) {
if( amount < 0 ) { if( amount < 0 ) {
@ -221,13 +164,7 @@ public class Economy_Gringotts implements Economy {
} }
/** @Override
* Deposit an amount to a player - DO NOT USE NEGATIVE AMOUNTS
*
* @param playerName Name of player
* @param amount Amount to deposit
* @return Detailed response of transaction
*/
public EconomyResponse depositPlayer(String playerName, double amount){ public EconomyResponse depositPlayer(String playerName, double amount){
if (amount < 0) { if (amount < 0) {
return new EconomyResponse(0, 0, ResponseType.FAILURE, "Cannot desposit negative funds"); return new EconomyResponse(0, 0, ResponseType.FAILURE, "Cannot desposit negative funds");
@ -246,99 +183,52 @@ public class Economy_Gringotts implements Economy {
} }
/** @Override
* Creates a bank account with the specified name and the player as the owner
* @param name
* @param player
* @return
*/
public EconomyResponse createBank(String name, String player) { public EconomyResponse createBank(String name, String player) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "Gringotts does not support bank accounts!"); return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "Gringotts does not support bank accounts!");
} }
/** @Override
* Deletes a bank account with the specified name.
* @param name
* @return if the operation completed successfully
*/
public EconomyResponse deleteBank(String name) { public EconomyResponse deleteBank(String name) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "Gringotts does not support bank accounts!"); return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "Gringotts does not support bank accounts!");
} }
/** @Override
* Returns the amount the bank has
* @param name
* @return
*/
public EconomyResponse bankBalance(String name) { public EconomyResponse bankBalance(String name) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "Gringotts does not support bank accounts!"); return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "Gringotts does not support bank accounts!");
} }
/** @Override
* Returns true or false whether the bank has the amount specified - DO NOT USE NEGATIVE AMOUNTS
*
* @param name
* @param amount
* @return
*/
public EconomyResponse bankHas(String name, double amount) { public EconomyResponse bankHas(String name, double amount) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "Gringotts does not support bank accounts!"); return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "Gringotts does not support bank accounts!");
} }
/** @Override
* Withdraw an amount from a bank account - DO NOT USE NEGATIVE AMOUNTS
*
* @param name
* @param amount
* @return
*/
public EconomyResponse bankWithdraw(String name, double amount) { public EconomyResponse bankWithdraw(String name, double amount) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "Gringotts does not support bank accounts!"); return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "Gringotts does not support bank accounts!");
} }
/** @Override
* Deposit an amount into a bank account - DO NOT USE NEGATIVE AMOUNTS
*
* @param name
* @param amount
* @return
*/
public EconomyResponse bankDeposit(String name, double amount) { public EconomyResponse bankDeposit(String name, double amount) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "Gringotts does not support bank accounts!"); return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "Gringotts does not support bank accounts!");
} }
/** @Override
* Check if a player is the owner of a bank account
* @param name
* @param playerName
* @return
*/
public EconomyResponse isBankOwner(String name, String playerName) { public EconomyResponse isBankOwner(String name, String playerName) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "Gringotts does not support bank accounts!"); return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "Gringotts does not support bank accounts!");
} }
/** @Override
* Check if the player is a member of the bank account
* @param name
* @param playerName
* @return
*/
public EconomyResponse isBankMember(String name, String playerName) { public EconomyResponse isBankMember(String name, String playerName) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "Gringotts does not support bank accounts!"); return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "Gringotts does not support bank accounts!");
} }
/** @Override
* Gets the list of banks
* @return the List of Banks
*/
public List<String> getBanks() { public List<String> getBanks() {
return new ArrayList<String>(); return new ArrayList<String>();
} }
/** @Override
* Attempts to create a player account for the given player
* @return if the account creation was successful
*/
public boolean createPlayerAccount(String playerName) { public boolean createPlayerAccount(String playerName) {
return hasAccount(playerName); return hasAccount(playerName);
} }