2025-06-22 03:19:06 +03:00
|
|
|
package hdvtdev.blockAndSeek;
|
|
|
|
|
|
|
|
|
|
import net.kyori.adventure.text.Component;
|
|
|
|
|
import net.kyori.adventure.text.minimessage.MiniMessage;
|
|
|
|
|
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
public class Localization {
|
|
|
|
|
|
2025-06-26 01:18:01 +03:00
|
|
|
private static volatile Map<String, String> localization = ConfigManager.getLocalization();
|
|
|
|
|
private static final MiniMessage miniMessage = MiniMessage.miniMessage();
|
|
|
|
|
private static final Component prefix = miniMessage.deserialize("<gold>[<bold><blue>BlockAndSeek<reset><gold>] ");
|
2025-06-22 03:19:06 +03:00
|
|
|
|
2025-06-26 01:18:01 +03:00
|
|
|
public static Component getPrefix() {
|
|
|
|
|
return prefix;
|
2025-06-22 03:19:06 +03:00
|
|
|
}
|
|
|
|
|
|
2025-06-26 01:18:01 +03:00
|
|
|
public static void update() {
|
|
|
|
|
localization = ConfigManager.getLocalization();
|
2025-06-22 03:19:06 +03:00
|
|
|
}
|
|
|
|
|
|
2025-06-26 01:18:01 +03:00
|
|
|
public static String get(String key, String... replacements) {
|
2025-06-22 03:19:06 +03:00
|
|
|
String s = localization.get(key);
|
2025-06-26 01:18:01 +03:00
|
|
|
if (s != null) {
|
|
|
|
|
for (int i = 0; i < replacements.length; i += 2) {
|
|
|
|
|
s = s.replace(replacements[i], replacements[i + 1]);
|
|
|
|
|
}
|
|
|
|
|
} else return "Unknown localization: " + key;
|
|
|
|
|
return s;
|
|
|
|
|
}
|
2025-06-22 03:19:06 +03:00
|
|
|
|
2025-06-26 01:18:01 +03:00
|
|
|
public static Component getComponent(String key, String... replacements) {
|
|
|
|
|
return miniMessage.deserialize(get(key, replacements));
|
2025-06-22 03:19:06 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|