This commit is contained in:
Kailan (TheKomputerKing) Blanks 2014-02-05 17:48:43 +00:00
commit 0afc6f3302
3 changed files with 254 additions and 0 deletions

View File

@ -69,6 +69,9 @@ Vault currently supports the following: Permissions 3, PEX, GroupManager, bPerms
<id>escapecraft-repo</id>
<url>http://dev.escapecraft.com/maven</url>
</repository>
<id>thekomputerking-repo</id>
<url>http://cloud.kompking.info/repo</url>
+ </repository>
</repositories>
<dependencies>
@ -84,6 +87,11 @@ Vault currently supports the following: Permissions 3, PEX, GroupManager, bPerms
<scope>system</scope>
<systemPath>${project.basedir}/lib/MiConomy.jar</systemPath>
</dependency>
<dependency>
<groupId>net.komputerking</groupId>
<artifactId>CleanConomy</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>de.hydrox.bukkit</groupId>
<artifactId>DroxPerms</artifactId>

View File

@ -45,6 +45,7 @@ import net.milkbowl.vault.economy.plugins.Economy_BOSE6;
import net.milkbowl.vault.economy.plugins.Economy_BOSE7;
import net.milkbowl.vault.economy.plugins.Economy_CommandsEX;
import net.milkbowl.vault.economy.plugins.Economy_Craftconomy;
import net.milkbowl.vault.economy.plugins.Economy_CleanConomy;
import net.milkbowl.vault.economy.plugins.Economy_Craftconomy3;
import net.milkbowl.vault.economy.plugins.Economy_CurrencyCore;
import net.milkbowl.vault.economy.plugins.Economy_DigiCoin;
@ -274,6 +275,9 @@ public class Vault extends JavaPlugin {
// Try to load Craftconomy3
hookEconomy("CraftConomy3", Economy_Craftconomy3.class, ServicePriority.Normal, "com.greatmancode.craftconomy3.tools.interfaces.BukkitLoader");
// Try to load CleanConomy
hookEconomy("CleanConomy", Economy_CleanConomy.class, ServicePriority.Normal, "net.komputerking.cleanconomy.CleanConomy");
// Try to load eWallet
hookEconomy("eWallet", Economy_eWallet.class, ServicePriority.Normal, "me.ethan.eWallet.ECO");

View File

@ -0,0 +1,242 @@
/* 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 java.util.ArrayList;
import net.komputerking.cleanconomy.CleanConomy;
public class Economy_CleanConomy implements Economy {
private static final Logger log = Logger.getLogger("Minecraft");
private final String name = "CleanConomy";
private Plugin plugin = null;
private CleanConomy con = null;
public Economy_CleanConomy(Plugin plugin) {
this.plugin = plugin;
Bukkit.getServer().getPluginManager().registerEvents(new EconomyServerListener(this), plugin);
// Load Plugin in case it was loaded before
if (con == null) {
Plugin cleanconomy = plugin.getServer().getPluginManager().getPlugin("CleanConomy");
if (cleanconomy != null && cleanconomy.isEnabled()) {
con = (CleanConomy) cleanconomy;
log.info(String.format("[%s][Economy] %s hooked.", plugin.getDescription().getName(), name));
}
}
}
@Override
public boolean isEnabled() {
if (con == null) {
return false;
} else {
return con.isEnabled();
}
}
@Override
public String getName() {
return name;
}
@Override
public double getBalance(String playerName) {
return con.getBalance(playerName);
}
@Override
public boolean createPlayerAccount(String playerName) {
if (hasAccount(playerName)) {
return false;
}
con.createPlayerAccount(playerName);
return true;
}
@Override
public EconomyResponse withdrawPlayer(String playerName, double amount) {
String s = con.withdraw(playerName, (int) amount, "");
if (s.startsWith("FAIL|")){
return new EconomyResponse(amount, getBalance(playerName), ResponseType.FAILURE, s.substring(6));
}
return new EconomyResponse(amount, getBalance(playerName), ResponseType.SUCCESS, s.substring(9));
}
@Override
public EconomyResponse depositPlayer(String playerName, double amount) {
String s = con.deposit(playerName, (int) amount, "");
if (s.startsWith("FAIL|")){
return new EconomyResponse(amount, getBalance(playerName), ResponseType.FAILURE, s.substring(6));
}
return new EconomyResponse(amount, getBalance(playerName), ResponseType.SUCCESS, s.substring(9));
}
public class EconomyServerListener implements Listener {
Economy_CleanConomy economy = null;
public EconomyServerListener(Economy_CleanConomy economy) {
this.economy = economy;
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginEnable(PluginEnableEvent event) {
if (economy.con == null) {
Plugin cleanconomy = event.getPlugin();
if (cleanconomy.getDescription().getName().equals("CleanConomy")) {
economy.con = (CleanConomy) cleanconomy;
log.info(String.format("[%s][Economy] %s hooked.", plugin.getDescription().getName(), economy.name));
}
}
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginDisable(PluginDisableEvent event) {
if (economy.con != null) {
if (event.getPlugin().getDescription().getName().equals("CleanConomy")) {
economy.con = null;
log.info(String.format("[%s][Economy] %s unhooked.", plugin.getDescription().getName(), economy.name));
}
}
}
}
@Override
public String format(double amount) {
return "" + (int) amount;
}
@Override
public String currencyNameSingular() {
return "";
}
@Override
public String currencyNamePlural() {
return "";
}
@Override
public boolean has(String playerName, double amount) {
return con.has(playerName, (int) amount);
}
@Override
public EconomyResponse createBank(String name, String player) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "CleanConomy does not support bank accounts!");
}
@Override
public EconomyResponse deleteBank(String name) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "CleanConomy does not support bank accounts!");
}
@Override
public EconomyResponse bankHas(String name, double amount) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "CleanConomy does not support bank accounts!");
}
@Override
public EconomyResponse bankWithdraw(String name, double amount) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "CleanConomy does not support bank accounts!");
}
@Override
public EconomyResponse bankDeposit(String name, double amount) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "CleanConomy does not support bank accounts!");
}
@Override
public EconomyResponse isBankOwner(String name, String playerName) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "CleanConomy does not support bank accounts!");
}
@Override
public EconomyResponse isBankMember(String name, String playerName) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "CleanConomy does not support bank accounts!");
}
@Override
public EconomyResponse bankBalance(String name) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "CleanConomy does not support bank accounts!");
}
@Override
public List<String> getBanks() {
return new ArrayList<String>();
}
@Override
public boolean hasBankSupport() {
return false;
}
@Override
public boolean hasAccount(String playerName) {
return con.hasAccount(playerName);
}
@Override
public int fractionalDigits() {
return -1;
}
@Override
public boolean hasAccount(String playerName, String worldName) {
return hasAccount(playerName);
}
@Override
public double getBalance(String playerName, String world) {
return getBalance(playerName);
}
@Override
public boolean has(String playerName, String worldName, double amount) {
return has(playerName, amount);
}
@Override
public EconomyResponse withdrawPlayer(String playerName, String worldName, double amount) {
return withdrawPlayer(playerName, amount);
}
@Override
public EconomyResponse depositPlayer(String playerName, String worldName, double amount) {
return depositPlayer(playerName, amount);
}
@Override
public boolean createPlayerAccount(String playerName, String worldName) {
return createPlayerAccount(playerName);
}
}