mirror of
https://github.com/MilkBowl/Vault.git
synced 2025-01-29 19:41:25 +01:00
Economy.getBalance(...) now returns a final double
This commit is contained in:
parent
4ad44bb1c1
commit
e67ae24658
@ -1,6 +1,6 @@
|
||||
name: Vault
|
||||
main: net.milkbowl.vault.Vault
|
||||
version: 1.0.0dev1
|
||||
version: 1.0.0dev2
|
||||
author: Cereal
|
||||
description: >
|
||||
Abstraction Library for Bukkit Plugins
|
||||
|
@ -23,7 +23,7 @@ public interface Economy {
|
||||
public boolean isEnabled();
|
||||
public String getName();
|
||||
public String format(double amount);
|
||||
public EconomyResponse getBalance(String playerName);
|
||||
public double getBalance(String playerName);
|
||||
public EconomyResponse withdrawPlayer(String playerName, double amount);
|
||||
public EconomyResponse depositPlayer(String playerName, double amount);
|
||||
}
|
@ -76,15 +76,13 @@ public class Economy_3co implements Economy {
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse getBalance(String playerName) {
|
||||
double balance;
|
||||
EconomyResponse.ResponseType type;
|
||||
String errorMessage = null;
|
||||
public double getBalance(String playerName) {
|
||||
final double balance;
|
||||
|
||||
balance = (double) economy.getMoney(plugin.getServer().getPlayer(playerName));
|
||||
type = EconomyResponse.ResponseType.SUCCESS;
|
||||
|
||||
return new EconomyResponse(balance, balance, type, errorMessage);
|
||||
final double fBalance = balance;
|
||||
return fBalance;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -78,15 +78,13 @@ public class Economy_BOSE implements Economy {
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse getBalance(String playerName) {
|
||||
double balance;
|
||||
EconomyResponse.ResponseType type;
|
||||
String errorMessage = null;
|
||||
public double getBalance(String playerName) {
|
||||
final double balance;
|
||||
|
||||
balance = (double) economy.getPlayerMoney(playerName);
|
||||
type = EconomyResponse.ResponseType.SUCCESS;
|
||||
|
||||
return new EconomyResponse(balance, balance, type, errorMessage);
|
||||
final double fBalance = balance;
|
||||
return fBalance;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -79,26 +79,18 @@ public class Economy_Essentials implements Economy {
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse getBalance(String playerName) {
|
||||
public double getBalance(String playerName) {
|
||||
double balance;
|
||||
EconomyResponse.ResponseType type;
|
||||
String errorMessage = null;
|
||||
|
||||
|
||||
try {
|
||||
balance = com.earth2me.essentials.api.Economy.getMoney(playerName);
|
||||
type = EconomyResponse.ResponseType.SUCCESS;
|
||||
} catch (UserDoesNotExistException e) {
|
||||
if(createPlayerAccount(playerName)) {
|
||||
balance = 0;
|
||||
type = EconomyResponse.ResponseType.SUCCESS;
|
||||
} else {
|
||||
balance = 0;
|
||||
type = EconomyResponse.ResponseType.FAILURE;
|
||||
errorMessage = "User does not exist";
|
||||
}
|
||||
createPlayerAccount(playerName);
|
||||
balance = 0;
|
||||
}
|
||||
|
||||
return new EconomyResponse(balance, balance, type, errorMessage);
|
||||
final double fBalance = balance;
|
||||
return fBalance;
|
||||
}
|
||||
|
||||
private boolean createPlayerAccount(String playerName) {
|
||||
|
@ -91,15 +91,13 @@ public class Economy_iConomy4 implements Economy {
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse getBalance(String playerName) {
|
||||
double balance;
|
||||
EconomyResponse.ResponseType type;
|
||||
String errorMessage = null;
|
||||
public double getBalance(String playerName) {
|
||||
final double balance;
|
||||
|
||||
balance = getAccountBalance(playerName);
|
||||
type = EconomyResponse.ResponseType.SUCCESS;
|
||||
|
||||
return new EconomyResponse(balance, balance, type, errorMessage);
|
||||
final double fBalance = balance;
|
||||
return fBalance;
|
||||
}
|
||||
|
||||
private double getAccountBalance(String playerName) {
|
||||
|
@ -84,15 +84,13 @@ public class Economy_iConomy5 implements Economy {
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse getBalance(String playerName) {
|
||||
double balance;
|
||||
EconomyResponse.ResponseType type;
|
||||
String errorMessage = null;
|
||||
public double getBalance(String playerName) {
|
||||
final double balance;
|
||||
|
||||
balance = getAccountBalance(playerName);
|
||||
type = EconomyResponse.ResponseType.SUCCESS;
|
||||
|
||||
return new EconomyResponse(balance, balance, type, errorMessage);
|
||||
final double fBalance = balance;
|
||||
return fBalance;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user