mirror of
https://github.com/MilkBowl/Vault.git
synced 2024-11-27 13:07:23 +01:00
Merge pull request #331 from omwah/sdfeconomy
Add changes necessary for supporting SDFEconomy
This commit is contained in:
commit
e008a6cbc8
11
pom.xml
11
pom.xml
@ -265,6 +265,11 @@
|
|||||||
<scope>system</scope>
|
<scope>system</scope>
|
||||||
<systemPath>${project.basedir}/lib/CommandsEX.jar</systemPath>
|
<systemPath>${project.basedir}/lib/CommandsEX.jar</systemPath>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.omwah</groupId>
|
||||||
|
<artifactId>SDFEconomy</artifactId>
|
||||||
|
<version>0.1.0-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<build>
|
<build>
|
||||||
<sourceDirectory>src/</sourceDirectory>
|
<sourceDirectory>src/</sourceDirectory>
|
||||||
@ -346,7 +351,7 @@
|
|||||||
|
|
||||||
Vault currently Supports:
|
Vault currently Supports:
|
||||||
Permissions 3, PEX, GroupManager, bPerms, bPerms2, SimplyPerms, DroxPerms, zPermissions, Starburst
|
Permissions 3, PEX, GroupManager, bPerms, bPerms2, SimplyPerms, DroxPerms, zPermissions, Starburst
|
||||||
iConomy 4,5,6 BOSEconomy 6/7, EssentialsEcon, 3Co, MultiConomy, MineConomy, EconXP, eWallet, CurrencyCore, XPBank, CraftConomy, AEco
|
iConomy 4,5,6 BOSEconomy 6/7, EssentialsEcon, 3Co, MultiConomy, MineConomy, EconXP, eWallet, CurrencyCore, XPBank, CraftConomy, AEco, SDFEconomy
|
||||||
</description>
|
</description>
|
||||||
<scm>
|
<scm>
|
||||||
<url>https://github.com/MilkBowl/Vault</url>
|
<url>https://github.com/MilkBowl/Vault</url>
|
||||||
@ -366,5 +371,9 @@ iConomy 4,5,6 BOSEconomy 6/7, EssentialsEcon, 3Co, MultiConomy, MineConomy, Econ
|
|||||||
<id>bukkit-repo</id>
|
<id>bukkit-repo</id>
|
||||||
<url>http://repo.bukkit.org/content/groups/public/</url>
|
<url>http://repo.bukkit.org/content/groups/public/</url>
|
||||||
</repository>
|
</repository>
|
||||||
|
<repository>
|
||||||
|
<id>sdfeconomy-repo</id>
|
||||||
|
<url>http://omwah.sdf.org/maven/repo/snapshots/</url>
|
||||||
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
</project>
|
</project>
|
||||||
|
@ -57,6 +57,7 @@ import net.milkbowl.vault.economy.plugins.Economy_eWallet;
|
|||||||
import net.milkbowl.vault.economy.plugins.Economy_iConomy4;
|
import net.milkbowl.vault.economy.plugins.Economy_iConomy4;
|
||||||
import net.milkbowl.vault.economy.plugins.Economy_iConomy5;
|
import net.milkbowl.vault.economy.plugins.Economy_iConomy5;
|
||||||
import net.milkbowl.vault.economy.plugins.Economy_iConomy6;
|
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.Permission;
|
||||||
import net.milkbowl.vault.permission.plugins.Permission_DroxPerms;
|
import net.milkbowl.vault.permission.plugins.Permission_DroxPerms;
|
||||||
import net.milkbowl.vault.permission.plugins.Permission_GroupManager;
|
import net.milkbowl.vault.permission.plugins.Permission_GroupManager;
|
||||||
@ -257,6 +258,9 @@ public class Vault extends JavaPlugin {
|
|||||||
// Try to load CommandsEX Economy
|
// Try to load CommandsEX Economy
|
||||||
hookEconomy("CommandsEX", Economy_CommandsEX.class, ServicePriority.Normal, "com.github.zathrus_writer.commandsex.api.EconomyAPI");
|
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
|
// Try to load XPBank
|
||||||
hookEconomy("XPBank", Economy_XPBank.class, ServicePriority.Normal, "com.gmail.mirelatrue.xpbank.XPBank");
|
hookEconomy("XPBank", Economy_XPBank.class, ServicePriority.Normal, "com.gmail.mirelatrue.xpbank.XPBank");
|
||||||
}
|
}
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user