Merge pull request #500 from Dmitchell94/master

InTime2 Support
This commit is contained in:
Nick Minkler 2014-01-17 16:30:56 -08:00
commit 114c24c64e
5 changed files with 227 additions and 1 deletions

View File

@ -87,6 +87,7 @@ Github and we'll get to it at our convenience.
- iConomy 4 (http://forums.bukkit.org/threads/40/)
- iConomy 5 (http://forums.bukkit.org/threads/40/)
- iConomy 6 (http://forums.bukkit.org/threads/40/)
- InTime2
- McMoney
- Miconomy
- MineConomy (http://dev.bukkit.org/server-mods/mineconomy/)

BIN
lib/InTime2.jar Normal file

Binary file not shown.

View File

@ -77,6 +77,13 @@ Vault currently supports the following: Permissions 3, PEX, GroupManager, bPerms
<artifactId>bukkit</artifactId>
<version>${bukkitVersion}</version>
</dependency>
<dependency>
<groupId>com.BlackMage.InTime2.InTime2</groupId>
<artifactId>InTime2</artifactId>
<version>0.3.7</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/InTime2.jar</systemPath>
</dependency>
<dependency>
<groupId>com.gmail.bleedobsidian.miconomy</groupId>
<artifactId>MiConomy</artifactId>

View File

@ -56,6 +56,7 @@ import net.milkbowl.vault.economy.plugins.Economy_GoldIsMoney;
import net.milkbowl.vault.economy.plugins.Economy_GoldIsMoney2;
import net.milkbowl.vault.economy.plugins.Economy_GoldenChestEconomy;
import net.milkbowl.vault.economy.plugins.Economy_Gringotts;
import net.milkbowl.vault.economy.plugins.Economy_InTime2;
import net.milkbowl.vault.economy.plugins.Economy_McMoney;
import net.milkbowl.vault.economy.plugins.Economy_MineConomy;
import net.milkbowl.vault.economy.plugins.Economy_MultiCurrency;
@ -255,7 +256,10 @@ public class Vault extends JavaPlugin {
hookEconomy("MiConomy", Economy_MiConomy.class, ServicePriority.Normal, "com.gmail.bleedobsidian.miconomy.Main");
// Try to load MiFaConomy
hookEconomy("MineFaConomy", Economy_Minefaconomy.class, ServicePriority.Normal, "me.coniin.plugins.minefaconomy.Minefaconomy");
hookEconomy("MineFaConomy", Economy_Minefaconomy.class, ServicePriority.Normal, "me.coniin.plugins.minefaconomy.Minefaconomy");
// Try to load InTime2
hookEconomy("InTime2", Economy_InTime2.class, ServicePriority.Normal, "com.BlackMage.InTime2.InTime2");
// Try to load MultiCurrency
hookEconomy("MultiCurrency", Economy_MultiCurrency.class, ServicePriority.Normal, "me.ashtheking.currency.Currency", "me.ashtheking.currency.CurrencyList");

View File

@ -0,0 +1,214 @@
+ + /* 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.BlackMage.Intime.Intime
+ +
+ +public class Economy_InTime2 implements Economy {
+ + private static final Logger log = Logger.getLogger("Minecraft");
+ +
+ + private String name = "InTime2";
+ + private Plugin plugin = null;
+ + protected Main economy = null;
+ +
+ + public Economy_InTime2(Plugin plugin) {
+ + this.plugin = plugin;
+ + Bukkit.getServer().getPluginManager().registerEvents(new EconomyServerListener(this), plugin);
+ + // Load Plugin in case it was loaded before
+ + if (economy == null) {
+ + Plugin ec = plugin.getServer().getPluginManager().getPlugin("InTime2");
+ + if (ec != null && ec.isEnabled() && ec.getClass().getName().equals("com.BlackMage.InTime2.InTime2")) {
+ + log.info(String.format("[%s][Economy] %s hooked.", plugin.getDescription().getName(), name));
+ + }
+ + }
+ + }
+ +
+ + @Override
+ + public boolean isEnabled() {
+ + if (economy == null) {
+ + return false;
+ + } else {
+ + return true;
+ + }
+ + }
+ +
+ + @Override
+ + public String getName() {
+ + return name;
+ + }
+ +
+ + @Override
+ + public String format(double amount) {
+ + return Functions.format(amount);
+ + }
+ +
+ + @Override
+ + public String currencyNameSingular() {
+ + return Functions.currencyName();
+ + }
+ +
+ + @Override
+ + public String currencyNamePlural() {
+ + return Functions.currencyName();
+ + }
+ +
+ + @Override
+ + public double getBalance(String playerName) {
+ + return (double) Backend.getMoney(playerName);
+ + }
+ +
+ + @Override
+ + public EconomyResponse withdrawPlayer(String playerName, double amount) {
+ + if (amount < 0) {
+ + return new EconomyResponse(0, 0, ResponseType.FAILURE, "Cannot withdraw negative funds");
+ + }
+ +
+ + if (Backend.hasEnoughMoney(playerName, amount)) {
+ + int newAmount = Backend.getMoney(playerName) - amount;
+ + Backend.setMoney(playerName, newAmount);
+ + return new EconomyResponse(amount, newAmount, ResponseType.SUCCESS, null);
+ + } else {
+ + return new EconomyResponse(0, Backend.getMoney(playerName), ResponseType.FAILURE, "Insufficient funds");
+ + }
+ + }
+ +
+ + @Override
+ + public EconomyResponse depositPlayer(String playerName, double amount) {
+ + if (amount < 0) {
+ + return new EconomyResponse(0, 0, ResponseType.FAILURE, "Cannot desposit negative funds");
+ + }
+ +
+ + int newAmount = Backend.getMoney(playerName) + amount;
+ + Backend.setMoney(playerName, newAmount);
+ + return new EconomyResponse(amount, newAmount, ResponseType.SUCCESS, null);
+ + }
+ +
+ + @Override
+ + public boolean has(String playerName, double amount) {
+ + return getBalance(playerName) >= amount;
+ + }
+ +
+ + @Override
+ + public EconomyResponse createBank(String name, String player) {
+ +
+ + return new EconomyResponse(0, 0, ResponseType.FAILURE, "Banks not supported by InTime2!");
+ + }
+ +
+ + @Override
+ + public EconomyResponse deleteBank(String name) {
+ + return new EconomyResponse(0, 0, ResponseType.FAILURE, "Banks not supported by InTime2!");
+ + }
+ +
+ + @Override
+ + public EconomyResponse bankHas(String name, double amount) {
+ + return new EconomyResponse(0, 0, ResponseType.FAILURE, "Banks not supported by InTime2!");
+ + }
+ +
+ + @Override
+ + public EconomyResponse bankWithdraw(String name, double amount) {
+ + return new EconomyResponse(0, 0, ResponseType.FAILURE, "Banks not supported by InTime2!");
+ + }
+ +
+ + @Override
+ + public EconomyResponse bankDeposit(String name, double amount) {
+ + return new EconomyResponse(0, 0, ResponseType.FAILURE, "Banks not supported by InTime2!");
+ + }
+ +
+ + @Override
+ + public EconomyResponse isBankOwner(String name, String playerName) {
+ + return new EconomyResponse(0, 0, ResponseType.FAILURE, "Banks not supported by InTime2!");
+ + }
+ +
+ + @Override
+ + public EconomyResponse isBankMember(String name, String playerName) {
+ + return new EconomyResponse(0, 0, ResponseType.FAILURE, "Banks not supported by InTime2!");
+ + }
+ +
+ + @Override
+ + public EconomyResponse bankBalance(String name) {
+ + return new EconomyResponse(0, 0, ResponseType.FAILURE, "Banks not supported by InTime2!");
+ + }
+ +
+ + @Override
+ + public List<String> getBanks() {
+ + throw new UnsupportedOperationException("Banks not supported by InTime2!");
+ + }
+ +
+ + @Override
+ + public boolean hasBankSupport() {
+ + return false;
+ + }
+ +
+ + @Override
+ + public boolean hasAccount(String playerName) {
+ + return true; // All players have an account
+ + }
+ +
+ + @Override
+ + public boolean createPlayerAccount(String playerName) {
+ + return true; // All players have an account
+ + }
+ +
+ + @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);
+ + }
+ +}