gt:                     i = ((Integer) OPTIONS.get(node)).intValue();
context: /*
      This program is free software: you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published by
      the Free Software Foundation, either version 3 of the License, or
      (at your option) any later version.
  
      This program is distributed in the hope that it will be useful,
      but WITHOUT ANY WARRANTY; without even the implied warranty of
      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      GNU General Public License for more details.
  
      You should have received a copy of the GNU General Public License
      along with this program.  If not, see <http://www.gnu.org/licenses/>.
   */
  package de.diemex.nff.service;
  
  import de.diemex.nff.NoFriendlyFire;
  import de.diemex.nff.Team;
  import de.diemex.nff.config.NFFNode;
  import org.bukkit.ChatColor;
  import org.bukkit.Color;
  import org.bukkit.configuration.ConfigurationSection;
  import org.bukkit.configuration.file.FileConfiguration;
  import org.bukkit.configuration.file.YamlConfiguration;
  
  import javax.print.DocFlavor;
  import java.io.File;
  import java.io.IOException;
  import java.util.*;
  import java.util.concurrent.ConcurrentHashMap;
  
  /**
   * Modular configuration class that utilizes a ConfigNode enumeration as easy
   * access and storage of configuration option values.
   *
   * @author Mitsugaru
   */
  @SuppressWarnings("SameParameterValue")
  public abstract class ModularConfig extends NFFModule
  {
      /**
       * Cache of options for the config.
       */
      protected final Map<ConfigNode, Object> OPTIONS = new ConcurrentHashMap<ConfigNode, Object>();
  
      /**
       * Constructor.
       *
       * @param plugin - plugin instance.
       */
      public ModularConfig(NoFriendlyFire plugin)
      {
          super(plugin);
      }
  
      /**
       * This updates a configuration option from the file.
       *
       * @param node - ConfigNode to update.
       */
      @SuppressWarnings("unchecked")
      public void updateOption(final ConfigNode node)
      {
          final ConfigurationSection config = plugin.getConfig();
          switch (node.getVarType())
          {
              case LIST:
              {
                  List<String> list = config.getStringList(node.getPath());
                  if (list == null)
                  {
                      list = (List<String>) node.getDefaultValue();
                  }
                  OPTIONS.put(node, list);
                  break;
              }
              case DOUBLE:
              {
                  OPTIONS.put(node, config.getDouble(node.getPath(), (Double) node.getDefaultValue()));
                  break;
              }
              case STRING:
              {
                  OPTIONS.put(node, config.getString(node.getPath(), (String) node.getDefaultValue()));
                  break;
              }
              case INTEGER:
              {
                  OPTIONS.put(node, config.getInt(node.getPath(), (Integer) node.getDefaultValue()));
                  break;
              }
              case BOOLEAN:
              {
                  OPTIONS.put(node, config.getBoolean(node.getPath(), (Boolean) node.getDefaultValue()));
                  break;
              }
              case TEAM_LIST:
              {
                  ArrayList<Team> teams = new ArrayList<Team>();
                  ConfigurationSection section = config.getConfigurationSection(node.getPath());
                  Map mapo = section.getValues(true);
  
                  Iterator iter = mapo.entrySet().iterator();
                  while (iter.hasNext())
                  {
                      Team myTeam = new Team();
                      Map.Entry <String, Object> pair = (Map.Entry<String, Object>) iter.next();
                      String path = pair.getKey();
                      Object value = pair.getValue();
                      if (value instanceof ConfigurationSection)
                      {
                          ConfigurationSection colorSection = (ConfigurationSection) value;
                          //Parse the color
                          {
                              String colorStr = colorSection.getString("Color");
                              boolean contains = false;
                              for (ChatColor color : ChatColor.values())
                              {
                                  String name = color.name();
                                  contains = name.equals(colorStr);
                                  if (contains) break;
                              }
                              if (contains)
                                  myTeam.setColor(ChatColor.valueOf(colorStr));
                          }
                          myTeam.setName(path);
                          teams.add(myTeam);
                      }
                  }
                  //Teams empty? load defaults...
                  if (teams.size() < 1)
                      teams = (ArrayList) node.getDefaultValue();
  
                  OPTIONS.put(node, teams);
                  break;
              }
              default:
              {
                  OPTIONS.put(node, config.get(node.getPath(), node.getDefaultValue()));
              }
          }
      }
  
      /**
       * Rewrites the config based on the validated values which are in memory
       */
      public void cleanRewrite()
      {
          FileConfiguration config = new YamlConfiguration();
          Set <Map.Entry<ConfigNode, Object>> nodes = OPTIONS.entrySet();
          for (Map.Entry<ConfigNode, Object> entry : nodes)
          {
              ConfigNode node = entry.getKey();
              switch (node.getVarType())
              {
                  case BOOLEAN:
                  {
                      config.set(node.getPath(), getBoolean(node));
                      break;
                  }
                  case STRING:
                  {
                      config.set(node.getPath(), getString(node));
                      break;
                  }
                  case INTEGER:
                  {
                      config.set(node.getPath(), getInt(node));
                      break;
                  }
                  case DOUBLE:
                  {
                      config.set(node.getPath(), getDouble(node));
                      break;
                  }
                  case LIST:
                  {
                      config.set(node.getPath(), getStringList(node));
                      break;
                  }
                  case TEAM_LIST:
                  {
                      ArrayList<Team> teams = getTeams(node);
                      for (Team team : teams)
                      {
                          config.set(NFFNode.TEAMS.getPath() + "." + team.getName() + ".Color", team.getColor().name());
                      }
                  }
                  default:
                  {
                      break;
                  }
              }
          }
          try
          {
              config.save(new File(plugin.getDataFolder() + File.separator + "config.yml"));
          } catch (IOException e)
          {
              e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
          }
      }
  
      /**
       * Saves the config.
       */
      public abstract void save();
  
      /**
       * Force set the value for the given configuration node.
       * <p/>
       * Note, there is no type checking with this method.
       *
       * @param node  - ConfigNode path to use.
       * @param value - Value to use.
       */
      public void set(final ConfigNode node, final Object value)
      {
          set(node.getPath(), value);
      }
  
      /**
       * Set the given path for the given value.
       *
       * @param path  - Path to use.
       * @param value - Value to use.
       */
      public abstract void set(final String path, final Object value);
  
      /**
       * Get the integer value of the node.
       *
       * @param node - Node to use.
       * @return Value of the node. Returns -1 if unknown.
       */
      public int getInt(final ConfigNode node)
      {
          int i = -1;
          switch (node.getVarType())
          {
              case INTEGER:
              {
                  try
                  {
  