Updated Gringotts compatibilty

Gringotts now supports storing fractional values, this commit updates
the vault integration to reflect those changes.
This commit is contained in:
Harry Jeffery 2012-08-03 16:46:07 +01:00
parent 0b75bcc019
commit 91b09ff41e
2 changed files with 9 additions and 8 deletions

Binary file not shown.

View File

@ -165,11 +165,14 @@ public class Economy_Gringotts implements Economy {
public boolean hasAccount(String playerName) { public boolean hasAccount(String playerName) {
try{ try{
Account account = gringotts.accounting.getAccount(new PlayerAccountHolder(playerName)); Account account = gringotts.accounting.getAccount(new PlayerAccountHolder(playerName));
if(account != null)
return true;
else
return false;
} }
catch (Exception e){ catch (Exception e){
return false; return false;
} }
return true;
} }
@ -214,7 +217,7 @@ public class Economy_Gringotts implements Economy {
if(account.balance() >= amount) { if(account.balance() >= amount) {
//We has mulah! //We has mulah!
account.remove((long)amount); account.remove(amount);
return new EconomyResponse(amount, account.balance(), ResponseType.SUCCESS, null); return new EconomyResponse(amount, account.balance(), ResponseType.SUCCESS, null);
} else { } else {
//Not enough money to withdraw this much. //Not enough money to withdraw this much.
@ -238,13 +241,11 @@ public class Economy_Gringotts implements Economy {
PlayerAccountHolder accountHolder = new PlayerAccountHolder(playerName); PlayerAccountHolder accountHolder = new PlayerAccountHolder(playerName);
Account account = gringotts.accounting.getAccount( accountHolder ); Account account = gringotts.accounting.getAccount( accountHolder );
long change = (long)account.add((long) amount); if (account.add(amount))
return new EconomyResponse( amount, account.balance(), ResponseType.SUCCESS, null);
else
return new EconomyResponse( 0, account.balance(), ResponseType.FAILURE, "Not enough capacity to store that many funds!");
if( change == amount ) {
return new EconomyResponse( change, account.balance(), ResponseType.SUCCESS, null);
} else {
return new EconomyResponse( change, account.balance(), ResponseType.FAILURE, "Not enough capacity to store that many funds!");
}
} }
/** /**