mirror of
https://github.com/MilkBowl/Vault.git
synced 2024-11-10 21:01:03 +01:00
Merge pull request #221 from MjolnirCommando/patch-1
External Multiple Currency Fix for MineConomy v1.4
This commit is contained in:
commit
387f5718a5
@ -23,6 +23,7 @@ import me.mjolnir.mineconomy.MineConomy;
|
|||||||
import me.mjolnir.mineconomy.exceptions.AccountNameConflictException;
|
import me.mjolnir.mineconomy.exceptions.AccountNameConflictException;
|
||||||
import me.mjolnir.mineconomy.exceptions.NoAccountException;
|
import me.mjolnir.mineconomy.exceptions.NoAccountException;
|
||||||
import me.mjolnir.mineconomy.internal.MCCom;
|
import me.mjolnir.mineconomy.internal.MCCom;
|
||||||
|
import me.mjolnir.mineconomy.internal.util.MCFormat;
|
||||||
import net.milkbowl.vault.economy.Economy;
|
import net.milkbowl.vault.economy.Economy;
|
||||||
import net.milkbowl.vault.economy.EconomyResponse;
|
import net.milkbowl.vault.economy.EconomyResponse;
|
||||||
import net.milkbowl.vault.economy.EconomyResponse.ResponseType;
|
import net.milkbowl.vault.economy.EconomyResponse.ResponseType;
|
||||||
@ -95,7 +96,7 @@ public class Economy_MineConomy implements Economy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String format(double amount) {
|
public String format(double amount) {
|
||||||
return String.valueOf(amount);
|
return MCFormat.format(amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String currencyNameSingular() {
|
public String currencyNameSingular() {
|
||||||
@ -109,22 +110,22 @@ public class Economy_MineConomy implements Economy {
|
|||||||
public double getBalance(String playerName) {
|
public double getBalance(String playerName) {
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return MCCom.getBalance(playerName);
|
return MCCom.getExternalBalance(playerName);
|
||||||
}
|
}
|
||||||
catch (NoAccountException e)
|
catch (NoAccountException e)
|
||||||
{
|
{
|
||||||
MCCom.create(playerName);
|
MCCom.create(playerName);
|
||||||
return MCCom.getBalance(playerName);
|
return MCCom.getExternalBalance(playerName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean has(String playerName, double amount) {
|
public boolean has(String playerName, double amount) {
|
||||||
try {
|
try {
|
||||||
return MCCom.canAfford(playerName, amount);
|
return MCCom.canExternalAfford(playerName, amount);
|
||||||
} catch(NoAccountException e) {
|
} catch(NoAccountException e) {
|
||||||
MCCom.create(playerName);
|
MCCom.create(playerName);
|
||||||
return MCCom.canAfford(playerName, amount);
|
return MCCom.canExternalAfford(playerName, amount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -132,10 +133,10 @@ public class Economy_MineConomy implements Economy {
|
|||||||
public EconomyResponse withdrawPlayer(String playerName, double amount) {
|
public EconomyResponse withdrawPlayer(String playerName, double amount) {
|
||||||
double balance;
|
double balance;
|
||||||
try {
|
try {
|
||||||
balance = MCCom.getBalance(playerName);
|
balance = MCCom.getExternalBalance(playerName);
|
||||||
} catch (NoAccountException e) {
|
} catch (NoAccountException e) {
|
||||||
MCCom.create(playerName);
|
MCCom.create(playerName);
|
||||||
balance = MCCom.getBalance(playerName);
|
balance = MCCom.getExternalBalance(playerName);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(amount < 0.0D) {
|
if(amount < 0.0D) {
|
||||||
@ -144,7 +145,7 @@ public class Economy_MineConomy implements Economy {
|
|||||||
|
|
||||||
if(balance >= amount) {
|
if(balance >= amount) {
|
||||||
double finalBalance = balance - amount;
|
double finalBalance = balance - amount;
|
||||||
MCCom.setBalance(playerName, finalBalance);
|
MCCom.setExternalBalance(playerName, finalBalance);
|
||||||
return new EconomyResponse(amount, finalBalance, ResponseType.SUCCESS, null);
|
return new EconomyResponse(amount, finalBalance, ResponseType.SUCCESS, null);
|
||||||
} else {
|
} else {
|
||||||
return new EconomyResponse(0.0D, balance, ResponseType.FAILURE, "Insufficient funds");
|
return new EconomyResponse(0.0D, balance, ResponseType.FAILURE, "Insufficient funds");
|
||||||
@ -155,17 +156,17 @@ public class Economy_MineConomy implements Economy {
|
|||||||
public EconomyResponse depositPlayer(String playerName, double amount) {
|
public EconomyResponse depositPlayer(String playerName, double amount) {
|
||||||
double balance;
|
double balance;
|
||||||
try {
|
try {
|
||||||
balance = MCCom.getBalance(playerName);
|
balance = MCCom.getExternalBalance(playerName);
|
||||||
} catch (NoAccountException e) {
|
} catch (NoAccountException e) {
|
||||||
MCCom.create(playerName);
|
MCCom.create(playerName);
|
||||||
balance = MCCom.getBalance(playerName);
|
balance = MCCom.getExternalBalance(playerName);
|
||||||
}
|
}
|
||||||
if(amount < 0.0D) {
|
if(amount < 0.0D) {
|
||||||
return new EconomyResponse(0.0D, 0.0, ResponseType.FAILURE, "Cannot deposit negative funds");
|
return new EconomyResponse(0.0D, 0.0, ResponseType.FAILURE, "Cannot deposit negative funds");
|
||||||
}
|
}
|
||||||
|
|
||||||
balance += amount;
|
balance += amount;
|
||||||
MCCom.setBalance(playerName, balance);
|
MCCom.setExternalBalance(playerName, balance);
|
||||||
return new EconomyResponse(amount, balance, ResponseType.SUCCESS, null);
|
return new EconomyResponse(amount, balance, ResponseType.SUCCESS, null);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -234,8 +235,8 @@ public class Economy_MineConomy implements Economy {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int fractionalDigits() {
|
public int fractionalDigits() {
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user