2011-05-15 19:33:03 +02:00
package com.Acrobot.ChestShop.Listeners ;
2011-05-15 18:16:25 +02:00
2011-05-16 17:35:12 +02:00
import com.Acrobot.ChestShop.ChestShop ;
2012-02-16 19:09:37 +01:00
import com.Acrobot.ChestShop.Economy.NoProvider ;
2012-01-25 16:32:34 +01:00
import com.Acrobot.ChestShop.Economy.Register ;
import com.Acrobot.ChestShop.Economy.Vault ;
2011-05-15 19:33:03 +02:00
import com.Acrobot.ChestShop.Items.Odd ;
2012-02-16 19:09:37 +01:00
import com.Acrobot.ChestShop.Protection.Plugins.* ;
2011-05-15 19:33:03 +02:00
import com.Acrobot.ChestShop.Protection.Security ;
2012-03-01 22:03:59 +01:00
import com.Acrobot.ChestShop.Utils.WorldGuard.uWorldGuard ;
2012-01-25 16:32:34 +01:00
import com.Acrobot.ChestShop.Utils.uHeroes ;
2011-09-23 14:07:20 +02:00
import com.Acrobot.ChestShop.Utils.uSign ;
2011-05-15 18:16:25 +02:00
import com.griefcraft.lwc.LWCPlugin ;
2012-03-06 19:41:14 +01:00
import com.herocraftonline.heroes.Heroes ;
2012-01-25 16:32:34 +01:00
import com.nijikokun.register.payment.forChestShop.Method ;
2011-10-11 13:15:53 +02:00
import com.nijikokun.register.payment.forChestShop.Methods ;
2011-09-22 15:56:06 +02:00
import com.palmergames.bukkit.towny.Towny ;
2011-10-11 13:15:53 +02:00
import com.sk89q.worldguard.bukkit.WorldGuardPlugin ;
2012-02-16 19:09:37 +01:00
import com.webkonsept.bukkit.simplechestlock.SCL ;
2012-01-25 16:32:34 +01:00
import net.milkbowl.vault.economy.Economy ;
2011-05-15 18:16:25 +02:00
import org.bukkit.plugin.Plugin ;
import org.bukkit.plugin.PluginDescriptionFile ;
2012-01-25 16:32:34 +01:00
import org.bukkit.plugin.RegisteredServiceProvider ;
2011-05-15 18:16:25 +02:00
import org.yi.acru.bukkit.Lockette.Lockette ;
/ * *
* @author Acrobot
* /
2012-02-16 19:09:37 +01:00
public class pluginEnable {
2011-05-15 18:16:25 +02:00
2011-09-06 19:01:57 +02:00
public static void initializePlugins ( ) {
2012-01-09 22:39:38 +01:00
Security . protections . add ( new Default ( ) ) ; //Initialize basic protection
2011-09-06 19:01:57 +02:00
for ( Object plugin : ChestShop . getDependencies ( ) ) {
Plugin pl = ChestShop . pm . getPlugin ( ( String ) plugin ) ;
if ( pl ! = null ) initializePlugin ( ( String ) plugin , pl ) ;
2011-05-15 18:16:25 +02:00
}
2012-01-25 16:32:34 +01:00
loadRegister ( ) ;
}
2012-03-17 15:00:25 +01:00
private static void loadRegister ( ) {
2012-01-25 16:32:34 +01:00
if ( com . Acrobot . ChestShop . Economy . Economy . economy = = null ) {
Method m = Methods . load ( ChestShop . pm ) ;
2012-02-16 19:09:37 +01:00
if ( m = = null ) {
com . Acrobot . ChestShop . Economy . Economy . economy = new NoProvider ( ) ;
return ;
}
2012-01-25 16:32:34 +01:00
Register . eco = m ;
com . Acrobot . ChestShop . Economy . Economy . economy = new Register ( ) ;
2012-03-06 19:41:14 +01:00
System . out . println ( ChestShop . chatPrefix + m . getName ( ) + " version " + m . getVersion ( ) + " loaded. " ) ;
2012-01-25 16:32:34 +01:00
}
2011-08-13 12:08:34 +02:00
}
2011-05-15 18:16:25 +02:00
2011-08-13 12:08:34 +02:00
private static void initializePlugin ( String name , Plugin plugin ) { //Really messy, right? But it's short and fast :)
2012-03-01 22:03:59 +01:00
if ( name . equals ( " LWC " ) ) {
2011-08-31 20:57:10 +02:00
LWCplugin . setLWC ( ( ( LWCPlugin ) plugin ) . getLWC ( ) ) ;
2011-12-01 14:02:58 +01:00
Security . protections . add ( new LWCplugin ( ) ) ;
2011-08-13 12:08:34 +02:00
} else if ( name . equals ( " Lockette " ) ) {
2011-09-06 19:01:57 +02:00
LockettePlugin . lockette = ( Lockette ) plugin ;
2011-12-01 14:02:58 +01:00
Security . protections . add ( new LockettePlugin ( ) ) ;
2011-09-06 19:01:57 +02:00
} else if ( name . equals ( " Deadbolt " ) ) {
2011-12-01 14:02:58 +01:00
Security . protections . add ( new DeadboltPlugin ( ) ) ;
2011-08-13 12:08:34 +02:00
} else if ( name . equals ( " OddItem " ) ) {
2011-09-25 16:17:44 +02:00
Odd . isInitialized = true ;
2011-09-22 15:56:06 +02:00
} else if ( name . equals ( " Towny " ) ) {
2011-09-23 14:07:20 +02:00
uSign . towny = ( Towny ) plugin ;
2011-10-11 13:15:53 +02:00
} else if ( name . equals ( " WorldGuard " ) ) {
2012-03-06 19:41:14 +01:00
uWorldGuard . wg = ( WorldGuardPlugin ) plugin ;
2012-03-01 22:03:59 +01:00
uWorldGuard . injectHax ( ) ; //Inject hax into WorldGuard
2012-01-25 16:32:34 +01:00
} else if ( name . equals ( " Vault " ) ) {
if ( com . Acrobot . ChestShop . Economy . Economy . economy ! = null ) return ;
RegisteredServiceProvider < Economy > rsp = ChestShop . getBukkitServer ( ) . getServicesManager ( ) . getRegistration ( Economy . class ) ;
2012-03-06 19:41:14 +01:00
if ( rsp = = null ) return ;
2012-01-25 16:32:34 +01:00
Vault . economy = rsp . getProvider ( ) ;
if ( Vault . economy = = null ) return ;
com . Acrobot . ChestShop . Economy . Economy . economy = new Vault ( ) ;
System . out . println ( ChestShop . chatPrefix + " Vault loaded using economy plugin " + Vault . economy . getName ( ) ) ;
return ;
2012-03-17 15:00:25 +01:00
} else if ( name . equals ( " Heroes " ) ) {
2012-01-25 16:32:34 +01:00
uHeroes . heroes = ( Heroes ) plugin ;
2012-02-16 19:09:37 +01:00
} else if ( name . equals ( " SimpleChestLock " ) ) {
SCLplugin . scl = ( SCL ) plugin ;
Security . protections . add ( new SCLplugin ( ) ) ;
2012-03-01 22:03:59 +01:00
} else {
return ;
2011-05-15 18:16:25 +02:00
}
2012-03-17 15:00:25 +01:00
2011-09-06 19:01:57 +02:00
PluginDescriptionFile description = plugin . getDescription ( ) ;
2011-09-01 18:59:15 +02:00
System . out . println ( ChestShop . chatPrefix + description . getName ( ) + " version " + description . getVersion ( ) + " loaded. " ) ;
2011-05-15 18:16:25 +02:00
}
2011-09-25 16:17:44 +02:00
2011-09-29 20:29:39 +02:00
private static String generateOutdatedVersion ( String pluginName , String curVersion , String neededVersion ) {
2011-09-25 16:17:44 +02:00
return ( new StringBuilder ( 7 ) . append ( ChestShop . chatPrefix ) . append ( " Your " ) . append ( pluginName ) . append ( " is outdated! Need version AT LEAST " ) . append ( neededVersion ) . append ( " - Your version is " ) . append ( curVersion ) . toString ( ) ) ;
}
2011-05-15 18:16:25 +02:00
}