adjust constructor reflection to explicitly check for Vault, not Plugin.

This commit is contained in:
Sleaker 2012-06-30 00:11:51 -07:00
parent 6e26ffb42a
commit 2f6c67b5e9

View File

@ -155,120 +155,120 @@ public class Vault extends JavaPlugin {
* Attempts to load Chat Addons
*/
private void loadChat() {
// Try to load PermissionsEx
hookChat("PermissionsEx", Chat_PermissionsEx.class, ServicePriority.Highest, "ru.tehkode.permissions.bukkit.PermissionsEx");
// Try to load PermissionsEx
hookChat("PermissionsEx", Chat_PermissionsEx.class, ServicePriority.Highest, "ru.tehkode.permissions.bukkit.PermissionsEx");
// Try to load mChatSuite
hookChat("mChatSuite", Chat_mChatSuite.class, ServicePriority.Highest, "in.mDev.MiracleM4n.mChatSuite.mChatSuite");
// Try to load mChatSuite
hookChat("mChatSuite", Chat_mChatSuite.class, ServicePriority.Highest, "in.mDev.MiracleM4n.mChatSuite.mChatSuite");
// Try to load mChat
hookChat("mChat", Chat_mChat.class, ServicePriority.Highest, "net.D3GN.MiracleM4n.mChat");
// Try to load mChat
hookChat("mChat", Chat_mChat.class, ServicePriority.Highest, "net.D3GN.MiracleM4n.mChat");
// Try to load DroxPerms Chat
hookChat("DroxPerms", Chat_DroxPerms.class, ServicePriority.Lowest, "de.hydrox.bukkit.DroxPerms.DroxPerms");
// Try to load DroxPerms Chat
hookChat("DroxPerms", Chat_DroxPerms.class, ServicePriority.Lowest, "de.hydrox.bukkit.DroxPerms.DroxPerms");
// Try to load bPermssions 2
hookChat("bPermssions2", Chat_bPermissions2.class, ServicePriority.Highest, "de.bananaco.bpermissions.api.ApiLayer");
// Try to load bPermssions 2
hookChat("bPermssions2", Chat_bPermissions2.class, ServicePriority.Highest, "de.bananaco.bpermissions.api.ApiLayer");
// Try to load bPermissions 1
hookChat("bPermissions", Chat_bPermissions.class, ServicePriority.Normal, "de.bananaco.permissions.info.InfoReader");
// Try to load bPermissions 1
hookChat("bPermissions", Chat_bPermissions.class, ServicePriority.Normal, "de.bananaco.permissions.info.InfoReader");
// Try to load GroupManager
hookChat("GroupManager", Chat_GroupManager.class, ServicePriority.Normal, "org.anjocaido.groupmanager.GroupManager");
// Try to load GroupManager
hookChat("GroupManager", Chat_GroupManager.class, ServicePriority.Normal, "org.anjocaido.groupmanager.GroupManager");
// Try to load Permissions 3 (Yeti)
hookChat("Permissions3", Chat_Permissions3.class, ServicePriority.Normal, "com.nijiko.permissions.ModularControl");
// Try to load Permissions 3 (Yeti)
hookChat("Permissions3", Chat_Permissions3.class, ServicePriority.Normal, "com.nijiko.permissions.ModularControl");
// Try to load iChat
hookChat("iChat", Chat_iChat.class, ServicePriority.Low, "net.TheDgtl.iChat.iChat");
// Try to load iChat
hookChat("iChat", Chat_iChat.class, ServicePriority.Low, "net.TheDgtl.iChat.iChat");
}
/**
* Attempts to load Economy Addons
*/
private void loadEconomy() {
// Try to load MultiCurrency
hookEconomy("MultiCurrency", Economy_MultiCurrency.class, ServicePriority.Normal, "me.ashtheking.currency.Currency", "me.ashtheking.currency.CurrencyList");
// Try to load MultiCurrency
hookEconomy("MultiCurrency", Economy_MultiCurrency.class, ServicePriority.Normal, "me.ashtheking.currency.Currency", "me.ashtheking.currency.CurrencyList");
// Try to load MineConomy
hookEconomy("MineConomy", Economy_MineConomy.class, ServicePriority.Normal, "me.mjolnir.mineconomy.MineConomy");
// Try to load MineConomy
hookEconomy("MineConomy", Economy_MineConomy.class, ServicePriority.Normal, "me.mjolnir.mineconomy.MineConomy");
// Try to load AEco
hookEconomy("AEco", Economy_AEco.class, ServicePriority.Normal, "org.neocraft.AEco.AEco");
// Try to load AEco
hookEconomy("AEco", Economy_AEco.class, ServicePriority.Normal, "org.neocraft.AEco.AEco");
// Try to load McMoney
hookEconomy("McMoney", Economy_McMoney.class, ServicePriority.Normal, "boardinggamer.mcmoney.McMoneyAPI");
// Try to load McMoney
hookEconomy("McMoney", Economy_McMoney.class, ServicePriority.Normal, "boardinggamer.mcmoney.McMoneyAPI");
// Try to load Craftconomy
hookEconomy("CraftConomy", Economy_Craftconomy.class, ServicePriority.Normal, "me.greatman.Craftconomy.Craftconomy");
// Try to load Craftconomy
hookEconomy("CraftConomy", Economy_Craftconomy.class, ServicePriority.Normal, "me.greatman.Craftconomy.Craftconomy");
// Try to load eWallet
hookEconomy("eWallet", Economy_eWallet.class, ServicePriority.Normal, "me.ethan.eWallet.ECO");
// Try to load eWallet
hookEconomy("eWallet", Economy_eWallet.class, ServicePriority.Normal, "me.ethan.eWallet.ECO");
// Try to load 3co
hookEconomy("3co", Economy_3co.class, ServicePriority.Normal, "me.ic3d.eco.ECO");
// Try to load 3co
hookEconomy("3co", Economy_3co.class, ServicePriority.Normal, "me.ic3d.eco.ECO");
// Try to load BOSEconomy 6
hookEconomy("BOSEconomy6", Economy_BOSE6.class, ServicePriority.Normal, "cosine.boseconomy.BOSEconomy", "cosine.boseconomy.CommandManager");
// Try to load BOSEconomy 6
hookEconomy("BOSEconomy6", Economy_BOSE6.class, ServicePriority.Normal, "cosine.boseconomy.BOSEconomy", "cosine.boseconomy.CommandManager");
// Try to load BOSEconomy 7
hookEconomy("BOSEconomy7", Economy_BOSE7.class, ServicePriority.Normal, "cosine.boseconomy.BOSEconomy", "cosine.boseconomy.CommandHandler");
// Try to load BOSEconomy 7
hookEconomy("BOSEconomy7", Economy_BOSE7.class, ServicePriority.Normal, "cosine.boseconomy.BOSEconomy", "cosine.boseconomy.CommandHandler");
// Try to load CurrencyCore
hookEconomy("CurrencyCore", Economy_CurrencyCore.class, ServicePriority.Normal, "is.currency.Currency");
// Try to load CurrencyCore
hookEconomy("CurrencyCore", Economy_CurrencyCore.class, ServicePriority.Normal, "is.currency.Currency");
// Try to load Essentials Economy
hookEconomy("Essentials Economy", Economy_Essentials.class, ServicePriority.Low, "com.earth2me.essentials.api.Economy", "com.earth2me.essentials.api.NoLoanPermittedException", "com.earth2me.essentials.api.UserDoesNotExistException");
// Try to load Essentials Economy
hookEconomy("Essentials Economy", Economy_Essentials.class, ServicePriority.Low, "com.earth2me.essentials.api.Economy", "com.earth2me.essentials.api.NoLoanPermittedException", "com.earth2me.essentials.api.UserDoesNotExistException");
// Try to load iConomy 4
hookEconomy("iConomy 4", Economy_iConomy4.class, ServicePriority.High, "com.nijiko.coelho.iConomy.iConomy", "com.nijiko.coelho.iConomy.system.Account");
// Try to load iConomy 4
hookEconomy("iConomy 4", Economy_iConomy4.class, ServicePriority.High, "com.nijiko.coelho.iConomy.iConomy", "com.nijiko.coelho.iConomy.system.Account");
// Try to load iConomy 5
hookEconomy("iConomy 5", Economy_iConomy5.class, ServicePriority.High, "com.iConomy.iConomy", "com.iConomy.system.Account", "com.iConomy.system.Holdings");
// Try to load iConomy 5
hookEconomy("iConomy 5", Economy_iConomy5.class, ServicePriority.High, "com.iConomy.iConomy", "com.iConomy.system.Account", "com.iConomy.system.Holdings");
// Try to load iConomy 6
hookEconomy("iConomy 6", Economy_iConomy6.class, ServicePriority.High, "com.iCo6.iConomy");
// Try to load iConomy 6
hookEconomy("iConomy 6", Economy_iConomy6.class, ServicePriority.High, "com.iCo6.iConomy");
// Try to load EconXP
hookEconomy("EconXP", Economy_EconXP.class, ServicePriority.Normal, "ca.agnate.EconXP.EconXP");
// Try to load EconXP
hookEconomy("EconXP", Economy_EconXP.class, ServicePriority.Normal, "ca.agnate.EconXP.EconXP");
}
/**
* Attempts to load Permission Addons
*/
private void loadPermission() {
// Try to load Starburst
hookPermission("Starburst", Permission_Starburst.class, ServicePriority.Highest, "com.dthielke.starburst.StarburstPlugin");
// Try to load Starburst
hookPermission("Starburst", Permission_Starburst.class, ServicePriority.Highest, "com.dthielke.starburst.StarburstPlugin");
// Try to load PermissionsEx
hookPermission("PermissionsEx", Permission_PermissionsEx.class, ServicePriority.Highest, "ru.tehkode.permissions.bukkit.PermissionsEx");
// Try to load PermissionsEx
hookPermission("PermissionsEx", Permission_PermissionsEx.class, ServicePriority.Highest, "ru.tehkode.permissions.bukkit.PermissionsEx");
// Try to load PermissionsBukkit
hookPermission("PermissionsBukkit", Permission_PermissionsBukkit.class, ServicePriority.Highest, "com.platymuus.bukkit.permissions.PermissionsPlugin");
// Try to load PermissionsBukkit
hookPermission("PermissionsBukkit", Permission_PermissionsBukkit.class, ServicePriority.Highest, "com.platymuus.bukkit.permissions.PermissionsPlugin");
// Try to load DroxPerms
hookPermission("DroxPerms", Permission_DroxPerms.class, ServicePriority.High, "de.hydrox.bukkit.DroxPerms.DroxPerms");
// Try to load DroxPerms
hookPermission("DroxPerms", Permission_DroxPerms.class, ServicePriority.High, "de.hydrox.bukkit.DroxPerms.DroxPerms");
// Try to load SimplyPerms
hookPermission("SimplyPerms", Permission_SimplyPerms.class, ServicePriority.Highest, "net.crystalyx.bukkit.simplyperms.SimplyPlugin");
// Try to load SimplyPerms
hookPermission("SimplyPerms", Permission_SimplyPerms.class, ServicePriority.Highest, "net.crystalyx.bukkit.simplyperms.SimplyPlugin");
// Try to load bPermissions2
hookPermission("bPermissions 2", Permission_bPermissions2.class, ServicePriority.Highest, "de.bananaco.bpermissions.api.WorldManager");
// Try to load bPermissions2
hookPermission("bPermissions 2", Permission_bPermissions2.class, ServicePriority.Highest, "de.bananaco.bpermissions.api.WorldManager");
// Try to load zPermission
hookPermission("zPermissions", Permission_zPermissions.class, ServicePriority.Highest, "org.tyrannyofheaven.bukkit.zPermissions.ZPermissionsPlugin");
// Try to load zPermission
hookPermission("zPermissions", Permission_zPermissions.class, ServicePriority.Highest, "org.tyrannyofheaven.bukkit.zPermissions.ZPermissionsPlugin");
// Try to load Privileges
hookPermission("Privileges", Permission_Privileges.class, ServicePriority.Highest, "net.krinsoft.privileges.Privileges");
// Try to load Privileges
hookPermission("Privileges", Permission_Privileges.class, ServicePriority.Highest, "net.krinsoft.privileges.Privileges");
// Try to load bPermissions
hookPermission("bPermissions", Permission_bPermissions.class, ServicePriority.High, "de.bananaco.permissions.SuperPermissionHandler");
// Try to load bPermissions
hookPermission("bPermissions", Permission_bPermissions.class, ServicePriority.High, "de.bananaco.permissions.SuperPermissionHandler");
// Try to load GroupManager
hookPermission("GroupManager", Permission_GroupManager.class, ServicePriority.High, "org.anjocaido.groupmanager.GroupManager");
// Try to load GroupManager
hookPermission("GroupManager", Permission_GroupManager.class, ServicePriority.High, "org.anjocaido.groupmanager.GroupManager");
// Try to load Permissions 3 (Yeti)
hookPermission("Permissions 3 (Yeti)", Permission_Permissions3.class, ServicePriority.High, "com.nijiko.permissions.ModularControl");
// Try to load Permissions 3 (Yeti)
hookPermission("Permissions 3 (Yeti)", Permission_Permissions3.class, ServicePriority.High, "com.nijiko.permissions.ModularControl");
Permission perms = new Permission_SuperPerms(this);
sm.register(Permission.class, perms, this, ServicePriority.Lowest);
@ -276,11 +276,11 @@ public class Vault extends JavaPlugin {
this.perms = sm.getRegistration(Permission.class).getProvider();
}
private void hookChat (String name, Class<? extends Chat> hookClass, ServicePriority priority, String...packages) {
try {
if (packagesExists(packages)) {
Chat chat = hookClass.getConstructor(Plugin.class, Permission.class).newInstance(this, perms);
Chat chat = hookClass.getConstructor(Vault.class, Permission.class).newInstance(this, perms);
sm.register(Chat.class, chat, this, priority);
log.info(String.format("[%s][Chat] %s found: %s", getDescription().getName(), name, chat.isEnabled() ? "Loaded" : "Waiting"));
}
@ -288,11 +288,11 @@ public class Vault extends JavaPlugin {
log.severe(String.format("[%s][Chat] There was an error hooking %s - check to make sure you're using a compatible version!", getDescription().getName(), name));
}
}
private void hookEconomy (String name, Class<? extends Economy> hookClass, ServicePriority priority, String...packages) {
try {
if (packagesExists(packages)) {
Economy econ = hookClass.getConstructor(Plugin.class).newInstance(this);
Economy econ = hookClass.getConstructor(Vault.class).newInstance(this);
sm.register(Economy.class, econ, this, priority);
log.info(String.format("[%s][Economy] %s found: %s", getDescription().getName(), name, econ.isEnabled() ? "Loaded" : "Waiting"));
}
@ -300,11 +300,11 @@ public class Vault extends JavaPlugin {
log.severe(String.format("[%s][Economy] There was an error hooking %s - check to make sure you're using a compatible version!", getDescription().getName(), name));
}
}
private void hookPermission (String name, Class<? extends Permission> hookClass, ServicePriority priority, String...packages) {
try {
if (packagesExists(packages)) {
Permission perms = hookClass.getConstructor(Plugin.class).newInstance(this);
Permission perms = hookClass.getConstructor(Vault.class).newInstance(this);
sm.register(Permission.class, perms, this, priority);
log.info(String.format("[%s][Permission] %s found: %s", getDescription().getName(), name, perms.isEnabled() ? "Loaded" : "Waiting"));
}