/*
 * Project: UHC
 * Class: gg.uhc.uhc.modules.Module
 *
 * The MIT License (MIT)
 *
 * Copyright (c) 2015 Graham Howden <graham_howden1 at yahoo.co.uk>.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */

package gg.uhc.uhc.modules;

import com.google.common.base.Preconditions;
import gg.uhc.uhc.inventory.IconStack;
import gg.uhc.uhc.messages.MessageTemplates;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.plugin.Plugin;

public abstract class Module {

    protected final IconStack icon = new IconStack(Material.BARRIER, 1);
    protected ConfigurationSection config;
    protected MessageTemplates messages;
    protected Plugin plugin;
    protected String id;

    protected void setPlugin(Plugin plugin) {
        this.plugin = plugin;
    }

    public void setMessageTemplates(MessageTemplates messages) {
        this.messages = messages;
    }

    protected void setConfig(ConfigurationSection section) {
        this.config = section;
    }

    public void initialize() throws InvalidConfigurationException { }

    protected void saveConfig() {
        plugin.saveConfig();
    }

    protected void setId(String id) {
        Preconditions.checkState(this.id == null, "ID has already been set, cannot be set again");
        this.id = id;
    }

    public final IconStack getIconStack() {
        return icon;
    }
}

@@ -1817,386 +1817,965 @@
     
-protected void setPlugin(Plugin plugin) %7B%0A        this.plugin = plugin;%0A    %7D%0A%0A    public void setMessageTemplates(MessageTemplates messages) %7B%0A        this.messages = messages;%0A    %7D%0A%0A    protected void setConfig(ConfigurationSection section) %7B%0A        this.config = section;%0A    %7D%0A%0A    public void initialize() throws InvalidConfigurationException %7B %7D%0A%0A    protected void save
+/**%0A     * @param plugin the plugin instance to use for timers e.t.c.%0A     */%0A    public void setPlugin(Plugin plugin) %7B%0A        this.plugin = plugin;%0A    %7D%0A%0A    /**%0A     * @return the plugin instance used by this module. May be null if not set yet%0A     */%0A    public Plugin getPlugin() %7B%0A        return plugin;%0A    %7D%0A%0A    /**%0A     * @param messages templating section to pull messages from%0A     */%0A    public void setMessageTemplates(MessageTemplates messages) %7B%0A        this.messages = messages;%0A    %7D%0A%0A    /**%0A     * @return templating section, null if not set yet.%0A     */%0A    public MessageTemplates getMessageTemaplates() %7B%0A        return messages;%0A    %7D%0A%0A    /**%0A     * @param section the config section to pull values from%0A     */%0A    public void setConfig(ConfigurationSection section) %7B%0A        this.config = section;%0A    %7D%0A%0A    /**%0A     * @return config section to pull config from, null if not set yet%0A     */%0A    public ConfigurationSection get
 Conf
@@ -2793,27 +2793,21 @@
     
-plugin.saveC
+return c
 onfig
-()
 ;%0A  
@@ -2815,25 +2815,145 @@
  %7D%0A%0A    
-protected
+/**%0A     * @param id set the id of this module%0A     * @throws IllegalStateException if id has already been set%0A     */%0A    public
  void se
@@ -3093,24 +3093,562 @@
  id;%0A    %7D%0A%0A
+    /**%0A     * @return the id of this module, may be null if not set yet%0A     */%0A    public String getId() %7B%0A        return this.id;%0A    %7D%0A%0A    /**%0A     * Should be called after constuctor and setters have been called%0A     * @throws InvalidConfigurationException%0A     */%0A    public abstract void initialize() throws InvalidConfigurationException;%0A%0A    /**%0A     * Simple wrapper around plugin.saveConfig();%0A     */%0A    protected void saveConfig() %7B%0A        plugin.saveConfig();%0A    %7D%0A%0A    /**%0A     * @return this modules IconStack%0A     */%0A
     public f

make setters and getters public