2012-02-19 09:22:02 +01:00
|
|
|
/* 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.
|
2011-06-29 02:18:20 +02:00
|
|
|
|
2012-02-19 09:22:02 +01:00
|
|
|
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/>.
|
|
|
|
*/
|
2011-06-29 02:18:20 +02:00
|
|
|
package net.milkbowl.vault;
|
|
|
|
|
2012-01-31 23:11:48 +01:00
|
|
|
import java.io.IOException;
|
2012-01-16 02:10:53 +01:00
|
|
|
import java.lang.reflect.InvocationTargetException;
|
|
|
|
import java.lang.reflect.Method;
|
2011-12-03 10:30:44 +01:00
|
|
|
import java.net.URL;
|
2011-07-19 16:33:01 +02:00
|
|
|
import java.util.Collection;
|
2011-06-29 02:18:20 +02:00
|
|
|
import java.util.logging.Logger;
|
|
|
|
|
2011-12-03 10:30:44 +01:00
|
|
|
import javax.xml.parsers.DocumentBuilderFactory;
|
|
|
|
|
2011-10-23 22:18:23 +02:00
|
|
|
import net.milkbowl.vault.chat.Chat;
|
|
|
|
import net.milkbowl.vault.chat.plugins.Chat_GroupManager;
|
|
|
|
import net.milkbowl.vault.chat.plugins.Chat_Permissions3;
|
|
|
|
import net.milkbowl.vault.chat.plugins.Chat_PermissionsEx;
|
2011-12-19 08:40:19 +01:00
|
|
|
import net.milkbowl.vault.chat.plugins.Chat_Towny;
|
2011-10-29 01:12:49 +02:00
|
|
|
import net.milkbowl.vault.chat.plugins.Chat_bPermissions;
|
2012-02-01 16:20:39 +01:00
|
|
|
import net.milkbowl.vault.chat.plugins.Chat_bPermissions2;
|
2011-11-19 19:13:12 +01:00
|
|
|
import net.milkbowl.vault.chat.plugins.Chat_iChat;
|
2011-10-23 22:18:23 +02:00
|
|
|
import net.milkbowl.vault.chat.plugins.Chat_mChat;
|
2012-02-21 10:22:16 +01:00
|
|
|
import net.milkbowl.vault.chat.plugins.Chat_mChatSuite;
|
2011-06-30 17:14:09 +02:00
|
|
|
import net.milkbowl.vault.economy.Economy;
|
|
|
|
import net.milkbowl.vault.economy.plugins.Economy_3co;
|
2012-03-12 07:33:33 +01:00
|
|
|
import net.milkbowl.vault.economy.plugins.Economy_AEco;
|
2011-10-10 08:02:05 +02:00
|
|
|
import net.milkbowl.vault.economy.plugins.Economy_BOSE6;
|
|
|
|
import net.milkbowl.vault.economy.plugins.Economy_BOSE7;
|
2012-01-16 17:01:30 +01:00
|
|
|
import net.milkbowl.vault.economy.plugins.Economy_Craftconomy;
|
2011-12-30 18:03:21 +01:00
|
|
|
import net.milkbowl.vault.economy.plugins.Economy_CurrencyCore;
|
2011-12-03 19:35:49 +01:00
|
|
|
import net.milkbowl.vault.economy.plugins.Economy_EconXP;
|
2011-06-30 17:14:09 +02:00
|
|
|
import net.milkbowl.vault.economy.plugins.Economy_Essentials;
|
2012-02-19 09:22:02 +01:00
|
|
|
import net.milkbowl.vault.economy.plugins.Economy_McMoney;
|
2011-11-27 20:14:28 +01:00
|
|
|
import net.milkbowl.vault.economy.plugins.Economy_MineConomy;
|
2011-09-23 08:43:48 +02:00
|
|
|
import net.milkbowl.vault.economy.plugins.Economy_MultiCurrency;
|
2011-11-27 20:28:23 +01:00
|
|
|
import net.milkbowl.vault.economy.plugins.Economy_eWallet;
|
2011-06-30 17:14:09 +02:00
|
|
|
import net.milkbowl.vault.economy.plugins.Economy_iConomy4;
|
|
|
|
import net.milkbowl.vault.economy.plugins.Economy_iConomy5;
|
2011-08-11 23:18:25 +02:00
|
|
|
import net.milkbowl.vault.economy.plugins.Economy_iConomy6;
|
2011-06-30 17:14:09 +02:00
|
|
|
import net.milkbowl.vault.permission.Permission;
|
2011-08-08 09:05:32 +02:00
|
|
|
import net.milkbowl.vault.permission.plugins.Permission_GroupManager;
|
2011-08-09 17:43:15 +02:00
|
|
|
import net.milkbowl.vault.permission.plugins.Permission_Permissions3;
|
2011-09-18 10:19:35 +02:00
|
|
|
import net.milkbowl.vault.permission.plugins.Permission_PermissionsBukkit;
|
2011-06-30 17:14:09 +02:00
|
|
|
import net.milkbowl.vault.permission.plugins.Permission_PermissionsEx;
|
2012-04-30 16:18:06 +02:00
|
|
|
import net.milkbowl.vault.permission.plugins.Permission_SimplyPerms;
|
2012-01-13 02:24:07 +01:00
|
|
|
import net.milkbowl.vault.permission.plugins.Permission_Starburst;
|
2011-09-18 10:19:35 +02:00
|
|
|
import net.milkbowl.vault.permission.plugins.Permission_SuperPerms;
|
2011-10-28 22:41:02 +02:00
|
|
|
import net.milkbowl.vault.permission.plugins.Permission_bPermissions;
|
2012-02-01 16:20:39 +01:00
|
|
|
import net.milkbowl.vault.permission.plugins.Permission_bPermissions2;
|
2012-01-01 01:35:31 +01:00
|
|
|
import net.milkbowl.vault.permission.plugins.Permission_zPermissions;
|
2011-06-29 02:18:20 +02:00
|
|
|
|
2012-02-20 18:54:20 +01:00
|
|
|
import org.bukkit.Bukkit;
|
|
|
|
import org.bukkit.OfflinePlayer;
|
2011-06-30 15:49:26 +02:00
|
|
|
import org.bukkit.command.Command;
|
|
|
|
import org.bukkit.command.CommandSender;
|
2011-06-30 17:14:09 +02:00
|
|
|
import org.bukkit.entity.Player;
|
2012-01-25 23:31:13 +01:00
|
|
|
import org.bukkit.event.EventHandler;
|
|
|
|
import org.bukkit.event.EventPriority;
|
|
|
|
import org.bukkit.event.Listener;
|
2011-12-10 05:14:28 +01:00
|
|
|
import org.bukkit.event.player.PlayerJoinEvent;
|
2012-01-16 02:10:53 +01:00
|
|
|
import org.bukkit.event.server.PluginEnableEvent;
|
2011-07-19 16:33:01 +02:00
|
|
|
import org.bukkit.plugin.RegisteredServiceProvider;
|
2011-07-19 15:25:12 +02:00
|
|
|
import org.bukkit.plugin.ServicePriority;
|
2012-01-06 09:19:43 +01:00
|
|
|
import org.bukkit.plugin.ServicesManager;
|
2011-06-29 02:18:20 +02:00
|
|
|
import org.bukkit.plugin.java.JavaPlugin;
|
2011-12-03 10:30:44 +01:00
|
|
|
import org.w3c.dom.Document;
|
|
|
|
import org.w3c.dom.Element;
|
|
|
|
import org.w3c.dom.Node;
|
|
|
|
import org.w3c.dom.NodeList;
|
2011-06-29 02:18:20 +02:00
|
|
|
|
2012-01-16 02:10:53 +01:00
|
|
|
import com.nijikokun.register.payment.Methods;
|
|
|
|
|
2011-06-29 02:18:20 +02:00
|
|
|
public class Vault extends JavaPlugin {
|
2011-08-12 19:11:25 +02:00
|
|
|
|
2011-12-10 05:14:28 +01:00
|
|
|
private static final Logger log = Logger.getLogger("Minecraft");
|
|
|
|
private Permission perms;
|
2012-02-27 17:54:43 +01:00
|
|
|
private double newVersion;
|
|
|
|
private double currentVersion;
|
2012-01-06 09:19:43 +01:00
|
|
|
private ServicesManager sm;
|
2012-01-31 23:11:48 +01:00
|
|
|
private Metrics metrics;
|
2012-01-16 02:15:05 +01:00
|
|
|
|
2011-12-10 05:14:28 +01:00
|
|
|
@Override
|
|
|
|
public void onDisable() {
|
|
|
|
// Remove all Service Registrations
|
|
|
|
getServer().getServicesManager().unregisterAll(this);
|
|
|
|
|
|
|
|
log.info(String.format("[%s] Disabled Version %s", getDescription().getName(), getDescription().getVersion()));
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onEnable() {
|
2012-02-27 19:25:07 +01:00
|
|
|
currentVersion = Double.valueOf(getDescription().getVersion().split("-")[0].replaceFirst("\\.", ""));
|
2012-01-06 09:19:43 +01:00
|
|
|
sm = getServer().getServicesManager();
|
2011-12-10 05:14:28 +01:00
|
|
|
// Load Vault Addons
|
|
|
|
loadEconomy();
|
|
|
|
loadPermission();
|
|
|
|
loadChat();
|
|
|
|
|
|
|
|
getCommand("vault-info").setExecutor(this);
|
2012-02-20 18:54:20 +01:00
|
|
|
getCommand("vault-convert").setExecutor(this);
|
2012-01-25 23:31:13 +01:00
|
|
|
getServer().getPluginManager().registerEvents(new VaultListener(), this);
|
2012-01-16 02:15:05 +01:00
|
|
|
|
2011-12-12 08:46:43 +01:00
|
|
|
// Schedule to check the version every 30 minutes for an update. This is to update the most recent
|
2011-12-10 06:19:09 +01:00
|
|
|
// version so if an admin reconnects they will be warned about newer versions.
|
|
|
|
this.getServer().getScheduler().scheduleAsyncRepeatingTask(this, new Runnable() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
try {
|
2011-12-18 19:38:09 +01:00
|
|
|
newVersion = updateCheck(currentVersion);
|
2012-02-18 20:16:13 +01:00
|
|
|
if (newVersion > currentVersion) {
|
|
|
|
log.warning("Vault " + newVersion + " is out! You are running: Vault " + currentVersion);
|
2011-12-12 08:46:43 +01:00
|
|
|
log.warning("Update Vault at: http://dev.bukkit.org/server-mods/vault");
|
|
|
|
}
|
2011-12-10 06:19:09 +01:00
|
|
|
} catch (Exception e) {
|
|
|
|
// ignore exceptions
|
|
|
|
}
|
|
|
|
}
|
2012-01-16 02:15:05 +01:00
|
|
|
|
2012-01-02 19:08:48 +01:00
|
|
|
}, 0, 432000);
|
2012-01-16 02:15:05 +01:00
|
|
|
|
2012-02-01 01:11:03 +01:00
|
|
|
// Load up the Plugin metrics
|
2012-01-31 23:11:48 +01:00
|
|
|
try {
|
2012-02-25 22:49:55 +01:00
|
|
|
String authors = "";
|
|
|
|
for (String author : this.getDescription().getAuthors()) {
|
|
|
|
authors += author + ", ";
|
|
|
|
}
|
|
|
|
if (!authors.isEmpty()) {
|
|
|
|
authors = authors.substring(0, authors.length() - 2);
|
|
|
|
}
|
|
|
|
metrics = new Metrics(getDescription().getVersion(), authors);
|
2012-02-01 02:45:29 +01:00
|
|
|
metrics.findCustomData(this);
|
|
|
|
metrics.beginMeasuringPlugin(this);
|
2012-01-31 23:11:48 +01:00
|
|
|
} catch (IOException e) {
|
|
|
|
// ignore exception
|
|
|
|
}
|
2011-12-10 05:14:28 +01:00
|
|
|
log.info(String.format("[%s] Enabled Version %s", getDescription().getName(), getDescription().getVersion()));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Attempts to load Chat Addons
|
|
|
|
*/
|
|
|
|
private void loadChat() {
|
|
|
|
// Try to load PermissionsEx
|
2012-02-21 10:22:16 +01:00
|
|
|
if (packageExists("ru.tehkode.permissions.bukkit.PermissionsEx")) {
|
2011-12-10 05:14:28 +01:00
|
|
|
Chat eChat = new Chat_PermissionsEx(this, perms);
|
2012-01-11 21:11:25 +01:00
|
|
|
sm.register(Chat.class, eChat, this, ServicePriority.Highest);
|
2011-12-10 05:14:28 +01:00
|
|
|
log.info(String.format("[%s][Chat] PermissionsEx found: %s", getDescription().getName(), eChat.isEnabled() ? "Loaded" : "Waiting"));
|
|
|
|
}
|
|
|
|
|
2012-02-21 10:22:16 +01:00
|
|
|
//Try loading mChatSuite
|
|
|
|
if (packageExists("in.mDev.MiracleM4n.mChatSuite.mChatSuite")) {
|
|
|
|
Chat mChat = new Chat_mChatSuite(this, perms);
|
|
|
|
sm.register(Chat.class, mChat, this, ServicePriority.Highest);
|
|
|
|
log.info(String.format("[%s][Chat] mChatSuite found: %s", getDescription().getName(), mChat.isEnabled() ? "Loaded" : "Waiting"));
|
|
|
|
}
|
|
|
|
|
2011-12-10 05:14:28 +01:00
|
|
|
//Try loading mChat
|
2012-02-21 10:22:16 +01:00
|
|
|
if (packageExists("net.D3GN.MiracleM4n.mChat")) {
|
2011-12-10 05:14:28 +01:00
|
|
|
Chat mChat = new Chat_mChat(this, perms);
|
2012-01-11 21:11:25 +01:00
|
|
|
sm.register(Chat.class, mChat, this, ServicePriority.Highest);
|
2011-12-10 05:14:28 +01:00
|
|
|
log.info(String.format("[%s][Chat] mChat found: %s", getDescription().getName(), mChat.isEnabled() ? "Loaded" : "Waiting"));
|
|
|
|
}
|
2012-01-16 02:15:05 +01:00
|
|
|
|
2012-01-30 01:15:15 +01:00
|
|
|
//try loading bPermssions 2
|
2012-02-21 10:22:16 +01:00
|
|
|
if (packageExists("de.bananaco.bpermissions.api.ApiLayer")) {
|
2012-02-19 02:04:43 +01:00
|
|
|
Chat bPerms = new Chat_bPermissions2(this, perms);
|
|
|
|
sm.register(Chat.class, bPerms, this, ServicePriority.High);
|
|
|
|
log.info(String.format("[%s][Chat] bPermissions2 found: %s", getDescription().getName(), bPerms.isEnabled() ? "Loaded" : "Waiting"));
|
|
|
|
}
|
|
|
|
|
|
|
|
// try loading bPermissions 1
|
2012-02-21 10:22:16 +01:00
|
|
|
if (packageExists("de.bananaco.permissions.info.InfoReader")) {
|
2012-02-19 02:04:43 +01:00
|
|
|
Chat bPerms = new Chat_bPermissions(this, perms);
|
|
|
|
sm.register(Chat.class, bPerms, this, ServicePriority.Normal);
|
|
|
|
log.info(String.format("[%s][Chat] bPermissions found: %s", getDescription().getName(), bPerms.isEnabled() ? "Loaded" : "Waiting"));
|
2011-12-10 05:14:28 +01:00
|
|
|
}
|
2012-01-16 02:15:05 +01:00
|
|
|
|
2011-12-10 05:14:28 +01:00
|
|
|
// Try to load GroupManager
|
2012-02-21 10:22:16 +01:00
|
|
|
if (packageExists("org.anjocaido.groupmanager.GroupManager")) {
|
2011-12-10 05:14:28 +01:00
|
|
|
Chat gPerms = new Chat_GroupManager(this, perms);
|
2012-01-06 09:19:43 +01:00
|
|
|
sm.register(Chat.class, gPerms, this, ServicePriority.Normal);
|
2011-12-10 05:14:28 +01:00
|
|
|
log.info(String.format("[%s][Chat] GroupManager found: %s", getDescription().getName(), gPerms.isEnabled() ? "Loaded" : "Waiting"));
|
|
|
|
}
|
|
|
|
|
|
|
|
// Try to load Permissions 3 (Yeti)
|
2012-02-21 10:22:16 +01:00
|
|
|
if (packageExists("com.nijiko.permissions.ModularControl")) {
|
2011-12-10 05:14:28 +01:00
|
|
|
Chat nPerms = new Chat_Permissions3(this, perms);
|
2012-01-06 09:19:43 +01:00
|
|
|
sm.register(Chat.class, nPerms, this, ServicePriority.Normal);
|
2011-12-10 05:14:28 +01:00
|
|
|
log.info(String.format("[%s][Chat] Permissions 3 (Yeti) found: %s", getDescription().getName(), nPerms.isEnabled() ? "Loaded" : "Waiting"));
|
|
|
|
}
|
|
|
|
|
|
|
|
// Try to load iChat
|
2012-02-21 10:22:16 +01:00
|
|
|
if (packageExists("net.TheDgtl.iChat.iChat")) {
|
2011-12-10 05:14:28 +01:00
|
|
|
Chat iChat = new Chat_iChat(this, perms);
|
2012-01-06 09:19:43 +01:00
|
|
|
sm.register(Chat.class, iChat, this, ServicePriority.Low);
|
2011-12-19 08:40:19 +01:00
|
|
|
log.info(String.format("[%s][Chat] iChat found: %s", getDescription().getName(), iChat.isEnabled() ? "Loaded" : "Waiting"));
|
|
|
|
}
|
2012-01-16 02:15:05 +01:00
|
|
|
|
2011-12-19 08:40:19 +01:00
|
|
|
//Try to load Towny Chat
|
2012-02-21 10:22:16 +01:00
|
|
|
if (packageExists("com.palmergames.bukkit.towny.Towny")) {
|
2011-12-19 08:40:19 +01:00
|
|
|
Chat townChat = new Chat_Towny(this, perms);
|
2012-01-06 09:19:43 +01:00
|
|
|
sm.register(Chat.class, townChat, this, ServicePriority.Lowest);
|
2011-12-19 08:40:19 +01:00
|
|
|
log.info(String.format("[%s][Chat] Towny found: %s", getDescription().getName(), townChat.isEnabled() ? "Loaded" : "Waiting"));
|
2011-12-10 05:14:28 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Attempts to load Economy Addons
|
|
|
|
*/
|
|
|
|
private void loadEconomy() {
|
|
|
|
// Try to load MultiCurrency
|
2012-02-21 10:22:16 +01:00
|
|
|
if (packageExists("me.ashtheking.currency.Currency", "me.ashtheking.currency.CurrencyList")) {
|
2011-12-10 05:14:28 +01:00
|
|
|
Economy econ = new Economy_MultiCurrency(this);
|
2012-01-06 09:19:43 +01:00
|
|
|
sm.register(Economy.class, econ, this, ServicePriority.Normal);
|
2011-12-10 05:14:28 +01:00
|
|
|
log.info(String.format("[%s][Economy] MultiCurrency found: %s", getDescription().getName(), econ.isEnabled() ? "Loaded" : "Waiting"));
|
|
|
|
}
|
|
|
|
|
|
|
|
//Try Loading MineConomy
|
2012-02-21 10:22:16 +01:00
|
|
|
if (packageExists("me.mjolnir.mineconomy.MineConomy")) {
|
2012-04-10 02:28:18 +02:00
|
|
|
Economy econ = new Economy_MineConomy(this);
|
|
|
|
sm.register(Economy.class, econ, this, ServicePriority.Normal);
|
|
|
|
log.info(String.format("[%s][Economy] MineConomy found: %s", getDescription().getName(), econ.isEnabled() ? "Loaded" : "Waiting"));
|
2011-12-10 05:14:28 +01:00
|
|
|
}
|
2012-04-10 02:28:18 +02:00
|
|
|
|
2012-03-12 07:33:33 +01:00
|
|
|
//Try Loading AEco
|
|
|
|
if (packageExists("org.neocraft.AEco.AEco")) {
|
|
|
|
Economy econ = new Economy_AEco(this);
|
|
|
|
sm.register(Economy.class, econ, this, ServicePriority.Normal);
|
|
|
|
log.info(String.format("[%s][Economy] AEco found: %s", getDescription().getName(), econ.isEnabled() ? "Loaded" : "Waiting"));
|
|
|
|
}
|
2012-04-10 02:28:18 +02:00
|
|
|
|
2012-02-19 09:22:02 +01:00
|
|
|
//Try Loading McMoney
|
2012-02-21 10:22:16 +01:00
|
|
|
if (packageExists("boardinggamer.mcmoney.McMoneyAPI")) {
|
2012-02-19 09:22:02 +01:00
|
|
|
Economy econ = new Economy_McMoney(this);
|
|
|
|
sm.register(Economy.class, econ, this, ServicePriority.Normal);
|
|
|
|
log.info(String.format("[%s][Economy] McMoney found: %s", getDescription().getName(), econ.isEnabled() ? "Loaded" : "Waiting"));
|
|
|
|
}
|
|
|
|
|
2012-01-16 17:01:30 +01:00
|
|
|
//Try Loading Craftconomy
|
2012-02-21 10:22:16 +01:00
|
|
|
if (packageExists("me.greatman.Craftconomy.Craftconomy")) {
|
2012-01-16 17:01:30 +01:00
|
|
|
Economy econ = new Economy_Craftconomy(this);
|
|
|
|
sm.register(Economy.class, econ, this, ServicePriority.Normal);
|
|
|
|
log.info(String.format("[%s][Economy] CraftConomy found: %s", getDescription().getName(), econ.isEnabled() ? "Loaded" : "Waiting"));
|
|
|
|
}
|
2012-01-30 01:15:15 +01:00
|
|
|
|
2011-12-10 05:14:28 +01:00
|
|
|
//Try loading eWallet
|
2012-02-21 10:22:16 +01:00
|
|
|
if (packageExists("me.ethan.eWallet.ECO")) {
|
2011-12-10 05:14:28 +01:00
|
|
|
Economy econ = new Economy_eWallet(this);
|
2012-01-06 09:19:43 +01:00
|
|
|
sm.register(Economy.class, econ, this, ServicePriority.Normal);
|
2011-12-10 05:14:28 +01:00
|
|
|
log.info(String.format("[%s][Economy] eWallet found: %s", getDescription().getName(), econ.isEnabled() ? "Loaded" : "Waiting"));
|
|
|
|
}
|
|
|
|
|
|
|
|
// Try to load 3co
|
2012-02-21 10:22:16 +01:00
|
|
|
if (packageExists("me.ic3d.eco.ECO")) {
|
2011-12-10 05:14:28 +01:00
|
|
|
Economy econ = new Economy_3co(this);
|
2012-01-06 09:19:43 +01:00
|
|
|
sm.register(Economy.class, econ, this, ServicePriority.Normal);
|
2011-12-10 05:14:28 +01:00
|
|
|
log.info(String.format("[%s][Economy] 3co found: %s", getDescription().getName(), econ.isEnabled() ? "Loaded" : "Waiting"));
|
|
|
|
}
|
|
|
|
|
|
|
|
// Try to load BOSEconomy
|
2012-02-21 10:22:16 +01:00
|
|
|
if (packageExists("cosine.boseconomy.BOSEconomy", "cosine.boseconomy.CommandManager")) {
|
2011-12-10 05:14:28 +01:00
|
|
|
Economy bose6 = new Economy_BOSE6(this);
|
2012-01-06 09:19:43 +01:00
|
|
|
sm.register(Economy.class, bose6, this, ServicePriority.Normal);
|
2011-12-10 05:14:28 +01:00
|
|
|
log.info(String.format("[%s][Economy] BOSEconomy6 found: %s", getDescription().getName(), bose6.isEnabled() ? "Loaded" : "Waiting"));
|
|
|
|
}
|
|
|
|
|
|
|
|
// Try to load BOSEconomy
|
2012-02-21 10:22:16 +01:00
|
|
|
if (packageExists("cosine.boseconomy.BOSEconomy", "cosine.boseconomy.CommandHandler")) {
|
2011-12-10 05:14:28 +01:00
|
|
|
Economy bose7 = new Economy_BOSE7(this);
|
2012-01-06 09:19:43 +01:00
|
|
|
sm.register(net.milkbowl.vault.economy.Economy.class, bose7, this, ServicePriority.Normal);
|
2011-12-10 05:14:28 +01:00
|
|
|
log.info(String.format("[%s][Economy] BOSEconomy7 found: %s", getDescription().getName(), bose7.isEnabled() ? "Loaded" : "Waiting"));
|
|
|
|
}
|
2012-01-16 02:15:05 +01:00
|
|
|
|
2011-12-30 18:03:21 +01:00
|
|
|
//Try to load CurrencyCore
|
2012-02-21 10:22:16 +01:00
|
|
|
if (packageExists("is.currency.Currency")) {
|
2011-12-30 18:03:21 +01:00
|
|
|
Economy cCore = new Economy_CurrencyCore(this);
|
2012-01-06 09:19:43 +01:00
|
|
|
sm.register(net.milkbowl.vault.economy.Economy.class, cCore, this, ServicePriority.Normal);
|
2011-12-30 18:03:21 +01:00
|
|
|
log.info(String.format("[%s][Economy] CurrencyCore found: %s", getDescription().getName(), cCore.isEnabled() ? "Loaded" : "Waiting"));
|
|
|
|
}
|
2012-01-16 02:15:05 +01:00
|
|
|
|
2011-12-10 05:14:28 +01:00
|
|
|
// Try to load Essentials Economy
|
2012-02-21 10:22:16 +01:00
|
|
|
if (packageExists("com.earth2me.essentials.api.Economy", "com.earth2me.essentials.api.NoLoanPermittedException", "com.earth2me.essentials.api.UserDoesNotExistException")) {
|
2011-12-10 05:14:28 +01:00
|
|
|
Economy essentials = new Economy_Essentials(this);
|
2012-01-06 09:19:43 +01:00
|
|
|
sm.register(net.milkbowl.vault.economy.Economy.class, essentials, this, ServicePriority.Low);
|
2011-12-10 05:14:28 +01:00
|
|
|
log.info(String.format("[%s][Economy] Essentials Economy found: %s", getDescription().getName(), essentials.isEnabled() ? "Loaded" : "Waiting"));
|
|
|
|
}
|
|
|
|
|
|
|
|
// Try to load iConomy 4
|
2012-02-21 10:22:16 +01:00
|
|
|
if (packageExists("com.nijiko.coelho.iConomy.iConomy", "com.nijiko.coelho.iConomy.system.Account")) {
|
2011-12-10 05:14:28 +01:00
|
|
|
Economy icon4 = new Economy_iConomy4(this);
|
2012-01-06 09:19:43 +01:00
|
|
|
sm.register(net.milkbowl.vault.economy.Economy.class, icon4, this, ServicePriority.High);
|
2011-12-10 05:14:28 +01:00
|
|
|
log.info(String.format("[%s][Economy] iConomy 4 found: ", getDescription().getName(), icon4.isEnabled() ? "Loaded" : "Waiting"));
|
|
|
|
}
|
|
|
|
|
|
|
|
// Try to load iConomy 5
|
2012-02-21 10:22:16 +01:00
|
|
|
if (packageExists("com.iConomy.iConomy", "com.iConomy.system.Account", "com.iConomy.system.Holdings")) {
|
2011-12-10 05:14:28 +01:00
|
|
|
Economy icon5 = new Economy_iConomy5(this);
|
2012-01-06 09:19:43 +01:00
|
|
|
sm.register(net.milkbowl.vault.economy.Economy.class, icon5, this, ServicePriority.High);
|
2011-12-10 05:14:28 +01:00
|
|
|
log.info(String.format("[%s][Economy] iConomy 5 found: %s", getDescription().getName(), icon5.isEnabled() ? "Loaded" : "Waiting"));
|
|
|
|
}
|
|
|
|
|
|
|
|
// Try to load iConomy 6
|
2012-02-21 10:22:16 +01:00
|
|
|
if (packageExists("com.iCo6.iConomy")) {
|
2011-12-10 05:14:28 +01:00
|
|
|
Economy icon6 = new Economy_iConomy6(this);
|
2012-01-06 09:19:43 +01:00
|
|
|
sm.register(Economy.class, icon6, this, ServicePriority.High);
|
2011-12-10 05:14:28 +01:00
|
|
|
log.info(String.format("[%s][Economy] iConomy 6 found: %s", getDescription().getName(), icon6.isEnabled() ? "Loaded" : "Waiting"));
|
|
|
|
}
|
|
|
|
|
|
|
|
//Try loading EconXP
|
2012-02-21 10:22:16 +01:00
|
|
|
if (packageExists("ca.agnate.EconXP.EconXP")) {
|
2011-12-03 19:35:49 +01:00
|
|
|
Economy econ = new Economy_EconXP(this);
|
2012-01-06 09:19:43 +01:00
|
|
|
sm.register(Economy.class, econ, this, ServicePriority.Normal);
|
2011-12-03 19:35:49 +01:00
|
|
|
log.info(String.format("[%s][Economy] EconXP found: %s", getDescription().getName(), econ.isEnabled() ? "Loaded" : "Waiting"));
|
|
|
|
}
|
2011-12-10 05:14:28 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Attempts to load Permission Addons
|
|
|
|
*/
|
|
|
|
private void loadPermission() {
|
2012-01-13 02:24:07 +01:00
|
|
|
//Try to load Starburst
|
2012-02-21 10:22:16 +01:00
|
|
|
if (packageExists("com.dthielke.starburst.StarburstPlugin")) {
|
2012-01-13 02:24:07 +01:00
|
|
|
Permission sPerms = new Permission_Starburst(this);
|
|
|
|
sm.register(Permission.class, sPerms, this, ServicePriority.Highest);
|
|
|
|
log.info(String.format("[%s][Permission] Starburst found: %s", getDescription().getName(), sPerms.isEnabled() ? "Loaded" : "Waiting"));
|
|
|
|
}
|
2012-01-16 02:15:05 +01:00
|
|
|
|
2011-12-10 05:14:28 +01:00
|
|
|
// Try to load PermissionsEx
|
2012-02-21 10:22:16 +01:00
|
|
|
if (packageExists("ru.tehkode.permissions.bukkit.PermissionsEx")) {
|
2011-12-10 05:14:28 +01:00
|
|
|
Permission ePerms = new Permission_PermissionsEx(this);
|
2012-01-06 09:19:43 +01:00
|
|
|
sm.register(Permission.class, ePerms, this, ServicePriority.Highest);
|
2011-12-10 05:14:28 +01:00
|
|
|
log.info(String.format("[%s][Permission] PermissionsEx found: %s", getDescription().getName(), ePerms.isEnabled() ? "Loaded" : "Waiting"));
|
|
|
|
}
|
|
|
|
|
|
|
|
//Try loading PermissionsBukkit
|
2012-02-21 10:22:16 +01:00
|
|
|
if (packageExists("com.platymuus.bukkit.permissions.PermissionsPlugin")) {
|
2011-12-10 05:14:28 +01:00
|
|
|
Permission pPerms = new Permission_PermissionsBukkit(this);
|
2012-01-06 09:19:43 +01:00
|
|
|
sm.register(Permission.class, pPerms, this, ServicePriority.Highest);
|
2011-12-10 05:14:28 +01:00
|
|
|
log.info(String.format("[%s][Permission] PermissionsBukkit found: %s", getDescription().getName(), pPerms.isEnabled() ? "Loaded" : "Waiting"));
|
|
|
|
}
|
2012-02-19 02:04:43 +01:00
|
|
|
|
2012-04-30 16:18:06 +02:00
|
|
|
//Try loading SimplyPerms
|
|
|
|
if (packageExists("net.crystalyx.bukkit.simplyperms.SimplyPlugin")) {
|
|
|
|
Permission sPerms = new Permission_SimplyPerms(this);
|
|
|
|
sm.register(Permission.class, sPerms, this, ServicePriority.Highest);
|
|
|
|
log.info(String.format("[%s][Permission] SimplyPerms found: %s", getDescription().getName(), sPerms.isEnabled() ? "Loaded" : "Waiting"));
|
|
|
|
}
|
2012-02-19 02:04:43 +01:00
|
|
|
|
2012-01-11 21:11:25 +01:00
|
|
|
//try loading bPermissions2
|
2012-02-21 10:22:16 +01:00
|
|
|
if (packageExists("de.bananaco.bpermissions.api.WorldManager")) {
|
2012-01-11 21:11:25 +01:00
|
|
|
Permission bPerms = new Permission_bPermissions2(this);
|
|
|
|
sm.register(Permission.class, bPerms, this, ServicePriority.Highest);
|
|
|
|
log.info(String.format("[%s][Chat] bPermissions found: %s", getDescription().getName(), bPerms.isEnabled() ? "Loaded" : "Waiting"));
|
|
|
|
}
|
2012-02-19 02:04:43 +01:00
|
|
|
|
2012-01-01 01:35:31 +01:00
|
|
|
//Try to load zPermission
|
2012-03-24 03:03:28 +01:00
|
|
|
if (packageExists("org.tyrannyofheaven.bukkit.zPermissions.ZPermissionsPlugin")) {
|
2012-01-01 01:35:31 +01:00
|
|
|
Permission zPerms = new Permission_zPermissions(this);
|
2012-01-06 09:19:43 +01:00
|
|
|
sm.register(Permission.class, zPerms, this, ServicePriority.Highest);
|
2012-03-24 03:03:28 +01:00
|
|
|
log.info(String.format("[%s][Permission] zPermissions found: %s", getDescription().getName(), zPerms.isEnabled() ? "Loaded" : "Waiting"));
|
2012-01-01 01:35:31 +01:00
|
|
|
}
|
2012-01-16 02:15:05 +01:00
|
|
|
|
2012-01-30 01:15:15 +01:00
|
|
|
//Try to load bPermissions
|
2012-02-21 10:22:16 +01:00
|
|
|
if (packageExists("de.bananaco.permissions.SuperPermissionHandler")) {
|
2012-01-30 01:15:15 +01:00
|
|
|
Permission bPerms = new Permission_bPermissions(this);
|
|
|
|
sm.register(Permission.class, bPerms, this, ServicePriority.High);
|
|
|
|
log.info(String.format("[%s][Permission] bPermissions found: %s", getDescription().getName(), bPerms.isEnabled() ? "Loaded" : "Waiting"));
|
|
|
|
}
|
|
|
|
|
2011-12-10 05:14:28 +01:00
|
|
|
// Try to load GroupManager
|
2012-02-21 10:22:16 +01:00
|
|
|
if (packageExists("org.anjocaido.groupmanager.GroupManager")) {
|
2011-12-10 05:14:28 +01:00
|
|
|
Permission gPerms = new Permission_GroupManager(this);
|
2012-01-06 09:19:43 +01:00
|
|
|
sm.register(Permission.class, gPerms, this, ServicePriority.High);
|
2011-12-10 05:14:28 +01:00
|
|
|
log.info(String.format("[%s][Permission] GroupManager found: %s", getDescription().getName(), gPerms.isEnabled() ? "Loaded" : "Waiting"));
|
|
|
|
}
|
|
|
|
// Try to load Permissions 3 (Yeti)
|
2012-02-21 10:22:16 +01:00
|
|
|
if (packageExists("com.nijiko.permissions.ModularControl")) {
|
2011-12-10 05:14:28 +01:00
|
|
|
Permission nPerms = new Permission_Permissions3(this);
|
2012-01-06 09:19:43 +01:00
|
|
|
sm.register(Permission.class, nPerms, this, ServicePriority.High);
|
2011-12-10 05:14:28 +01:00
|
|
|
log.info(String.format("[%s][Permission] Permissions 3 (Yeti) found: %s", getDescription().getName(), nPerms.isEnabled() ? "Loaded" : "Waiting"));
|
|
|
|
}
|
|
|
|
|
|
|
|
Permission perms = new Permission_SuperPerms(this);
|
2012-01-06 09:19:43 +01:00
|
|
|
sm.register(Permission.class, perms, this, ServicePriority.Lowest);
|
2011-12-10 05:14:28 +01:00
|
|
|
log.info(String.format("[%s][Permission] SuperPermissions loaded as backup permission system.", getDescription().getName()));
|
2012-01-16 02:15:05 +01:00
|
|
|
|
2012-01-06 09:19:43 +01:00
|
|
|
this.perms = sm.getRegistration(Permission.class).getProvider();
|
2011-12-10 05:14:28 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean onCommand(CommandSender sender, Command command, String commandLabel, String[] args) {
|
|
|
|
if (sender instanceof Player) {
|
|
|
|
// Check if Player
|
|
|
|
// If so, ignore command if player is not Op
|
|
|
|
Player p = (Player) sender;
|
|
|
|
if (!p.isOp()) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-02-20 18:54:20 +01:00
|
|
|
if (command.getName().equalsIgnoreCase("vault-info")) {
|
|
|
|
infoCommand(sender);
|
|
|
|
return true;
|
|
|
|
} else if (command.getName().equalsIgnoreCase("vault-convert")) {
|
|
|
|
convertCommand(sender, args);
|
|
|
|
return true;
|
2012-04-06 20:10:22 +02:00
|
|
|
} else {
|
2012-02-20 18:54:20 +01:00
|
|
|
// Show help
|
|
|
|
sender.sendMessage("Vault Commands:");
|
|
|
|
sender.sendMessage(" /vault-info - Displays information about Vault");
|
2012-02-21 10:22:16 +01:00
|
|
|
sender.sendMessage(" /vault-convert [economy1] [economy2] - Converts from one Economy to another");
|
2012-02-20 18:54:20 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2011-12-10 05:14:28 +01:00
|
|
|
|
2012-02-20 18:54:20 +01:00
|
|
|
private void convertCommand(CommandSender sender, String[] args) {
|
|
|
|
Collection<RegisteredServiceProvider<Economy>> econs = this.getServer().getServicesManager().getRegistrations(Economy.class);
|
|
|
|
if (econs == null || econs.size() < 2) {
|
|
|
|
sender.sendMessage("You must have at least 2 economies loaded to convert.");
|
|
|
|
return;
|
|
|
|
} else if (args.length != 2) {
|
|
|
|
sender.sendMessage("You must specify only the economy to convert from and the economy to convert to. (without spaces)");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
Economy econ1 = null;
|
|
|
|
Economy econ2 = null;
|
|
|
|
for (RegisteredServiceProvider<Economy> econ : econs) {
|
|
|
|
String econName = econ.getProvider().getName().replace(" ", "");
|
|
|
|
if (econName.equalsIgnoreCase(args[0])) {
|
|
|
|
econ1 = econ.getProvider();
|
|
|
|
} else if (econName.equalsIgnoreCase(args[1])) {
|
|
|
|
econ2 = econ.getProvider();
|
2011-12-10 05:14:28 +01:00
|
|
|
}
|
2012-02-20 18:54:20 +01:00
|
|
|
}
|
2012-02-21 10:22:16 +01:00
|
|
|
|
2012-02-20 18:54:20 +01:00
|
|
|
if (econ1 == null) {
|
|
|
|
sender.sendMessage("Could not find " + args[0] + " loaded on the server, check your spelling");
|
|
|
|
return;
|
|
|
|
} else if (econ2 == null) {
|
|
|
|
sender.sendMessage("Could not find " + args[1] + " loaded on the server, check your spelling");
|
|
|
|
return;
|
|
|
|
}
|
2012-02-21 10:22:16 +01:00
|
|
|
|
2012-02-20 18:54:20 +01:00
|
|
|
sender.sendMessage("This may take some time to convert, expect server lag.");
|
|
|
|
for (OfflinePlayer op : Bukkit.getServer().getOfflinePlayers()) {
|
|
|
|
String pName = op.getName();
|
|
|
|
if (econ1.hasAccount(pName)) {
|
|
|
|
if (econ2.hasAccount(pName)) {
|
|
|
|
continue;
|
2011-12-10 05:14:28 +01:00
|
|
|
}
|
2012-02-20 18:54:20 +01:00
|
|
|
econ2.createPlayerAccount(pName);
|
|
|
|
econ2.depositPlayer(pName, econ1.getBalance(pName));
|
2011-12-10 05:14:28 +01:00
|
|
|
}
|
2012-02-20 18:54:20 +01:00
|
|
|
}
|
|
|
|
}
|
2011-12-10 05:14:28 +01:00
|
|
|
|
2012-02-20 18:54:20 +01:00
|
|
|
private void infoCommand(CommandSender sender) {
|
|
|
|
// Get String of Registered Economy Services
|
|
|
|
String registeredEcons = null;
|
|
|
|
Collection<RegisteredServiceProvider<Economy>> econs = this.getServer().getServicesManager().getRegistrations(Economy.class);
|
|
|
|
for (RegisteredServiceProvider<Economy> econ : econs) {
|
|
|
|
Economy e = econ.getProvider();
|
|
|
|
if (registeredEcons == null) {
|
|
|
|
registeredEcons = e.getName();
|
|
|
|
} else {
|
|
|
|
registeredEcons += ", " + e.getName();
|
|
|
|
}
|
|
|
|
}
|
2011-12-10 05:14:28 +01:00
|
|
|
|
2012-02-20 18:54:20 +01:00
|
|
|
// Get String of Registered Permission Services
|
|
|
|
String registeredPerms = null;
|
|
|
|
Collection<RegisteredServiceProvider<Permission>> perms = this.getServer().getServicesManager().getRegistrations(Permission.class);
|
|
|
|
for (RegisteredServiceProvider<Permission> perm : perms) {
|
|
|
|
Permission p = perm.getProvider();
|
|
|
|
if (registeredPerms == null) {
|
|
|
|
registeredPerms = p.getName();
|
|
|
|
} else {
|
|
|
|
registeredPerms += ", " + p.getName();
|
|
|
|
}
|
2011-12-10 05:14:28 +01:00
|
|
|
}
|
2012-02-20 18:54:20 +01:00
|
|
|
|
2012-04-25 16:21:24 +02:00
|
|
|
String registeredChats = null;
|
|
|
|
Collection<RegisteredServiceProvider<Chat>> chats = this.getServer().getServicesManager().getRegistrations(Chat.class);
|
|
|
|
for (RegisteredServiceProvider<Chat> chat : chats) {
|
|
|
|
Chat c = chat.getProvider();
|
|
|
|
if (registeredChats == null) {
|
|
|
|
registeredChats = c.getName();
|
|
|
|
} else {
|
|
|
|
registeredChats += ", " + c.getName();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-02-20 18:54:20 +01:00
|
|
|
// Get Economy & Permission primary Services
|
2012-04-25 16:16:44 +02:00
|
|
|
RegisteredServiceProvider<Economy> rsp = getServer().getServicesManager().getRegistration(Economy.class);
|
|
|
|
Economy econ = null;
|
|
|
|
if (rsp != null) {
|
|
|
|
econ = rsp.getProvider();
|
|
|
|
}
|
|
|
|
Permission perm = null;
|
|
|
|
RegisteredServiceProvider<Permission> rspp = getServer().getServicesManager().getRegistration(Permission.class);
|
|
|
|
if (rspp != null) {
|
|
|
|
perm = rspp.getProvider();
|
|
|
|
}
|
2012-04-25 16:21:24 +02:00
|
|
|
Chat chat = null;
|
|
|
|
RegisteredServiceProvider<Chat> rspc = getServer().getServicesManager().getRegistration(Chat.class);
|
|
|
|
if (rspc != null) {
|
|
|
|
chat = rspc.getProvider();
|
|
|
|
}
|
2012-02-20 18:54:20 +01:00
|
|
|
// Send user some info!
|
|
|
|
sender.sendMessage(String.format("[%s] Vault v%s Information", getDescription().getName(), getDescription().getVersion()));
|
2012-04-25 16:16:44 +02:00
|
|
|
sender.sendMessage(String.format("[%s] Economy: %s [%s]", getDescription().getName(), econ == null ? "None" : econ.getName(), registeredEcons));
|
|
|
|
sender.sendMessage(String.format("[%s] Permission: %s [%s]", getDescription().getName(), perm == null ? "None" : perm.getName(), registeredPerms));
|
2012-04-25 16:21:24 +02:00
|
|
|
sender.sendMessage(String.format("[%s] Chat: %s [%s]", getDescription().getName(), chat == null ? "None" : chat.getName(), registeredChats));
|
2011-12-10 05:14:28 +01:00
|
|
|
}
|
2012-01-16 02:15:05 +01:00
|
|
|
|
2011-12-10 05:14:28 +01:00
|
|
|
/**
|
|
|
|
* Determines if all packages in a String array are within the Classpath
|
|
|
|
* This is the best way to determine if a specific plugin exists and will be
|
|
|
|
* loaded. If the plugin package isn't loaded, we shouldn't bother waiting
|
|
|
|
* for it!
|
|
|
|
* @param packages String Array of package names to check
|
|
|
|
* @return Success or Failure
|
|
|
|
*/
|
2012-02-21 10:22:16 +01:00
|
|
|
private static boolean packageExists(String...packages) {
|
2011-12-10 05:14:28 +01:00
|
|
|
try {
|
|
|
|
for (String pkg : packages) {
|
|
|
|
Class.forName(pkg);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
} catch (Exception e) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2012-01-16 02:15:05 +01:00
|
|
|
|
2012-02-27 17:54:43 +01:00
|
|
|
public double updateCheck(double currentVersion) throws Exception {
|
2011-12-10 05:14:28 +01:00
|
|
|
String pluginUrlString = "http://dev.bukkit.org/server-mods/vault/files.rss";
|
|
|
|
try {
|
|
|
|
URL url = new URL(pluginUrlString);
|
|
|
|
Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(url.openConnection().getInputStream());
|
|
|
|
doc.getDocumentElement().normalize();
|
|
|
|
NodeList nodes = doc.getElementsByTagName("item");
|
|
|
|
Node firstNode = nodes.item(0);
|
|
|
|
if (firstNode.getNodeType() == 1) {
|
|
|
|
Element firstElement = (Element)firstNode;
|
|
|
|
NodeList firstElementTagName = firstElement.getElementsByTagName("title");
|
|
|
|
Element firstNameElement = (Element) firstElementTagName.item(0);
|
|
|
|
NodeList firstNodes = firstNameElement.getChildNodes();
|
2012-02-27 17:54:43 +01:00
|
|
|
return Double.valueOf(firstNodes.item(0).getNodeValue().replace("Vault", "").replaceFirst(".", "").trim());
|
2011-12-10 05:14:28 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception localException) {
|
|
|
|
}
|
2011-12-18 19:38:09 +01:00
|
|
|
return currentVersion;
|
2011-12-10 05:14:28 +01:00
|
|
|
}
|
2012-01-16 02:15:05 +01:00
|
|
|
|
2012-01-25 23:31:13 +01:00
|
|
|
public class VaultListener implements Listener {
|
2012-01-16 02:15:05 +01:00
|
|
|
|
2012-01-25 23:31:13 +01:00
|
|
|
@EventHandler(priority = EventPriority.MONITOR)
|
2011-12-10 05:14:28 +01:00
|
|
|
public void onPlayerJoin(PlayerJoinEvent event) {
|
|
|
|
Player player = event.getPlayer();
|
|
|
|
if (perms.has(player, "vault.admin")) {
|
|
|
|
try {
|
2012-02-18 20:16:13 +01:00
|
|
|
if (newVersion > currentVersion) {
|
2012-02-29 21:20:11 +01:00
|
|
|
player.sendMessage(newVersion + " is out! You are running " + currentVersion);
|
2011-12-10 05:14:28 +01:00
|
|
|
player.sendMessage("Update Vault at: http://dev.bukkit.org/server-mods/vault");
|
|
|
|
}
|
|
|
|
} catch (Exception e) {
|
|
|
|
// Ignore exceptions
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-01-30 01:15:15 +01:00
|
|
|
|
2012-01-25 23:31:13 +01:00
|
|
|
@EventHandler(priority = EventPriority.MONITOR)
|
2012-01-16 02:10:53 +01:00
|
|
|
public void onPluginEnable(PluginEnableEvent event) {
|
2012-02-27 17:42:16 +01:00
|
|
|
if (event.getPlugin().getDescription().getName().equals("Register") && packageExists("com.nijikokun.register.payment.Methods")) {
|
2012-01-16 02:15:05 +01:00
|
|
|
if (!Methods.hasMethod()) {
|
|
|
|
try {
|
|
|
|
Method m = Methods.class.getMethod("addMethod", Methods.class);
|
|
|
|
m.setAccessible(true);
|
|
|
|
m.invoke(null, "Vault", new net.milkbowl.vault.VaultEco());
|
|
|
|
if (!Methods.setPreferred("Vault")) {
|
|
|
|
log.info("Unable to hook register");
|
|
|
|
} else {
|
|
|
|
log.info("[Vault] - Successfully injected Vault methods into Register.");
|
|
|
|
}
|
|
|
|
} catch (SecurityException e) {
|
|
|
|
log.info("Unable to hook register");
|
|
|
|
} catch (NoSuchMethodException e) {
|
|
|
|
log.info("Unable to hook register");
|
|
|
|
} catch (IllegalArgumentException e) {
|
|
|
|
log.info("Unable to hook register");
|
|
|
|
} catch (IllegalAccessException e) {
|
|
|
|
log.info("Unable to hook register");
|
|
|
|
} catch (InvocationTargetException e) {
|
2012-01-16 02:10:53 +01:00
|
|
|
log.info("Unable to hook register");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-02-21 00:33:06 +01:00
|
|
|
}
|