mirror of
https://github.com/MilkBowl/Vault.git
synced 2024-12-29 04:18:08 +01:00
re-enabled mineconomy. it's not recommended to use as it is missing a
LOT of features compared to ico/bose
This commit is contained in:
parent
e24e7e9c52
commit
84bac686c0
@ -230,19 +230,18 @@ public class Vault extends JavaPlugin {
|
||||
|
||||
//Try Loading MineConomy
|
||||
if (packageExists("me.mjolnir.mineconomy.MineConomy")) {
|
||||
// Economy econ = new Economy_MineConomy(this);
|
||||
//sm.register(Economy.class, econ, this, ServicePriority.Normal);
|
||||
//log.info(String.format("[%s][Economy] MineConomy found: %s", getDescription().getName(), econ.isEnabled() ? "Loaded" : "Waiting"));
|
||||
log.info(String.format("[%s][Economy] MineConomy found but is no longer supported!", getDescription().getName()));
|
||||
Economy econ = new Economy_MineConomy(this);
|
||||
sm.register(Economy.class, econ, this, ServicePriority.Normal);
|
||||
log.info(String.format("[%s][Economy] MineConomy found: %s", getDescription().getName(), econ.isEnabled() ? "Loaded" : "Waiting"));
|
||||
}
|
||||
|
||||
|
||||
//Try Loading AEco
|
||||
if (packageExists("org.neocraft.AEco.AEco")) {
|
||||
Economy econ = new Economy_AEco(this);
|
||||
sm.register(Economy.class, econ, this, ServicePriority.Normal);
|
||||
log.info(String.format("[%s][Economy] AEco found: %s", getDescription().getName(), econ.isEnabled() ? "Loaded" : "Waiting"));
|
||||
}
|
||||
|
||||
|
||||
//Try Loading McMoney
|
||||
if (packageExists("boardinggamer.mcmoney.McMoneyAPI")) {
|
||||
Economy econ = new Economy_McMoney(this);
|
||||
|
@ -20,7 +20,9 @@ import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import me.mjolnir.mineconomy.MineConomy;
|
||||
import me.mjolnir.mineconomy.internal.Accounting;
|
||||
import me.mjolnir.mineconomy.exceptions.AccountNameConflictException;
|
||||
import me.mjolnir.mineconomy.exceptions.NoAccountException;
|
||||
import me.mjolnir.mineconomy.internal.MCCom;
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
import net.milkbowl.vault.economy.EconomyResponse;
|
||||
import net.milkbowl.vault.economy.EconomyResponse.ResponseType;
|
||||
@ -84,106 +86,128 @@ public class Economy_MineConomy implements Economy {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return this.econ != null;
|
||||
return econ != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
return "MineConomy";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String format(double amount) {
|
||||
return String.valueOf(amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String currencyNameSingular() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String currencyNamePlural() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBalance(String playerName) {
|
||||
// return Accounting.getBalance(playerName, MineConomy.accounts);
|
||||
return 0.0;
|
||||
try
|
||||
{
|
||||
return MCCom.getBalance(playerName);
|
||||
}
|
||||
catch (NoAccountException e)
|
||||
{
|
||||
MCCom.create(playerName);
|
||||
return MCCom.getBalance(playerName);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean has(String playerName, double amount) {
|
||||
return getBalance(playerName) >= amount;
|
||||
try {
|
||||
return MCCom.canAfford(playerName, amount);
|
||||
} catch(NoAccountException e) {
|
||||
MCCom.create(playerName);
|
||||
return MCCom.canAfford(playerName, amount);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse withdrawPlayer(String playerName, double amount) {
|
||||
double balance = getBalance(playerName);
|
||||
if (amount < 0) {
|
||||
return new EconomyResponse(0, balance, ResponseType.FAILURE, "Cannot withdraw negative funds");
|
||||
} else if (balance >= amount) {
|
||||
double balance;
|
||||
try {
|
||||
balance = MCCom.getBalance(playerName);
|
||||
} catch (NoAccountException e) {
|
||||
MCCom.create(playerName);
|
||||
balance = MCCom.getBalance(playerName);
|
||||
}
|
||||
|
||||
if(amount < 0.0D) {
|
||||
return new EconomyResponse(0.0D, balance, ResponseType.FAILURE, "Cannot withdraw negative funds");
|
||||
}
|
||||
|
||||
if(balance >= amount) {
|
||||
double finalBalance = balance - amount;
|
||||
//Accounting.setBalance(playerName, finalBalance, MineConomy.accounts);
|
||||
MCCom.setBalance(playerName, finalBalance);
|
||||
return new EconomyResponse(amount, finalBalance, ResponseType.SUCCESS, null);
|
||||
} else {
|
||||
return new EconomyResponse(0, balance, ResponseType.FAILURE, "Insufficient funds");
|
||||
return new EconomyResponse(0.0D, balance, ResponseType.FAILURE, "Insufficient funds");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse depositPlayer(String playerName, double amount) {
|
||||
double balance = getBalance(playerName);
|
||||
if (amount < 0) {
|
||||
return new EconomyResponse(0, balance, ResponseType.FAILURE, "Cannot deposit negative funds");
|
||||
} else {
|
||||
balance += amount;
|
||||
//Accounting.setBalance(playerName, balance, MineConomy.accounts);
|
||||
return new EconomyResponse(amount, balance, ResponseType.SUCCESS, null);
|
||||
double balance;
|
||||
try {
|
||||
balance = MCCom.getBalance(playerName);
|
||||
} catch (NoAccountException e) {
|
||||
MCCom.create(playerName);
|
||||
balance = MCCom.getBalance(playerName);
|
||||
}
|
||||
if(amount < 0.0D) {
|
||||
return new EconomyResponse(0.0D, 0.0, ResponseType.FAILURE, "Cannot deposit negative funds");
|
||||
}
|
||||
|
||||
balance += amount;
|
||||
MCCom.setBalance(playerName, balance);
|
||||
return new EconomyResponse(amount, balance, ResponseType.SUCCESS, null);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse createBank(String name, String player) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "MineConomy does not support bank accounts!");
|
||||
return new EconomyResponse(0.0D, 0.0D, ResponseType.NOT_IMPLEMENTED, "MineConomy does not support bank accounts!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse deleteBank(String name) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "MineConomy does not support bank accounts!");
|
||||
return new EconomyResponse(0.0D, 0.0D, ResponseType.NOT_IMPLEMENTED, "MineConomy does not support bank accounts!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankHas(String name, double amount) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "MineConomy does not support bank accounts!");
|
||||
return new EconomyResponse(0.0D, 0.0D, ResponseType.NOT_IMPLEMENTED, "MineConomy does not support bank accounts!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankWithdraw(String name, double amount) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "MineConomy does not support bank accounts!");
|
||||
return new EconomyResponse(0.0D, 0.0D, ResponseType.NOT_IMPLEMENTED, "MineConomy does not support bank accounts!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankDeposit(String name, double amount) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "MineConomy does not support bank accounts!");
|
||||
return new EconomyResponse(0.0D, 0.0D, ResponseType.NOT_IMPLEMENTED, "MineConomy does not support bank accounts!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse isBankOwner(String name, String playerName) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "MineConomy does not support bank accounts!");
|
||||
return new EconomyResponse(0.0D, 0.0D, ResponseType.NOT_IMPLEMENTED, "MineConomy does not support bank accounts!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse isBankMember(String name, String playerName) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "MineConomy does not support bank accounts!");
|
||||
return new EconomyResponse(0.0D, 0.0D, ResponseType.NOT_IMPLEMENTED, "MineConomy does not support bank accounts!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankBalance(String name) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "MineConomy does not support bank accounts!");
|
||||
return new EconomyResponse(0.0D, 0.0D, ResponseType.NOT_IMPLEMENTED, "MineConomy does not support bank accounts!");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -198,16 +222,15 @@ public class Economy_MineConomy implements Economy {
|
||||
|
||||
@Override
|
||||
public boolean hasAccount(String playerName) {
|
||||
// return Accounting.containsKey(playerName, MineConomy.accounts);
|
||||
return true;
|
||||
return MCCom.exists(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createPlayerAccount(String playerName) {
|
||||
if (hasAccount(playerName)) {
|
||||
try {
|
||||
MCCom.create(playerName);
|
||||
return true;
|
||||
} catch(AccountNameConflictException e) {
|
||||
return false;
|
||||
}
|
||||
// Accounting.setBalance(playerName, 0, MineConomy.accounts);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user