mirror of
https://github.com/MilkBowl/Vault.git
synced 2024-11-14 06:36:43 +01:00
Merge branch 'master' of https://Sleaker@github.com/MilkBowl/Vault.git
This commit is contained in:
commit
f6cee62506
BIN
lib/XPBank.jar
Normal file
BIN
lib/XPBank.jar
Normal file
Binary file not shown.
18
pom.xml
18
pom.xml
@ -146,6 +146,13 @@
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/iConomy6.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.gmail.mirelatrue.xpbank.XPBank</groupId>
|
||||
<artifactId>XPBank</artifactId>
|
||||
<version>0.9</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/XPBank.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.D3GN.MiracleM4n.mChat.mChat</groupId>
|
||||
<artifactId>mChat</artifactId>
|
||||
@ -258,6 +265,11 @@
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/CommandsEX.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.omwah</groupId>
|
||||
<artifactId>SDFEconomy</artifactId>
|
||||
<version>0.1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<sourceDirectory>src/</sourceDirectory>
|
||||
@ -339,7 +351,7 @@
|
||||
|
||||
Vault currently Supports:
|
||||
Permissions 3, PEX, GroupManager, bPerms, bPerms2, SimplyPerms, DroxPerms, zPermissions, Starburst
|
||||
iConomy 4,5,6 BOSEconomy 6/7, EssentialsEcon, 3Co, MultiConomy, MineConomy, EconXP, eWallet, CurrencyCore, CraftConomy, AEco
|
||||
iConomy 4,5,6 BOSEconomy 6/7, EssentialsEcon, 3Co, MultiConomy, MineConomy, EconXP, eWallet, CurrencyCore, XPBank, CraftConomy, AEco, SDFEconomy
|
||||
</description>
|
||||
<scm>
|
||||
<url>https://github.com/MilkBowl/Vault</url>
|
||||
@ -359,5 +371,9 @@ iConomy 4,5,6 BOSEconomy 6/7, EssentialsEcon, 3Co, MultiConomy, MineConomy, Econ
|
||||
<id>bukkit-repo</id>
|
||||
<url>http://repo.bukkit.org/content/groups/public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>sdfeconomy-repo</id>
|
||||
<url>http://omwah.sdf.org/maven/repo/snapshots/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
</project>
|
||||
|
@ -52,10 +52,12 @@ import net.milkbowl.vault.economy.plugins.Economy_Gringotts;
|
||||
import net.milkbowl.vault.economy.plugins.Economy_McMoney;
|
||||
import net.milkbowl.vault.economy.plugins.Economy_MineConomy;
|
||||
import net.milkbowl.vault.economy.plugins.Economy_MultiCurrency;
|
||||
import net.milkbowl.vault.economy.plugins.Economy_XPBank;
|
||||
import net.milkbowl.vault.economy.plugins.Economy_eWallet;
|
||||
import net.milkbowl.vault.economy.plugins.Economy_iConomy4;
|
||||
import net.milkbowl.vault.economy.plugins.Economy_iConomy5;
|
||||
import net.milkbowl.vault.economy.plugins.Economy_iConomy6;
|
||||
import net.milkbowl.vault.economy.plugins.Economy_SDFEconomy;
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
import net.milkbowl.vault.permission.plugins.Permission_DroxPerms;
|
||||
import net.milkbowl.vault.permission.plugins.Permission_GroupManager;
|
||||
@ -256,6 +258,12 @@ public class Vault extends JavaPlugin {
|
||||
|
||||
// Try to load CommandsEX Economy
|
||||
hookEconomy("CommandsEX", Economy_CommandsEX.class, ServicePriority.Normal, "com.github.zathrus_writer.commandsex.api.EconomyAPI");
|
||||
|
||||
// Try to load SDFEconomy Economy
|
||||
hookEconomy("SDFEconomy", Economy_SDFEconomy.class, ServicePriority.Normal, "com.github.omwah.SDFEconomy.SDFEconomy");
|
||||
|
||||
// Try to load XPBank
|
||||
hookEconomy("XPBank", Economy_XPBank.class, ServicePriority.Normal, "com.gmail.mirelatrue.xpbank.XPBank");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -550,4 +558,4 @@ public class Vault extends JavaPlugin {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -98,7 +98,7 @@ public interface Economy {
|
||||
*
|
||||
* @param playerName
|
||||
* @param amount
|
||||
* @return
|
||||
* @return True if <b>playerName</b> has <b>amount</b>, False else wise
|
||||
*/
|
||||
public boolean has(String playerName, double amount);
|
||||
|
||||
@ -124,7 +124,7 @@ public interface Economy {
|
||||
* Creates a bank account with the specified name and the player as the owner
|
||||
* @param name
|
||||
* @param player
|
||||
* @return
|
||||
* @return EconomyResponse Object
|
||||
*/
|
||||
public EconomyResponse createBank(String name, String player);
|
||||
|
||||
@ -138,7 +138,7 @@ public interface Economy {
|
||||
/**
|
||||
* Returns the amount the bank has
|
||||
* @param name
|
||||
* @return
|
||||
* @return EconomyResponse Object
|
||||
*/
|
||||
public EconomyResponse bankBalance(String name);
|
||||
|
||||
@ -147,7 +147,7 @@ public interface Economy {
|
||||
*
|
||||
* @param name
|
||||
* @param amount
|
||||
* @return
|
||||
* @return EconomyResponse Object
|
||||
*/
|
||||
public EconomyResponse bankHas(String name, double amount);
|
||||
|
||||
@ -156,7 +156,7 @@ public interface Economy {
|
||||
*
|
||||
* @param name
|
||||
* @param amount
|
||||
* @return
|
||||
* @return EconomyResponse Object
|
||||
*/
|
||||
public EconomyResponse bankWithdraw(String name, double amount);
|
||||
|
||||
@ -165,7 +165,7 @@ public interface Economy {
|
||||
*
|
||||
* @param name
|
||||
* @param amount
|
||||
* @return
|
||||
* @return EconomyResponse Object
|
||||
*/
|
||||
public EconomyResponse bankDeposit(String name, double amount);
|
||||
|
||||
@ -173,7 +173,7 @@ public interface Economy {
|
||||
* Check if a player is the owner of a bank account
|
||||
* @param name
|
||||
* @param playerName
|
||||
* @return
|
||||
* @return EconomyResponse Object
|
||||
*/
|
||||
public EconomyResponse isBankOwner(String name, String playerName);
|
||||
|
||||
@ -181,7 +181,7 @@ public interface Economy {
|
||||
* Check if the player is a member of the bank account
|
||||
* @param name
|
||||
* @param playerName
|
||||
* @return
|
||||
* @return EconomyResponse Object
|
||||
*/
|
||||
public EconomyResponse isBankMember(String name, String playerName);
|
||||
|
||||
|
200
src/net/milkbowl/vault/economy/plugins/Economy_SDFEconomy.java
Normal file
200
src/net/milkbowl/vault/economy/plugins/Economy_SDFEconomy.java
Normal file
@ -0,0 +1,200 @@
|
||||
/* This file is part of Vault.
|
||||
|
||||
Vault is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Vault is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with Vault. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package net.milkbowl.vault.economy.plugins;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.server.PluginDisableEvent;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
|
||||
import com.github.omwah.SDFEconomy.SDFEconomy;
|
||||
import com.github.omwah.SDFEconomy.SDFEconomyAPI;
|
||||
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
import net.milkbowl.vault.economy.EconomyResponse;
|
||||
|
||||
public class Economy_SDFEconomy implements Economy {
|
||||
private static final Logger log = Logger.getLogger("Minecraft");
|
||||
private Plugin plugin = null;
|
||||
|
||||
private final String name = "SDFEconomy";
|
||||
private SDFEconomyAPI api = null;
|
||||
|
||||
public Economy_SDFEconomy(Plugin _plugin) {
|
||||
plugin = _plugin;
|
||||
|
||||
// Register a listener to wait for plugin being loaded
|
||||
plugin.getServer().getPluginManager().registerEvents(new EconomyServerListener(this), plugin);
|
||||
|
||||
// Try and Load API in case plugin was loaded before Vault
|
||||
load_api();
|
||||
}
|
||||
|
||||
public void load_api() {
|
||||
SDFEconomy pluginSDF = (SDFEconomy) plugin.getServer().getPluginManager().getPlugin("SDFEconomy");
|
||||
if(!isEnabled() && pluginSDF != null) {
|
||||
api = pluginSDF.getAPI();
|
||||
log.info(String.format("[%s][Economy] %s hooked.", plugin.getDescription().getName(), name));
|
||||
}
|
||||
}
|
||||
|
||||
public void unload_api() {
|
||||
SDFEconomy pluginSDF = (SDFEconomy) plugin.getServer().getPluginManager().getPlugin("SDFEconomy");
|
||||
if(isEnabled() && pluginSDF != null) {
|
||||
api = null;
|
||||
log.info(String.format("[%s][Economy] %s unhooked.", plugin.getDescription().getName(), name));
|
||||
}
|
||||
}
|
||||
|
||||
public class EconomyServerListener implements Listener {
|
||||
Economy_SDFEconomy economy = null;
|
||||
|
||||
public EconomyServerListener(Economy_SDFEconomy economy) {
|
||||
this.economy = economy;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
if (event.getPlugin().getDescription().getName().equals("SDFEconomy")) {
|
||||
economy.load_api();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginDisable(PluginDisableEvent event) {
|
||||
if (event.getPlugin().getDescription().getName().equals("SDFEconomy")) {
|
||||
economy.unload_api();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return api != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "SDFEconomy";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasBankSupport() {
|
||||
return api.hasBankSupport();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fractionalDigits() {
|
||||
return api.fractionalDigits();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String format(double amount) {
|
||||
return api.format(amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String currencyNamePlural() {
|
||||
return api.currencyNamePlural();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String currencyNameSingular() {
|
||||
return api.currencyNameSingular();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasAccount(String playerName) {
|
||||
return api.hasAccount(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBalance(String playerName) {
|
||||
return api.getBalance(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean has(String playerName, double amount) {
|
||||
return api.has(playerName, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse withdrawPlayer(String playerName, double amount) {
|
||||
return api.withdrawPlayer(playerName, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse depositPlayer(String playerName, double amount) {
|
||||
return api.depositPlayer(playerName, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse createBank(String name, String player) {
|
||||
return api.createBank(name, player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse deleteBank(String name) {
|
||||
return api.deleteBank(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankBalance(String name) {
|
||||
return api.bankBalance(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankHas(String name, double amount) {
|
||||
return api.bankHas(name, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankWithdraw(String name, double amount) {
|
||||
return api.bankWithdraw(name, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankDeposit(String name, double amount) {
|
||||
return api.bankDeposit(name, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse isBankOwner(String name, String playerName) {
|
||||
return api.isBankOwner(name, playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse isBankMember(String name, String playerName) {
|
||||
return api.isBankMember(name, playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getBanks() {
|
||||
return api.getBankNames();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createPlayerAccount(String playerName) {
|
||||
return api.createPlayerAccount(playerName);
|
||||
}
|
||||
|
||||
}
|
294
src/net/milkbowl/vault/economy/plugins/Economy_XPBank.java
Normal file
294
src/net/milkbowl/vault/economy/plugins/Economy_XPBank.java
Normal file
@ -0,0 +1,294 @@
|
||||
/* This file is part of Vault.
|
||||
|
||||
Vault is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Vault is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with Vault. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.milkbowl.vault.economy.plugins;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
import net.milkbowl.vault.economy.EconomyResponse;
|
||||
import net.milkbowl.vault.economy.EconomyResponse.ResponseType;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.server.PluginDisableEvent;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.gmail.mirelatrue.xpbank.XPBank;
|
||||
|
||||
public class Economy_XPBank implements Economy {
|
||||
private static final Logger log = Logger.getLogger("Minecraft");
|
||||
|
||||
private final String name = "XPBank";
|
||||
private Plugin plugin = null;
|
||||
private XPBank XPB = null;
|
||||
|
||||
public Economy_XPBank(Plugin plugin) {
|
||||
this.plugin = plugin;
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new EconomyServerListener(this), plugin);
|
||||
|
||||
// Load Plugin in case it was loaded before
|
||||
if (XPB == null) {
|
||||
Plugin economy = plugin.getServer().getPluginManager().getPlugin("XPBank");
|
||||
if (economy != null && economy.isEnabled()) {
|
||||
XPB = (XPBank) economy;
|
||||
log.info(String.format("[%s][Economy] %s hooked.", plugin.getDescription().getName(), name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class EconomyServerListener implements Listener {
|
||||
Economy_XPBank economy = null;
|
||||
|
||||
public EconomyServerListener(Economy_XPBank economy_XPBank) {
|
||||
this.economy = economy_XPBank;
|
||||
}
|
||||
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
if (economy.XPB == null) {
|
||||
Plugin eco = plugin.getServer().getPluginManager().getPlugin("XPBank");
|
||||
|
||||
if (eco != null && eco.isEnabled()) {
|
||||
economy.XPB = (XPBank) eco;
|
||||
log.info(String.format("[%s][Economy] %s hooked.", plugin.getDescription().getName(), economy.name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginDisable(PluginDisableEvent event) {
|
||||
if (economy.XPB != null) {
|
||||
if (event.getPlugin().getDescription().getName().equals("XPBank")) {
|
||||
economy.XPB = null;
|
||||
log.info(String.format("[%s][Economy] %s unhooked.", plugin.getDescription().getName(), economy.name));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return this.XPB != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String format(double amount) {
|
||||
return String.format("%d %s", (int) amount, XPBank.currencyName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String currencyNamePlural() {
|
||||
return XPBank.currencyName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String currencyNameSingular() {
|
||||
return XPBank.currencyName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBalance(String playerName) {
|
||||
return XPB.getBalance(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean has(String playerName, double amount) {
|
||||
if (XPB.getBalance(playerName) >= (int) amount) { return true; }
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse withdrawPlayer(String playerName, double amount) {
|
||||
if (!XPB.playerExists(playerName)) {
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, "Player doesn't exist");
|
||||
}
|
||||
|
||||
int value = (int) amount;
|
||||
int balance = XPB.getBalance(playerName);
|
||||
|
||||
if (value < 1) {
|
||||
return new EconomyResponse(0, balance, ResponseType.FAILURE, "Amount must be greater than zero");
|
||||
}
|
||||
|
||||
if (value > balance) {
|
||||
return new EconomyResponse(0, balance, ResponseType.FAILURE, String.format("Insufficient %s", XPBank.currencyName));
|
||||
}
|
||||
|
||||
XPB.addToBalance(playerName, -value);
|
||||
|
||||
return new EconomyResponse(value, balance - value, ResponseType.SUCCESS, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse depositPlayer(String playerName, double amount) {
|
||||
if (!XPB.playerExists(playerName)) {
|
||||
// Stupid plugins that use fake players without creating them first...
|
||||
// return new EconomyResponse(0, 0, ResponseType.FAILURE, "Player doesn't exist");
|
||||
this.createPlayerAccount(playerName);
|
||||
}
|
||||
|
||||
int value = (int) amount;
|
||||
int balance = XPB.getBalance(playerName);
|
||||
|
||||
if (value < 1) {
|
||||
return new EconomyResponse(0, balance, ResponseType.FAILURE, "Amount must be greater than zero");
|
||||
}
|
||||
|
||||
XPB.addToBalance(playerName, value);
|
||||
|
||||
return new EconomyResponse(value, balance + value, ResponseType.SUCCESS, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse createBank(String name, String player) {
|
||||
if (XPB.bankExists(name)) {
|
||||
return new EconomyResponse(0, XPB.getBankBalance(name), ResponseType.FAILURE, "That account already exists");
|
||||
}
|
||||
|
||||
Boolean created = XPB.addBank(name);
|
||||
|
||||
if (!created) {
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, "There was an error creating the account");
|
||||
}
|
||||
|
||||
return new EconomyResponse(0, 0, ResponseType.SUCCESS, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse deleteBank(String name) {
|
||||
if (!XPB.bankExists(name)) {
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, "There is no account with that name");
|
||||
}
|
||||
|
||||
Boolean deleted = XPB.deleteBank(name);
|
||||
|
||||
if (!deleted) {
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, "There was an error deleting the account");
|
||||
}
|
||||
|
||||
return new EconomyResponse(0, 0, ResponseType.SUCCESS, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankHas(String name, double amount) {
|
||||
if (!XPB.bankExists(name)) {
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, "There is no account with that name");
|
||||
}
|
||||
|
||||
int balance = XPB.getBankBalance(name);
|
||||
|
||||
if (balance >= (int) amount) {
|
||||
return new EconomyResponse(0, balance, ResponseType.SUCCESS, null);
|
||||
}
|
||||
|
||||
return new EconomyResponse(0, balance, ResponseType.FAILURE, String.format("The account does not have that much %s", XPBank.currencyName));
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankWithdraw(String name, double amount) {
|
||||
if (!XPB.bankExists(name)) {
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, "There is no account with that name");
|
||||
}
|
||||
|
||||
int value = (int) amount;
|
||||
int balance = XPB.getBankBalance(name);
|
||||
|
||||
if (value < 1) {
|
||||
return new EconomyResponse(0, balance, ResponseType.FAILURE, "Amount must be greater than zero");
|
||||
}
|
||||
|
||||
if (value > balance) {
|
||||
return new EconomyResponse(0, balance, ResponseType.FAILURE, String.format("Insufficient %s", XPBank.currencyName));
|
||||
}
|
||||
|
||||
XPB.addToBankBalance(name, -value);
|
||||
|
||||
return new EconomyResponse(value, balance - value, ResponseType.SUCCESS, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankDeposit(String name, double amount) {
|
||||
if (!XPB.bankExists(name)) {
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, "There is no account with that name");
|
||||
}
|
||||
|
||||
int value = (int) amount;
|
||||
int balance = XPB.getBankBalance(name);
|
||||
|
||||
if (value < 1) {
|
||||
return new EconomyResponse(0, balance, ResponseType.FAILURE, "Amount must be greater than zero");
|
||||
}
|
||||
|
||||
XPB.addToBankBalance(name, value);
|
||||
|
||||
return new EconomyResponse(value, balance + value, ResponseType.SUCCESS, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse isBankOwner(String name, String playerName) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "XPBank does not support assigning bank owners");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse isBankMember(String name, String playerName) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "XPBank does not support assigning bank members");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankBalance(String name) {
|
||||
if (!XPB.bankExists(name)) {
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, "There is no account with that name");
|
||||
}
|
||||
|
||||
return new EconomyResponse(0, XPB.getBankBalance(name), ResponseType.SUCCESS, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getBanks() {
|
||||
return XPB.getBanks();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasBankSupport() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasAccount(String playerName) {
|
||||
return XPB.playerExists(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createPlayerAccount(String playerName) {
|
||||
return XPB.addPlayer(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fractionalDigits() {
|
||||
return 0;
|
||||
}
|
||||
}
|
@ -630,7 +630,7 @@ public class Items {
|
||||
* Single item search function, for when we only ever want to return 1 result
|
||||
*
|
||||
* @param searchString
|
||||
* @return
|
||||
* @return ItemInfo Object
|
||||
*/
|
||||
public static ItemInfo itemByName(String searchString) {
|
||||
ItemInfo matchedItem = null;
|
||||
@ -706,7 +706,7 @@ public class Items {
|
||||
* Joins elements of a String array with the glue between them into a String.
|
||||
* @param array
|
||||
* @param glue
|
||||
* @return
|
||||
* @return Concacted Array combined with glue
|
||||
*/
|
||||
public static String join(String[] array, String glue) {
|
||||
String joined = null;
|
||||
@ -729,7 +729,7 @@ public class Items {
|
||||
* Joins elements of a String array with the glue between them into a String.
|
||||
* @param list
|
||||
* @param glue
|
||||
* @return
|
||||
* @return Concacted Array combined with glue
|
||||
*/
|
||||
public static String join(List<String> list, String glue) {
|
||||
String joined = null;
|
||||
|
Loading…
Reference in New Issue
Block a user