Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static HashMap<String, File> loadLangFiles(){
- File langFolder = new File(main.instance.getDataFolder(), "/languages");
- if(!langFolder.exists()){
- langFolder.mkdir();
- }
- HashMap<String,File> langs = new HashMap<>();
- langs.put("en", new File(langFolder, "en.yml"));
- langs.put("es", new File(langFolder, "es.yml"));
- langs.put("bg", new File(langFolder, "bg.yml"));
- s_langs = langs;
- for(File lang : langs.values()){
- try{
- if(!lang.exists()){
- InputStream stream = main.instance.getResource(lang.getName());
- Files.copy(stream, lang.toPath());
- }
- }catch (IOException e){
- e.printStackTrace();
- }
- }
- return langs;
- }
- public static void fillLangMap(main plugin){
- loadLangFiles();
- if(!messages.isEmpty()){
- messages.clear();
- }
- String selectedLang = plugin.getConfig().getString("pluginLanguage");
- FileConfiguration conf = YamlConfiguration.loadConfiguration(s_langs.get(selectedLang));
- for(String key : conf.getKeys(false)){
- for(String messName : conf.getConfigurationSection(key).getKeys(false)){
- messages.put(messName, ChatColor.translateAlternateColorCodes('&', conf.getString(key + "." + messName)));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment