mirror of
https://github.com/MilkBowl/Vault.git
synced 2024-11-27 04:55:33 +01:00
commit
1e6db1c87a
BIN
lib/TAEcon.jar
Normal file
BIN
lib/TAEcon.jar
Normal file
Binary file not shown.
9
pom.xml
9
pom.xml
@ -10,7 +10,7 @@
|
|||||||
<url>http://dev.bukkit.org/server-mods/vault/</url>
|
<url>http://dev.bukkit.org/server-mods/vault/</url>
|
||||||
<description>Vault is a Permissions & Economy API to allow plugins to more easily hook into these systems without needing to hook each individual system themselves.
|
<description>Vault is a Permissions & Economy API to allow plugins to more easily hook into these systems without needing to hook each individual system themselves.
|
||||||
|
|
||||||
Vault currently supports the following: Permissions 3, PEX, GroupManager, bPerms, bPerms2, SimplyPerms, DroxPerms, zPermissions, rscPermissions, Starburst, iConomy (4/5/6) BOSEconomy *6/7), EssentialsEcon, 3Co, MultiConomy, MineConomy, EconXP, eWallet, CurrencyCore, XPBank, CraftConomy, AEco, SDFEconomy</description>
|
Vault currently supports the following: Permissions 3, PEX, GroupManager, bPerms, bPerms2, SimplyPerms, DroxPerms, zPermissions, rscPermissions, Starburst, iConomy (4/5/6) BOSEconomy *6/7), EssentialsEcon, 3Co, MultiConomy, MineConomy, EconXP, eWallet, CurrencyCore, XPBank, CraftConomy, AEco, SDFEconomy, TAEcon</description>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
@ -355,6 +355,13 @@ Vault currently supports the following: Permissions 3, PEX, GroupManager, bPerms
|
|||||||
<scope>system</scope>
|
<scope>system</scope>
|
||||||
<systemPath>${project.basedir}/lib/rscPermissions.jar</systemPath>
|
<systemPath>${project.basedir}/lib/rscPermissions.jar</systemPath>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.teamalpha.taecon</groupId>
|
||||||
|
<artifactId>TAEcon</artifactId>
|
||||||
|
<version>0.1</version>
|
||||||
|
<scope>system</scope>
|
||||||
|
<systemPath>${project.basedir}/lib/TAEcon.jar</systemPath>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
@ -55,6 +55,7 @@ import net.milkbowl.vault.economy.plugins.Economy_Gringotts;
|
|||||||
import net.milkbowl.vault.economy.plugins.Economy_McMoney;
|
import net.milkbowl.vault.economy.plugins.Economy_McMoney;
|
||||||
import net.milkbowl.vault.economy.plugins.Economy_MineConomy;
|
import net.milkbowl.vault.economy.plugins.Economy_MineConomy;
|
||||||
import net.milkbowl.vault.economy.plugins.Economy_MultiCurrency;
|
import net.milkbowl.vault.economy.plugins.Economy_MultiCurrency;
|
||||||
|
import net.milkbowl.vault.economy.plugins.Economy_TAEcon;
|
||||||
import net.milkbowl.vault.economy.plugins.Economy_XPBank;
|
import net.milkbowl.vault.economy.plugins.Economy_XPBank;
|
||||||
import net.milkbowl.vault.economy.plugins.Economy_eWallet;
|
import net.milkbowl.vault.economy.plugins.Economy_eWallet;
|
||||||
import net.milkbowl.vault.economy.plugins.Economy_iConomy4;
|
import net.milkbowl.vault.economy.plugins.Economy_iConomy4;
|
||||||
@ -284,6 +285,9 @@ public class Vault extends JavaPlugin {
|
|||||||
|
|
||||||
// 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");
|
||||||
|
|
||||||
|
// Try to load TAEcon
|
||||||
|
hookEconomy("TAEcon", Economy_TAEcon.class, ServicePriority.Normal, "net.teamalpha.taecon.TAEcon");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
258
src/net/milkbowl/vault/economy/plugins/Economy_TAEcon.java
Normal file
258
src/net/milkbowl/vault/economy/plugins/Economy_TAEcon.java
Normal file
@ -0,0 +1,258 @@
|
|||||||
|
/* 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.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
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 net.milkbowl.vault.economy.EconomyResponse;
|
||||||
|
import net.milkbowl.vault.economy.EconomyResponse.ResponseType;
|
||||||
|
import net.teamalpha.taecon.TAEcon;
|
||||||
|
|
||||||
|
public class Economy_TAEcon implements net.milkbowl.vault.economy.Economy {
|
||||||
|
private static final Logger log = Logger.getLogger("Minecraft");
|
||||||
|
|
||||||
|
private final String name = "TAEcon";
|
||||||
|
private Plugin plugin = null;
|
||||||
|
private TAEcon economy = null;
|
||||||
|
|
||||||
|
public Economy_TAEcon(Plugin plugin){
|
||||||
|
this.plugin = plugin;
|
||||||
|
Bukkit.getServer().getPluginManager().registerEvents(new EconomyServerListener(this), plugin);
|
||||||
|
|
||||||
|
if (economy == null) {
|
||||||
|
Plugin taecon = plugin.getServer().getPluginManager().getPlugin(name);
|
||||||
|
|
||||||
|
if (taecon != null && taecon.isEnabled()) {
|
||||||
|
economy = (TAEcon) taecon;
|
||||||
|
log.info(String.format("[%s][Economy] %s hooked.", plugin.getDescription().getName(), name));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class EconomyServerListener implements Listener {
|
||||||
|
Economy_TAEcon economy = null;
|
||||||
|
|
||||||
|
public EconomyServerListener(Economy_TAEcon economy) {
|
||||||
|
this.economy = economy;
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
|
public void onPluginEnable(PluginEnableEvent event) {
|
||||||
|
if (economy.economy == null) {
|
||||||
|
Plugin taecon = event.getPlugin();
|
||||||
|
|
||||||
|
if (taecon.getDescription().getName().equals(economy.name)) {
|
||||||
|
economy.economy = (TAEcon) taecon;
|
||||||
|
log.info(String.format("[%s][Economy] %s hooked.", plugin.getDescription().getName(), economy.name));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
|
public void onPluginDisable(PluginDisableEvent event) {
|
||||||
|
if (economy.economy != null) {
|
||||||
|
if (event.getPlugin().getDescription().getName().equals(economy.name)) {
|
||||||
|
economy.economy = null;
|
||||||
|
log.info(String.format("[%s][Economy] %s unhooked.", plugin.getDescription().getName(), economy.name));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isEnabled() {
|
||||||
|
return economy != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasBankSupport() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int fractionalDigits() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String format(double amount) {
|
||||||
|
amount = Math.ceil(amount);
|
||||||
|
if (amount == 1) {
|
||||||
|
return String.format("%d %s", (int)amount, currencyNameSingular());
|
||||||
|
} else {
|
||||||
|
return String.format("%d %s", (int)amount, currencyNamePlural());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String currencyNamePlural() {
|
||||||
|
return economy.getCurrencyName(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String currencyNameSingular() {
|
||||||
|
return economy.getCurrencyName(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasAccount(String playerName) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double getBalance(String playerName) {
|
||||||
|
return economy.getBalance(playerName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean has(String playerName, double amount) {
|
||||||
|
return getBalance(playerName) >= amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EconomyResponse withdrawPlayer(String playerName, double amount) {
|
||||||
|
ResponseType rt;
|
||||||
|
String message;
|
||||||
|
int iamount = (int)Math.ceil(amount);
|
||||||
|
|
||||||
|
if (has(playerName, amount)) {
|
||||||
|
if (economy.removeBalance(playerName, iamount)) {
|
||||||
|
rt = ResponseType.SUCCESS;
|
||||||
|
message = null;
|
||||||
|
} else {
|
||||||
|
rt = ResponseType.SUCCESS;
|
||||||
|
message = "ERROR";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
rt = ResponseType.FAILURE;
|
||||||
|
message = "Not enough money";
|
||||||
|
}
|
||||||
|
|
||||||
|
return new EconomyResponse(iamount, getBalance(playerName), rt, message);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EconomyResponse depositPlayer(String playerName, double amount) {
|
||||||
|
ResponseType rt;
|
||||||
|
String message;
|
||||||
|
int iamount = (int)Math.floor(amount);
|
||||||
|
|
||||||
|
if (economy.addBalance(playerName, iamount)) {
|
||||||
|
rt = ResponseType.SUCCESS;
|
||||||
|
message = null;
|
||||||
|
} else {
|
||||||
|
rt = ResponseType.SUCCESS;
|
||||||
|
message = "ERROR";
|
||||||
|
}
|
||||||
|
|
||||||
|
return new EconomyResponse(iamount, getBalance(playerName), rt, message);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EconomyResponse createBank(String name, String player) {
|
||||||
|
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "TAEcon does not support bank accounts");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EconomyResponse deleteBank(String name) {
|
||||||
|
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "TAEcon does not support bank accounts");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EconomyResponse bankBalance(String name) {
|
||||||
|
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "TAEcon does not support bank accounts");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EconomyResponse bankHas(String name, double amount) {
|
||||||
|
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "TAEcon does not support bank accounts");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EconomyResponse bankWithdraw(String name, double amount) {
|
||||||
|
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "TAEcon does not support bank accounts");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EconomyResponse bankDeposit(String name, double amount) {
|
||||||
|
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "TAEcon does not support bank accounts");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EconomyResponse isBankOwner(String name, String playerName) {
|
||||||
|
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "TAEcon does not support bank accounts");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EconomyResponse isBankMember(String name, String playerName) {
|
||||||
|
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "TAEcon does not support bank accounts");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> getBanks() {
|
||||||
|
return new ArrayList<String>();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean createPlayerAccount(String playerName) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasAccount(String playerName, String worldName) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@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 false;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user