2011-06-29 02:18:20 +02:00
|
|
|
/**
|
|
|
|
* Copyright (C) 2011 Morgan Humes <morgan@lanaddict.com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program 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 General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
package net.milkbowl.vault;
|
|
|
|
|
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-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;
|
|
|
|
import net.milkbowl.vault.chat.plugins.Chat_mChat;
|
2011-06-30 17:14:09 +02:00
|
|
|
import net.milkbowl.vault.economy.Economy;
|
|
|
|
import net.milkbowl.vault.economy.plugins.Economy_3co;
|
2011-10-10 08:02:05 +02:00
|
|
|
import net.milkbowl.vault.economy.plugins.Economy_BOSE6;
|
|
|
|
import net.milkbowl.vault.economy.plugins.Economy_BOSE7;
|
2011-06-30 17:14:09 +02:00
|
|
|
import net.milkbowl.vault.economy.plugins.Economy_Essentials;
|
2011-09-23 08:43:48 +02:00
|
|
|
import net.milkbowl.vault.economy.plugins.Economy_MultiCurrency;
|
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_Permissions2;
|
|
|
|
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;
|
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;
|
2011-06-29 02:18:20 +02:00
|
|
|
|
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.command.ConsoleCommandSender;
|
|
|
|
import org.bukkit.entity.Player;
|
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;
|
2011-06-29 02:18:20 +02:00
|
|
|
import org.bukkit.plugin.java.JavaPlugin;
|
|
|
|
|
|
|
|
public class Vault extends JavaPlugin {
|
2011-08-12 19:11:25 +02:00
|
|
|
|
2011-06-29 02:18:20 +02:00
|
|
|
private static final Logger log = Logger.getLogger("Minecraft");
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onDisable() {
|
2011-07-19 16:40:27 +02:00
|
|
|
// Remove all Service Registrations
|
2011-07-19 16:33:01 +02:00
|
|
|
getServer().getServicesManager().unregisterAll(this);
|
2011-08-12 19:11:25 +02:00
|
|
|
|
2011-06-29 02:18:20 +02:00
|
|
|
log.info(String.format("[%s] Disabled Version %s", getDescription().getName(), getDescription().getVersion()));
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onEnable() {
|
2011-06-30 15:49:26 +02:00
|
|
|
// Load Vault Addons
|
|
|
|
loadEconomy();
|
|
|
|
loadPermission();
|
2011-10-23 22:18:23 +02:00
|
|
|
loadChat();
|
2011-08-12 19:11:25 +02:00
|
|
|
|
2011-07-18 18:34:54 +02:00
|
|
|
getCommand("vault-info").setExecutor(this);
|
|
|
|
getCommand("vault-reload").setExecutor(this);
|
2011-06-29 02:18:20 +02:00
|
|
|
log.info(String.format("[%s] Enabled Version %s", getDescription().getName(), getDescription().getVersion()));
|
|
|
|
}
|
|
|
|
|
2011-10-23 22:18:23 +02:00
|
|
|
/**
|
|
|
|
* Attempts to load Chat Addons
|
|
|
|
*/
|
|
|
|
private void loadChat() {
|
|
|
|
|
|
|
|
// Try to load PermissionsEx
|
|
|
|
if (packageExists(new String[] { "ru.tehkode.permissions.bukkit.PermissionsEx" })) {
|
|
|
|
Chat eChat = new Chat_PermissionsEx(this);
|
|
|
|
getServer().getServicesManager().register(net.milkbowl.vault.chat.Chat.class, eChat, this, ServicePriority.Highest);
|
|
|
|
log.info(String.format("[%s][Chat] PermissionsEx found: %s", getDescription().getName(), eChat.isEnabled() ? "Loaded" : "Waiting"));
|
|
|
|
} else {
|
|
|
|
log.info(String.format("[%s][Chat] PermissionsEx not found.", getDescription().getName()));
|
|
|
|
}
|
|
|
|
|
|
|
|
//Try loading mChat
|
|
|
|
if (packageExists(new String[] {"net.D3GN.MiracleM4n.mChat"} )) {
|
|
|
|
Chat mChat = new Chat_mChat(this);
|
|
|
|
getServer().getServicesManager().register(net.milkbowl.vault.chat.Chat.class, mChat, this, ServicePriority.Highest);
|
|
|
|
log.info(String.format("[%s][Chat] mChat found: %s", getDescription().getName(), mChat.isEnabled() ? "Loaded" : "Waiting"));
|
|
|
|
} else {
|
|
|
|
log.info(String.format("[%s][Chat] mChat not found.", getDescription().getName()));
|
|
|
|
}
|
|
|
|
|
|
|
|
// Try to load GroupManager
|
|
|
|
if (packageExists(new String[] { "org.anjocaido.groupmanager.GroupManager" })) {
|
|
|
|
Chat gPerms = new Chat_GroupManager(this);
|
|
|
|
getServer().getServicesManager().register(net.milkbowl.vault.chat.Chat.class, gPerms, this, ServicePriority.High);
|
|
|
|
log.info(String.format("[%s][Chat] GroupManager found: %s", getDescription().getName(), gPerms.isEnabled() ? "Loaded" : "Waiting"));
|
|
|
|
} else {
|
|
|
|
log.info(String.format("[%s][Chat] GroupManager not found.", getDescription().getName()));
|
|
|
|
}
|
|
|
|
|
|
|
|
// Try to load Permissions 3 (Yeti)
|
|
|
|
if (packageExists(new String[] { "com.nijiko.permissions.ModularControl" })) {
|
|
|
|
Chat nPerms = new Chat_Permissions3(this);
|
|
|
|
getServer().getServicesManager().register(net.milkbowl.vault.chat.Chat.class, nPerms, this, ServicePriority.High);
|
|
|
|
log.info(String.format("[%s][Chat] Permissions 3 (Yeti) found: %s", getDescription().getName(), nPerms.isEnabled() ? "Loaded" : "Waiting"));
|
|
|
|
} else {
|
|
|
|
log.info(String.format("[%s][Chat] Permissions 3 (Yeti) not found.", getDescription().getName()));
|
|
|
|
}
|
|
|
|
|
|
|
|
// Try to load Permissions 2 (Phoenix)
|
|
|
|
if (packageExists(new String[] { "com.nijiko.permissions.Control" })) {
|
|
|
|
Permission oPerms = new Permission_Permissions2(this);
|
|
|
|
getServer().getServicesManager().register(net.milkbowl.vault.permission.Permission.class, oPerms, this, ServicePriority.Low);
|
|
|
|
log.info(String.format("[%s][Chat] Permissions 2 (Phoenix) found: %s", getDescription().getName(), oPerms.isEnabled() ? "Loaded" : "Waiting"));
|
|
|
|
} else {
|
|
|
|
log.info(String.format("[%s][Chat] Permissions 2 (Phoenix) not found.", getDescription().getName()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-06-30 16:37:26 +02:00
|
|
|
/**
|
|
|
|
* Attempts to load Economy Addons
|
|
|
|
*/
|
2011-06-30 15:49:26 +02:00
|
|
|
private void loadEconomy() {
|
2011-09-23 08:43:48 +02:00
|
|
|
// Try to load MultiCurrency
|
|
|
|
if (packageExists(new String[] { "me.ashtheking.currency.Currency", "me.ashtheking.currency.CurrencyList" })) {
|
|
|
|
Economy econ = new Economy_MultiCurrency(this);
|
|
|
|
getServer().getServicesManager().register(net.milkbowl.vault.economy.Economy.class, econ, this, ServicePriority.Normal);
|
|
|
|
log.info(String.format("[%s][Economy] MultiCurrency found: %s", getDescription().getName(), econ.isEnabled() ? "Loaded" : "Waiting"));
|
|
|
|
} else {
|
|
|
|
log.info(String.format("[%s][Economy] MultiCurrency not found.", getDescription().getName()));
|
|
|
|
}
|
|
|
|
|
2011-06-30 15:49:26 +02:00
|
|
|
// Try to load 3co
|
2011-08-12 19:11:25 +02:00
|
|
|
if (packageExists(new String[] { "me.ic3d.eco.ECO" })) {
|
2011-06-30 15:49:26 +02:00
|
|
|
Economy econ = new Economy_3co(this);
|
2011-07-19 16:33:01 +02:00
|
|
|
getServer().getServicesManager().register(net.milkbowl.vault.economy.Economy.class, econ, this, ServicePriority.Normal);
|
2011-06-30 15:49:26 +02:00
|
|
|
log.info(String.format("[%s][Economy] 3co found: %s", getDescription().getName(), econ.isEnabled() ? "Loaded" : "Waiting"));
|
|
|
|
} else {
|
|
|
|
log.info(String.format("[%s][Economy] 3co not found.", getDescription().getName()));
|
|
|
|
}
|
2011-08-12 19:11:25 +02:00
|
|
|
|
2011-06-30 15:49:26 +02:00
|
|
|
// Try to load BOSEconomy
|
2011-10-10 08:36:29 +02:00
|
|
|
if (packageExists(new String[] { "cosine.boseconomy.BOSEconomy", "cosine.boseconomy.CommandManager" })) {
|
2011-10-10 08:02:05 +02:00
|
|
|
Economy bose6 = new Economy_BOSE6(this);
|
|
|
|
getServer().getServicesManager().register(net.milkbowl.vault.economy.Economy.class, bose6, this, ServicePriority.Normal);
|
|
|
|
log.info(String.format("[%s][Economy] BOSEconomy6 found: %s", getDescription().getName(), bose6.isEnabled() ? "Loaded" : "Waiting"));
|
2011-06-30 15:49:26 +02:00
|
|
|
} else {
|
2011-10-10 08:02:05 +02:00
|
|
|
log.info(String.format("[%s][Economy] BOSEconomy6 not found.", getDescription().getName()));
|
|
|
|
}
|
|
|
|
// Try to load BOSEconomy
|
2011-10-10 08:36:29 +02:00
|
|
|
if (packageExists(new String[] { "cosine.boseconomy.BOSEconomy", "cosine.boseconomy.CommandHandler" })) {
|
2011-10-10 08:02:05 +02:00
|
|
|
Economy bose7 = new Economy_BOSE7(this);
|
|
|
|
getServer().getServicesManager().register(net.milkbowl.vault.economy.Economy.class, bose7, this, ServicePriority.Normal);
|
|
|
|
log.info(String.format("[%s][Economy] BOSEconomy7 found: %s", getDescription().getName(), bose7.isEnabled() ? "Loaded" : "Waiting"));
|
|
|
|
} else {
|
|
|
|
log.info(String.format("[%s][Economy] BOSEconomy7 not found.", getDescription().getName()));
|
2011-06-30 15:49:26 +02:00
|
|
|
}
|
|
|
|
// Try to load Essentials Economy
|
|
|
|
if (packageExists(new String[] { "com.earth2me.essentials.api.Economy", "com.earth2me.essentials.api.NoLoanPermittedException", "com.earth2me.essentials.api.UserDoesNotExistException" })) {
|
|
|
|
Economy essentials = new Economy_Essentials(this);
|
2011-07-19 16:33:01 +02:00
|
|
|
getServer().getServicesManager().register(net.milkbowl.vault.economy.Economy.class, essentials, this, ServicePriority.Low);
|
2011-06-30 15:49:26 +02:00
|
|
|
log.info(String.format("[%s][Economy] Essentials Economy found: %s", getDescription().getName(), essentials.isEnabled() ? "Loaded" : "Waiting"));
|
|
|
|
} else {
|
|
|
|
log.info(String.format("[%s][Economy] Essentials Economy not found.", getDescription().getName()));
|
|
|
|
}
|
|
|
|
|
|
|
|
// Try to load iConomy 4
|
|
|
|
if (packageExists(new String[] { "com.nijiko.coelho.iConomy.iConomy", "com.nijiko.coelho.iConomy.system.Account" })) {
|
|
|
|
Economy icon4 = new Economy_iConomy4(this);
|
2011-09-23 20:40:21 +02:00
|
|
|
getServer().getServicesManager().register(net.milkbowl.vault.economy.Economy.class, icon4, this, ServicePriority.High);
|
2011-06-30 15:49:26 +02:00
|
|
|
log.info(String.format("[%s][Economy] iConomy 4 found: ", getDescription().getName(), icon4.isEnabled() ? "Loaded" : "Waiting"));
|
|
|
|
} else {
|
|
|
|
log.info(String.format("[%s][Economy] iConomy 4 not found.", getDescription().getName()));
|
|
|
|
}
|
|
|
|
|
|
|
|
// Try to load iConomy 5
|
|
|
|
if (packageExists(new String[] { "com.iConomy.iConomy", "com.iConomy.system.Account", "com.iConomy.system.Holdings" })) {
|
|
|
|
Economy icon5 = new Economy_iConomy5(this);
|
2011-09-23 20:40:21 +02:00
|
|
|
getServer().getServicesManager().register(net.milkbowl.vault.economy.Economy.class, icon5, this, ServicePriority.High);
|
2011-06-30 15:49:26 +02:00
|
|
|
log.info(String.format("[%s][Economy] iConomy 5 found: %s", getDescription().getName(), icon5.isEnabled() ? "Loaded" : "Waiting"));
|
|
|
|
} else {
|
|
|
|
log.info(String.format("[%s][Economy] iConomy 5 not found.", getDescription().getName()));
|
|
|
|
}
|
2011-08-12 19:11:25 +02:00
|
|
|
|
2011-08-11 23:18:25 +02:00
|
|
|
// Try to load iConomy 6
|
|
|
|
if (packageExists(new String[] { "com.iCo6.iConomy" })) {
|
|
|
|
Economy icon6 = new Economy_iConomy6(this);
|
2011-09-23 20:40:21 +02:00
|
|
|
getServer().getServicesManager().register(net.milkbowl.vault.economy.Economy.class, icon6, this, ServicePriority.High);
|
2011-08-11 23:18:25 +02:00
|
|
|
log.info(String.format("[%s][Economy] iConomy 6 found: %s", getDescription().getName(), icon6.isEnabled() ? "Loaded" : "Waiting"));
|
|
|
|
} else {
|
|
|
|
log.info(String.format("[%s][Economy] iConomy 6 not found.", getDescription().getName()));
|
|
|
|
}
|
2011-06-30 15:49:26 +02:00
|
|
|
}
|
2011-08-12 19:11:25 +02:00
|
|
|
|
2011-06-30 16:37:26 +02:00
|
|
|
/**
|
|
|
|
* Attempts to load Permission Addons
|
|
|
|
*/
|
2011-06-30 15:49:26 +02:00
|
|
|
private void loadPermission() {
|
|
|
|
// Try to load PermissionsEx
|
2011-08-12 19:11:25 +02:00
|
|
|
if (packageExists(new String[] { "ru.tehkode.permissions.bukkit.PermissionsEx" })) {
|
2011-06-30 15:49:26 +02:00
|
|
|
Permission ePerms = new Permission_PermissionsEx(this);
|
2011-09-25 02:53:09 +02:00
|
|
|
getServer().getServicesManager().register(net.milkbowl.vault.permission.Permission.class, ePerms, this, ServicePriority.Highest);
|
2011-06-30 15:49:26 +02:00
|
|
|
log.info(String.format("[%s][Permission] PermissionsEx found: %s", getDescription().getName(), ePerms.isEnabled() ? "Loaded" : "Waiting"));
|
|
|
|
} else {
|
|
|
|
log.info(String.format("[%s][Permission] PermissionsEx not found.", getDescription().getName()));
|
|
|
|
}
|
2011-09-18 10:19:35 +02:00
|
|
|
|
|
|
|
//Try loading PermissionsBukkit
|
|
|
|
if (packageExists(new String[] {"com.platymuus.bukkit.permissions.PermissionsPlugin"} )) {
|
|
|
|
Permission pPerms = new Permission_PermissionsBukkit(this);
|
2011-09-25 02:53:09 +02:00
|
|
|
getServer().getServicesManager().register(net.milkbowl.vault.permission.Permission.class, pPerms, this, ServicePriority.Highest);
|
2011-09-18 10:19:35 +02:00
|
|
|
log.info(String.format("[%s][Permission] PermissionsBukkit found: %s", getDescription().getName(), pPerms.isEnabled() ? "Loaded" : "Waiting"));
|
|
|
|
} else {
|
|
|
|
log.info(String.format("[%s][Permission] PermissionsBukkit not found.", getDescription().getName()));
|
|
|
|
}
|
2011-10-28 22:41:02 +02:00
|
|
|
if (packageExists(new String[] {"de.bananaco.permissions.worlds.WorldPermissionsManager"} )) {
|
|
|
|
Permission bPerms = new Permission_bPermissions(this);
|
|
|
|
getServer().getServicesManager().register(net.milkbowl.vault.permission.Permission.class, bPerms, this, ServicePriority.Highest);
|
|
|
|
log.info(String.format("[%s][Permission] bPermissions found: %s", getDescription().getName(), bPerms.isEnabled() ? "Loaded" : "Waiting"));
|
|
|
|
} else {
|
|
|
|
log.info(String.format("[%s][Permission] bPermissions not found.", getDescription().getName()));
|
|
|
|
}
|
2011-08-12 19:11:25 +02:00
|
|
|
// Try to load GroupManager
|
|
|
|
if (packageExists(new String[] { "org.anjocaido.groupmanager.GroupManager" })) {
|
|
|
|
Permission gPerms = new Permission_GroupManager(this);
|
2011-09-18 10:19:35 +02:00
|
|
|
getServer().getServicesManager().register(net.milkbowl.vault.permission.Permission.class, gPerms, this, ServicePriority.High);
|
2011-08-12 19:11:25 +02:00
|
|
|
log.info(String.format("[%s][Permission] GroupManager found: %s", getDescription().getName(), gPerms.isEnabled() ? "Loaded" : "Waiting"));
|
2011-08-08 09:05:32 +02:00
|
|
|
} else {
|
|
|
|
log.info(String.format("[%s][Permission] GroupManager not found.", getDescription().getName()));
|
|
|
|
}
|
2011-08-12 19:11:25 +02:00
|
|
|
|
2011-08-11 22:55:28 +02:00
|
|
|
// Try to load Permissions 3 (Yeti)
|
2011-08-09 17:43:15 +02:00
|
|
|
if (packageExists(new String[] { "com.nijiko.permissions.ModularControl" })) {
|
|
|
|
Permission nPerms = new Permission_Permissions3(this);
|
2011-09-25 02:53:09 +02:00
|
|
|
getServer().getServicesManager().register(net.milkbowl.vault.permission.Permission.class, nPerms, this, ServicePriority.High);
|
2011-08-11 22:55:28 +02:00
|
|
|
log.info(String.format("[%s][Permission] Permissions 3 (Yeti) found: %s", getDescription().getName(), nPerms.isEnabled() ? "Loaded" : "Waiting"));
|
2011-06-30 15:49:26 +02:00
|
|
|
} else {
|
2011-08-11 22:55:28 +02:00
|
|
|
log.info(String.format("[%s][Permission] Permissions 3 (Yeti) not found.", getDescription().getName()));
|
2011-08-09 17:43:15 +02:00
|
|
|
}
|
2011-08-12 19:11:25 +02:00
|
|
|
|
|
|
|
// Try to load Permissions 2 (Phoenix)
|
|
|
|
if (packageExists(new String[] { "com.nijiko.permissions.Control" })) {
|
|
|
|
Permission oPerms = new Permission_Permissions2(this);
|
2011-09-18 10:19:35 +02:00
|
|
|
getServer().getServicesManager().register(net.milkbowl.vault.permission.Permission.class, oPerms, this, ServicePriority.Low);
|
2011-08-12 19:11:25 +02:00
|
|
|
log.info(String.format("[%s][Permission] Permissions 2 (Phoenix) found: %s", getDescription().getName(), oPerms.isEnabled() ? "Loaded" : "Waiting"));
|
2011-08-09 17:43:15 +02:00
|
|
|
} else {
|
2011-08-11 22:55:28 +02:00
|
|
|
log.info(String.format("[%s][Permission] Permissions 2 (Phoenix) not found.", getDescription().getName()));
|
2011-06-30 15:49:26 +02:00
|
|
|
}
|
2011-09-18 10:19:35 +02:00
|
|
|
|
|
|
|
Permission perms = new Permission_SuperPerms(this);
|
|
|
|
getServer().getServicesManager().register(net.milkbowl.vault.permission.Permission.class, perms, this, ServicePriority.Lowest);
|
2011-09-25 02:53:09 +02:00
|
|
|
log.info(String.format("[%s][Permission] SuperPermissions loaded as backup permission system.", getDescription().getName()));
|
2011-08-12 19:11:25 +02:00
|
|
|
|
2011-06-30 15:49:26 +02:00
|
|
|
}
|
2011-08-12 19:11:25 +02:00
|
|
|
|
2011-06-30 15:49:26 +02:00
|
|
|
@Override
|
|
|
|
public boolean onCommand(CommandSender sender, Command command, String commandLabel, String[] args) {
|
2011-08-12 19:11:25 +02:00
|
|
|
if (sender instanceof Player) {
|
2011-06-30 17:14:09 +02:00
|
|
|
// Check if Player
|
|
|
|
// If so, ignore command if player is not Op
|
|
|
|
Player p = (Player) sender;
|
2011-08-12 19:11:25 +02:00
|
|
|
if (!p.isOp()) {
|
2011-06-30 17:14:09 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
} else if (!(sender instanceof ConsoleCommandSender)) {
|
|
|
|
// Check if NOT console
|
|
|
|
// Ignore it if not originated from Console!
|
|
|
|
return true;
|
|
|
|
}
|
2011-08-12 19:11:25 +02:00
|
|
|
|
2011-07-19 16:40:27 +02:00
|
|
|
if (command.getLabel().equals("vault-info")) {
|
2011-08-12 19:11:25 +02:00
|
|
|
|
2011-07-19 16:40:27 +02:00
|
|
|
// Get String of Registered Economy Services
|
|
|
|
String registeredEcons = null;
|
|
|
|
Collection<RegisteredServiceProvider<Economy>> econs = this.getServer().getServicesManager().getRegistrations(net.milkbowl.vault.economy.Economy.class);
|
2011-08-12 19:11:25 +02:00
|
|
|
for (RegisteredServiceProvider<Economy> econ : econs) {
|
2011-07-19 16:40:27 +02:00
|
|
|
Economy e = econ.getProvider();
|
2011-08-12 19:11:25 +02:00
|
|
|
if (registeredEcons == null) {
|
2011-07-19 16:40:27 +02:00
|
|
|
registeredEcons = e.getName();
|
|
|
|
} else {
|
|
|
|
registeredEcons += ", " + e.getName();
|
|
|
|
}
|
2011-07-19 16:33:01 +02:00
|
|
|
}
|
2011-08-12 19:11:25 +02:00
|
|
|
|
2011-07-19 16:40:27 +02:00
|
|
|
// Get String of Registered Permission Services
|
|
|
|
String registeredPerms = null;
|
|
|
|
Collection<RegisteredServiceProvider<Permission>> perms = this.getServer().getServicesManager().getRegistrations(net.milkbowl.vault.permission.Permission.class);
|
2011-08-12 19:11:25 +02:00
|
|
|
for (RegisteredServiceProvider<Permission> perm : perms) {
|
2011-07-19 16:40:27 +02:00
|
|
|
Permission p = perm.getProvider();
|
2011-08-12 19:11:25 +02:00
|
|
|
if (registeredPerms == null) {
|
2011-07-19 16:40:27 +02:00
|
|
|
registeredPerms = p.getName();
|
|
|
|
} else {
|
|
|
|
registeredPerms += ", " + p.getName();
|
|
|
|
}
|
2011-07-19 16:33:01 +02:00
|
|
|
}
|
2011-08-12 19:11:25 +02:00
|
|
|
|
2011-07-19 16:40:27 +02:00
|
|
|
// Get Economy & Permission primary Services
|
|
|
|
Economy econ = getServer().getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class).getProvider();
|
|
|
|
Permission perm = getServer().getServicesManager().getRegistration(net.milkbowl.vault.permission.Permission.class).getProvider();
|
2011-08-12 19:11:25 +02:00
|
|
|
|
2011-07-19 16:40:27 +02:00
|
|
|
// Send user some info!
|
2011-07-18 18:34:54 +02:00
|
|
|
sender.sendMessage(String.format("[%s] Vault v%s Information", getDescription().getName(), getDescription().getVersion()));
|
2011-07-19 16:33:01 +02:00
|
|
|
sender.sendMessage(String.format("[%s] Economy: %s [%s]", getDescription().getName(), econ.getName(), registeredEcons));
|
|
|
|
sender.sendMessage(String.format("[%s] Permission: %s [%s]", getDescription().getName(), perm.getName(), registeredPerms));
|
2011-07-18 18:34:54 +02:00
|
|
|
return true;
|
2011-07-19 16:40:27 +02:00
|
|
|
} else {
|
|
|
|
// Show help
|
|
|
|
sender.sendMessage("Vault Commands:");
|
|
|
|
sender.sendMessage(" /vault-info - Displays information about Vault");
|
2011-07-18 18:34:54 +02:00
|
|
|
return true;
|
2011-06-30 15:49:26 +02:00
|
|
|
}
|
2011-06-29 02:18:20 +02:00
|
|
|
}
|
2011-08-12 19:11:25 +02:00
|
|
|
|
2011-06-30 16:37:26 +02:00
|
|
|
/**
|
|
|
|
* Determines if all packages in a String array are within the Classpath
|
2011-08-12 19:11:25 +02:00
|
|
|
* 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!
|
2011-06-30 16:37:26 +02:00
|
|
|
* @param packages String Array of package names to check
|
|
|
|
* @return Success or Failure
|
|
|
|
*/
|
2011-07-05 20:37:51 +02:00
|
|
|
private static boolean packageExists(String[] packages) {
|
2011-06-30 15:49:26 +02:00
|
|
|
try {
|
|
|
|
for (String pkg : packages) {
|
|
|
|
Class.forName(pkg);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
} catch (Exception e) {
|
|
|
|
return false;
|
|
|
|
}
|
2011-06-29 02:18:20 +02:00
|
|
|
}
|
|
|
|
}
|