src/main/java/de/mviper/adventskalender/LanguageManager.java gelöscht
This commit is contained in:
@@ -1,41 +0,0 @@
|
||||
package de.mviper.adventskalender;
|
||||
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
public class LanguageManager {
|
||||
|
||||
private static FileConfiguration languageConfig;
|
||||
|
||||
public static void setup() {
|
||||
String lang = Adventskalender.getInstance().getConfig().getString("general.language", "de");
|
||||
File languageFile = new File(Adventskalender.getInstance().getDataFolder(), "messages_" + lang + ".yml");
|
||||
|
||||
if (!languageFile.exists()) {
|
||||
Adventskalender.getInstance().saveResource("messages_" + lang + ".yml", false);
|
||||
}
|
||||
|
||||
languageConfig = YamlConfiguration.loadConfiguration(languageFile);
|
||||
}
|
||||
|
||||
public static String getString(String path) {
|
||||
if (languageConfig.contains(path)) {
|
||||
return format(languageConfig.getString(path));
|
||||
}
|
||||
return "§cLanguage key not found: " + path;
|
||||
}
|
||||
|
||||
public static List<String> getStringList(String path) {
|
||||
if (languageConfig.contains(path)) {
|
||||
return languageConfig.getStringList(path).stream().map(LanguageManager::format).toList();
|
||||
}
|
||||
return List.of("§cLanguage key list not found: " + path);
|
||||
}
|
||||
|
||||
private static String format(String message) {
|
||||
return org.bukkit.ChatColor.translateAlternateColorCodes('&', message);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user