mirror of
https://github.com/MilkBowl/Vault.git
synced 2025-01-01 05:48:06 +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
|
//Try Loading MineConomy
|
||||||
if (packageExists("me.mjolnir.mineconomy.MineConomy")) {
|
if (packageExists("me.mjolnir.mineconomy.MineConomy")) {
|
||||||
// Economy econ = new Economy_MineConomy(this);
|
Economy econ = new Economy_MineConomy(this);
|
||||||
//sm.register(Economy.class, econ, this, ServicePriority.Normal);
|
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: %s", getDescription().getName(), econ.isEnabled() ? "Loaded" : "Waiting"));
|
||||||
log.info(String.format("[%s][Economy] MineConomy found but is no longer supported!", getDescription().getName()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Try Loading AEco
|
//Try Loading AEco
|
||||||
if (packageExists("org.neocraft.AEco.AEco")) {
|
if (packageExists("org.neocraft.AEco.AEco")) {
|
||||||
Economy econ = new Economy_AEco(this);
|
Economy econ = new Economy_AEco(this);
|
||||||
sm.register(Economy.class, econ, this, ServicePriority.Normal);
|
sm.register(Economy.class, econ, this, ServicePriority.Normal);
|
||||||
log.info(String.format("[%s][Economy] AEco found: %s", getDescription().getName(), econ.isEnabled() ? "Loaded" : "Waiting"));
|
log.info(String.format("[%s][Economy] AEco found: %s", getDescription().getName(), econ.isEnabled() ? "Loaded" : "Waiting"));
|
||||||
}
|
}
|
||||||
|
|
||||||
//Try Loading McMoney
|
//Try Loading McMoney
|
||||||
if (packageExists("boardinggamer.mcmoney.McMoneyAPI")) {
|
if (packageExists("boardinggamer.mcmoney.McMoneyAPI")) {
|
||||||
Economy econ = new Economy_McMoney(this);
|
Economy econ = new Economy_McMoney(this);
|
||||||
|
@ -20,7 +20,9 @@ import java.util.List;
|
|||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import me.mjolnir.mineconomy.MineConomy;
|
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.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;
|
||||||
@ -84,106 +86,128 @@ public class Economy_MineConomy implements Economy {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isEnabled() {
|
public boolean isEnabled() {
|
||||||
return this.econ != null;
|
return econ != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return "MineConomy";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String format(double amount) {
|
public String format(double amount) {
|
||||||
return String.valueOf(amount);
|
return String.valueOf(amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String currencyNameSingular() {
|
public String currencyNameSingular() {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String currencyNamePlural() {
|
public String currencyNamePlural() {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public double getBalance(String playerName) {
|
public double getBalance(String playerName) {
|
||||||
// return Accounting.getBalance(playerName, MineConomy.accounts);
|
try
|
||||||
return 0.0;
|
{
|
||||||
|
return MCCom.getBalance(playerName);
|
||||||
|
}
|
||||||
|
catch (NoAccountException e)
|
||||||
|
{
|
||||||
|
MCCom.create(playerName);
|
||||||
|
return MCCom.getBalance(playerName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean has(String playerName, double amount) {
|
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
|
@Override
|
||||||
public EconomyResponse withdrawPlayer(String playerName, double amount) {
|
public EconomyResponse withdrawPlayer(String playerName, double amount) {
|
||||||
double balance = getBalance(playerName);
|
double balance;
|
||||||
if (amount < 0) {
|
try {
|
||||||
return new EconomyResponse(0, balance, ResponseType.FAILURE, "Cannot withdraw negative funds");
|
balance = MCCom.getBalance(playerName);
|
||||||
} else if (balance >= amount) {
|
} 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;
|
double finalBalance = balance - amount;
|
||||||
//Accounting.setBalance(playerName, finalBalance, MineConomy.accounts);
|
MCCom.setBalance(playerName, finalBalance);
|
||||||
return new EconomyResponse(amount, finalBalance, ResponseType.SUCCESS, null);
|
return new EconomyResponse(amount, finalBalance, ResponseType.SUCCESS, null);
|
||||||
} else {
|
} else {
|
||||||
return new EconomyResponse(0, balance, ResponseType.FAILURE, "Insufficient funds");
|
return new EconomyResponse(0.0D, balance, ResponseType.FAILURE, "Insufficient funds");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EconomyResponse depositPlayer(String playerName, double amount) {
|
public EconomyResponse depositPlayer(String playerName, double amount) {
|
||||||
double balance = getBalance(playerName);
|
double balance;
|
||||||
if (amount < 0) {
|
try {
|
||||||
return new EconomyResponse(0, balance, ResponseType.FAILURE, "Cannot deposit negative funds");
|
balance = MCCom.getBalance(playerName);
|
||||||
} else {
|
} catch (NoAccountException e) {
|
||||||
balance += amount;
|
MCCom.create(playerName);
|
||||||
//Accounting.setBalance(playerName, balance, MineConomy.accounts);
|
balance = MCCom.getBalance(playerName);
|
||||||
return new EconomyResponse(amount, balance, ResponseType.SUCCESS, null);
|
|
||||||
}
|
}
|
||||||
|
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
|
@Override
|
||||||
public EconomyResponse createBank(String name, String player) {
|
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
|
@Override
|
||||||
public EconomyResponse deleteBank(String name) {
|
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
|
@Override
|
||||||
public EconomyResponse bankHas(String name, double amount) {
|
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
|
@Override
|
||||||
public EconomyResponse bankWithdraw(String name, double amount) {
|
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
|
@Override
|
||||||
public EconomyResponse bankDeposit(String name, double amount) {
|
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
|
@Override
|
||||||
public EconomyResponse isBankOwner(String name, String playerName) {
|
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
|
@Override
|
||||||
public EconomyResponse isBankMember(String name, String playerName) {
|
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
|
@Override
|
||||||
public EconomyResponse bankBalance(String name) {
|
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
|
@Override
|
||||||
@ -198,16 +222,15 @@ public class Economy_MineConomy implements Economy {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasAccount(String playerName) {
|
public boolean hasAccount(String playerName) {
|
||||||
// return Accounting.containsKey(playerName, MineConomy.accounts);
|
return MCCom.exists(playerName);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean createPlayerAccount(String playerName) {
|
public boolean createPlayerAccount(String playerName) {
|
||||||
if (hasAccount(playerName)) {
|
try {
|
||||||
|
MCCom.create(playerName);
|
||||||
|
return true;
|
||||||
|
} catch(AccountNameConflictException e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Accounting.setBalance(playerName, 0, MineConomy.accounts);
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user