/*
* Copyright (c) 2013, LankyLord
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package net.lankylord.simplehomes.managers.languages;

import org.bukkit.ChatColor;
import org.bukkit.configuration.file.FileConfiguration;

/** @author LankyLord */
public class LanguageManager {

    public static String HOME_DELETED = ChatColor.YELLOW + "Home deleted.";
    public static String HOME_LIST_PREFIX = ChatColor.YELLOW + "Homes:";
    public static String HOME_NOT_FOUND = ChatColor.RED + "Home not found.";
    public static String HOME_NOT_SET = ChatColor.RED + "Home cannot be set. The maximum number of homes has been " +
            "reached";
    public static String HOME_SET = ChatColor.YELLOW + "Home set.";
    public static String NO_HOMES_FOUND = ChatColor.RED + "No homes found.";
    public static String PLAYER_COMMAND_ONLY = ChatColor.RED + "Only players may issue that command.";
    public static String TELEPORT_OTHERHOME = ChatColor.YELLOW + "Teleported to %p's home.";
    public static String TELEPORT_SUCCESS = ChatColor.YELLOW + "Teleported.";

    private LanguageFileManager fileManager;
    private FileConfiguration languageConfig;

    public LanguageManager(LanguageFileManager fileManager) {
        this.fileManager = fileManager;
        languageConfig = fileManager.getLanguageConfig();
        loadMessages();
    }

    private String convertColours(String string) {
        return ChatColor.translateAlternateColorCodes('&', string);
    }

    private void loadMessages() {
        HOME_DELETED = languageConfig.getString("home-deleted");
        HOME_LIST_PREFIX = languageConfig.getString("home-list-prefix");
        HOME_NOT_FOUND = languageConfig.getString("home-not-found");
        HOME_NOT_SET = languageConfig.getString("home-max-reached");
        HOME_SET = languageConfig.getString("home-set");
        NO_HOMES_FOUND = languageConfig.getString("no-homes-found");
        PLAYER_COMMAND_ONLY = languageConfig.getString("player-command-only");
        TELEPORT_OTHERHOME = languageConfig.getString("teleport-otherhome");
        TELEPORT_SUCCESS = languageConfig.getString("teleport-success");
    }
}
@@ -2774,24 +2774,39 @@
 E_DELETED = 
+convertColours(
 languageConf
@@ -2829,24 +2829,25 @@
 me-deleted%22)
+)
 ;%0A        HO
@@ -2863,16 +2863,31 @@
 REFIX = 
+convertColours(
 language
@@ -2922,16 +2922,17 @@
 prefix%22)
+)
 ;%0A      
@@ -2942,32 +2942,47 @@
 OME_NOT_FOUND = 
+convertColours(
 languageConfig.g
@@ -2999,32 +2999,33 @@
 home-not-found%22)
+)
 ;%0A        HOME_N
@@ -3029,24 +3029,39 @@
 E_NOT_SET = 
+convertColours(
 languageConf
@@ -3092,16 +3092,17 @@
 eached%22)
+)
 ;%0A      
@@ -3114,16 +3114,31 @@
 E_SET = 
+convertColours(
 language
@@ -3165,16 +3165,17 @@
 me-set%22)
+)
 ;%0A      
@@ -3193,16 +3193,31 @@
 FOUND = 
+convertColours(
 language
@@ -3250,16 +3250,17 @@
 -found%22)
+)
 ;%0A      
@@ -3283,16 +3283,31 @@
 _ONLY = 
+convertColours(
 language
@@ -3345,16 +3345,17 @@
 d-only%22)
+)
 ;%0A      
@@ -3377,16 +3377,31 @@
 RHOME = 
+convertColours(
 language
@@ -3438,16 +3438,17 @@
 erhome%22)
+)
 ;%0A      
@@ -3468,16 +3468,31 @@
 CCESS = 
+convertColours(
 language
@@ -3527,16 +3527,17 @@
 uccess%22)
+)
 ;%0A    %7D%0A

Translate alternative colour codes