2012-05-10 16:32:25 +02:00
|
|
|
package com.Acrobot.ChestShop;
|
2011-05-15 18:16:25 +02:00
|
|
|
|
2012-06-08 15:28:36 +02:00
|
|
|
import com.Acrobot.Breeze.Utils.MaterialUtil;
|
2012-05-10 16:32:25 +02:00
|
|
|
import com.Acrobot.ChestShop.Config.Config;
|
|
|
|
import com.Acrobot.ChestShop.Config.Property;
|
2012-04-19 15:53:08 +02:00
|
|
|
import com.Acrobot.ChestShop.Economy.Economy;
|
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;
|
2012-05-10 16:32:25 +02:00
|
|
|
import com.Acrobot.ChestShop.Plugins.*;
|
|
|
|
import com.griefcraft.lwc.LWC;
|
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;
|
|
|
|
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
2012-02-16 19:09:37 +01:00
|
|
|
import com.webkonsept.bukkit.simplechestlock.SCL;
|
2012-06-08 15:28:36 +02:00
|
|
|
import org.bukkit.Bukkit;
|
2011-05-15 18:16:25 +02:00
|
|
|
import org.bukkit.plugin.Plugin;
|
|
|
|
import org.bukkit.plugin.PluginDescriptionFile;
|
2012-06-08 15:28:36 +02:00
|
|
|
import org.bukkit.plugin.PluginManager;
|
2012-01-25 16:32:34 +01:00
|
|
|
import org.bukkit.plugin.RegisteredServiceProvider;
|
2011-05-15 18:16:25 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @author Acrobot
|
|
|
|
*/
|
2012-05-10 16:32:25 +02:00
|
|
|
public class Dependencies {
|
|
|
|
public static void load() {
|
|
|
|
initializeSecurity();
|
2012-04-19 15:53:08 +02:00
|
|
|
|
2012-06-08 15:28:36 +02:00
|
|
|
PluginManager pluginManager = Bukkit.getPluginManager();
|
|
|
|
|
|
|
|
for (Object dependency : ChestShop.getDependencies()) {
|
|
|
|
Plugin plugin = pluginManager.getPlugin((String) dependency);
|
|
|
|
if (plugin != null) {
|
|
|
|
initializePlugin((String) dependency, plugin);
|
2012-04-19 15:53:08 +02:00
|
|
|
}
|
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
|
|
|
|
2012-05-10 16:32:25 +02:00
|
|
|
private static void initializeSecurity() {
|
|
|
|
ChestShop.registerListener(new com.Acrobot.ChestShop.Plugins.ChestShop());
|
|
|
|
}
|
|
|
|
|
2012-03-17 15:00:25 +01:00
|
|
|
private static void loadRegister() {
|
2012-04-19 15:53:08 +02:00
|
|
|
if (Economy.economy != null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-06-08 15:28:36 +02:00
|
|
|
Method method = Methods.load();
|
2012-04-19 15:53:08 +02:00
|
|
|
if (method == null) {
|
|
|
|
Economy.economy = new NoProvider();
|
|
|
|
return;
|
2012-01-25 16:32:34 +01:00
|
|
|
}
|
2012-04-19 15:53:08 +02:00
|
|
|
Economy.economy = new Register(method);
|
2012-05-10 16:32:25 +02:00
|
|
|
ChestShop.getBukkitLogger().info(method.getName() + " version " + method.getVersion() + " loaded.");
|
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")) {
|
2012-05-10 16:32:25 +02:00
|
|
|
ChestShop.registerListener(new LightweightChestProtection(LWC.getInstance()));
|
2011-08-13 12:08:34 +02:00
|
|
|
} else if (name.equals("Lockette")) {
|
2012-05-10 16:32:25 +02:00
|
|
|
ChestShop.registerListener(new Lockette());
|
2011-09-06 19:01:57 +02:00
|
|
|
} else if (name.equals("Deadbolt")) {
|
2012-05-10 16:32:25 +02:00
|
|
|
ChestShop.registerListener(new Deadbolt());
|
2011-08-13 12:08:34 +02:00
|
|
|
} else if (name.equals("OddItem")) {
|
2012-06-08 15:28:36 +02:00
|
|
|
MaterialUtil.Odd.initialize();
|
2011-09-22 15:56:06 +02:00
|
|
|
} else if (name.equals("Towny")) {
|
2012-05-10 16:32:25 +02:00
|
|
|
if (!Config.getBoolean(Property.TOWNY_INTEGRATION)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
ChestShop.registerListener(new Towny());
|
2011-10-11 13:15:53 +02:00
|
|
|
} else if (name.equals("WorldGuard")) {
|
2012-05-10 16:32:25 +02:00
|
|
|
WorldGuardPlugin worldGuard = (WorldGuardPlugin) plugin;
|
|
|
|
if (Config.getBoolean(Property.WORLDGUARD_USE_PROTECTION)) {
|
|
|
|
ChestShop.registerListener(new WorldGuardProtection(worldGuard));
|
|
|
|
}
|
|
|
|
if (!Config.getBoolean(Property.WORLDGUARD_INTEGRATION)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
ChestShop.registerListener(new WorldGuardBuilding(worldGuard));
|
2012-01-25 16:32:34 +01:00
|
|
|
} else if (name.equals("Vault")) {
|
2012-04-19 15:53:08 +02:00
|
|
|
if (Economy.economy != null) return;
|
|
|
|
|
|
|
|
RegisteredServiceProvider<net.milkbowl.vault.economy.Economy> rsp = ChestShop.getBukkitServer().getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class);
|
2012-03-06 19:41:14 +01:00
|
|
|
if (rsp == null) return;
|
2012-04-19 15:53:08 +02:00
|
|
|
|
2012-01-25 16:32:34 +01:00
|
|
|
Vault.economy = rsp.getProvider();
|
|
|
|
if (Vault.economy == null) return;
|
2012-04-19 15:53:08 +02:00
|
|
|
|
|
|
|
Economy.economy = new Vault();
|
2012-05-10 16:32:25 +02:00
|
|
|
ChestShop.getBukkitLogger().info("Vault loaded - using " + Vault.economy.getName());
|
2012-01-25 16:32:34 +01:00
|
|
|
return;
|
2012-03-17 15:00:25 +01:00
|
|
|
} else if (name.equals("Heroes")) {
|
2012-05-10 16:32:25 +02:00
|
|
|
ChestShop.registerListener(new Heroes((com.herocraftonline.heroes.Heroes) plugin));
|
2012-02-16 19:09:37 +01:00
|
|
|
} else if (name.equals("SimpleChestLock")) {
|
2012-05-10 16:32:25 +02:00
|
|
|
ChestShop.registerListener(new SimpleChestLock((SCL) plugin));
|
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();
|
2012-05-10 16:32:25 +02:00
|
|
|
ChestShop.getBukkitLogger().info(description.getName() + " version " + description.getVersion() + " loaded.");
|
2011-09-25 16:17:44 +02:00
|
|
|
}
|
2011-05-15 18:16:25 +02:00
|
|
|
}
|