Refactor admin command cooldown handling and update localization

- Updated cooldown handling in AdminCommandHandler to use localized messages.
- Added new method in Locales class to retrieve strings based on CommandSender type.
- Introduced cooldown messages in English and Russian localization files.
- Removed outdated DuelMode section from TODO.md and updated the last modified date.
This commit is contained in:
loki 2026-04-01 16:25:41 +02:00
parent 3100c53229
commit 46f7b794c6
5 changed files with 29 additions and 9 deletions

View file

@ -10,6 +10,7 @@ import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.jetbrains.annotations.NotNull;
@ -45,6 +46,23 @@ public class Locales {
return getString(getPlayerLocale(player), path);
}
/**
* Player: that player's locale. Console / command blocks: default language from config ({@link Option#OPTIONS_DEFAULTS}), or {@code en}.
*/
@NotNull
public static String getString(@NotNull CommandSender sender, @NotNull String path) {
if (sender instanceof Player player) {
return getString(player, path);
}
String locale = Option.OPTIONS_DEFAULTS != null
? Option.OPTIONS_DEFAULTS.get(ParkourOption.LANG)
: null;
if (locale == null || locale.isBlank()) {
locale = "en";
}
return getString(locale, path);
}
@NotNull
public static String getString(@NotNull String locale, @NotNull String path) {
return cachedValue(locale, c -> c.getString(path), "");