//============ HOOKS =============
        #region Hooks

        /**<summary>Called when item defaults are setup.</summary>*/
        public static void OnSetItemDefaults(Item item)
        {
            if (ItemMods.ContainsKey(item.type))
            {
                ItemModification itemMod = ItemMods[item.type];

                itemMod.ModifyItem(item);

                ErrorLogger.Close();
            }
        }
        //=========== LOADING ============
        #region Loading

        /**<summary>Loads or reloads the modifications xml doc.</summary>*/
        private static void LoadModifications()
        {
            try {
                ItemMods.Clear();

                XmlDocument  doc = new XmlDocument();
                XmlAttribute attribute;
                XmlNode      node;
                int          type;
                doc.Load(ConfigPath);

                XmlNodeList nodeList = doc.SelectNodes("/ItemModifications/Item");
                for (int i = 0; i < nodeList.Count; i++)
                {
                    node = nodeList[i];

                    attribute = node.Attributes["ID"];
                    if (attribute != null)
                    {
                        if (!int.TryParse(attribute.InnerText, out type))
                        {
                            if (!ErrorLogger.IsOpen)
                            {
                                ErrorLogger.Open();
                            }

                            ErrorLogger.WriteErrorHeader();
                            ErrorLogger.WriteLine("Error when reading XML.");
                            ErrorLogger.WriteLine("ItemID: " + attribute.InnerText + " could not be parsed.");
                            ErrorLogger.WriteLine();
                            continue;
                        }
                        if (ItemMods.ContainsKey(type))
                        {
                            if (!ErrorLogger.IsOpen)
                            {
                                ErrorLogger.Open();
                            }

                            ErrorLogger.WriteErrorHeader();
                            ErrorLogger.WriteLine("Error when reading XML.");
                            ErrorLogger.WriteLine("ItemID: " + type.ToString() + " already exists.");
                            ErrorLogger.WriteLine();
                            continue;
                        }
                        ItemModification item = new ItemModification(type);
                        item.LoadXml(node);

                        if (item.VarList.ContainsKey("Name"))
                        {
                            SetItemName(type, item.VarList["Name"].Value as string);
                        }
                        if (item.VarList.ContainsKey("Tooltip"))
                        {
                            SetItemTooltip(type, item.VarList["Tooltip"].Value as string);
                        }

                        ItemMods.Add(type, item);
                    }
                }
            }
            catch (Exception ex) {
                ErrorLogger.Open();
                ErrorLogger.WriteErrorHeader();
                ErrorLogger.WriteLine("Error when parsing XML.");
                ErrorLogger.WriteLine("Exception: ");
                ErrorLogger.WriteLine(ex.ToString());
                ErrorLogger.WriteLine();
            }

            // Close the error log if needed
            ErrorLogger.Close();
        }