package uk.co.eluinhost.ultrahardcore;

import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.inject.Singleton;
import org.bukkit.Bukkit;
import org.bukkit.configuration.serialization.ConfigurationSerialization;
import org.bukkit.event.Listener;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
import uk.co.eluinhost.metrics.MetricsLite;
import uk.co.eluinhost.ultrahardcore.features.deathbans.DeathBan;

import java.io.IOException;

/**
 * UltraHardcore
 * <p/>
 * Main plugin class, init
 *
 * @author ghowden
 */
@Singleton
public class UltraHardcore extends JavaPlugin implements Listener {

    /**
     * @return the current instance of the plugin
     */
    public static Plugin getInstance() {
        return Bukkit.getPluginManager().getPlugin("UltraHardcore");
    }

    //When the plugin gets started
    @Override
    public void onEnable() {
        //register deathbans for serilization
        ConfigurationSerialization.registerClass(DeathBan.class);
        //register the bungeecord plugin channel
        getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");

        Injector injector = Guice.createInjector(new UHCModule(this));

        DefaultClasses defaults = injector.getInstance(DefaultClasses.class);

        //load all the configs
        defaults.loadDefaultConfigurations();
        //load all the features
        defaults.loadDefaultFeatures(injector);
        //load all the scatter types
        defaults.loadDefaultScatterTypes(injector);
        //load all the commands
        defaults.loadDefaultCommands();
        //load the default border types
        defaults.loadDefaultBorders();

        //Load all the metric infos
        try {
            MetricsLite met = new MetricsLite(this);
            met.start();
        } catch (IOException ignored) {
        }
    }
}
@@ -1620,24 +1620,95 @@
 tCommands();
+%0A%0A        if(Bukkit.getPluginManager().getPlugin(%22WorldEdit%22) != null)%7B
 %0A        //l
@@ -1770,24 +1770,34 @@
 ltBorders();
+%0A        %7D
 %0A%0A        //

handle if worldedit isn't found