Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add localization for command descriptions #326

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public AntiAfkCommand(AuraSkills plugin) {
@CommandPermission("auraskills.command.antiafk.logs")
@CommandCompletion("@players")
@SuppressWarnings("deprecation")
@Description("%desc_antiafk_logs")
public void onLogs(CommandSender sender,
@Flags("other") String player,
@Default("1") @Conditions("limits:min=1") Integer page,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public ArmorCommand(AuraSkills plugin) {
@Subcommand("modifier add")
@CommandCompletion("@stats @nothing false|true")
@CommandPermission("auraskills.command.armor.modifier")
@Description("Adds an armor stat modifier to the item held, along with lore by default.")
@Description("%desc_armor_modifier_add")
public void onArmorModifierAdd(@Flags("itemheld") Player player, Stat stat, double value, @Default("true") boolean lore) {
Locale locale = plugin.getUser(player).getLocale();
ItemStack item = player.getInventory().getItemInMainHand();
Expand All @@ -62,7 +62,7 @@ public void onArmorModifierAdd(@Flags("itemheld") Player player, Stat stat, doub
@Subcommand("modifier remove")
@CommandCompletion("@stats false|true")
@CommandPermission("auraskills.command.armor.modifier")
@Description("Removes an armor stat modifier from the item held, and the lore associated with it by default.")
@Description("%desc_armor_modifier_remove")
public void onArmorModifierRemove(@Flags("itemheld") Player player, Stat stat, @Default("true") boolean lore) {
Locale locale = plugin.getUser(player).getLocale();
ItemStack item = player.getInventory().getItemInMainHand();
Expand Down Expand Up @@ -90,7 +90,7 @@ public void onArmorModifierRemove(@Flags("itemheld") Player player, Stat stat, @

@Subcommand("modifier list")
@CommandPermission("auraskills.command.armor.modifier")
@Description("Lists all armor stat modifiers on the item held.")
@Description("%desc_armor_modifier_list")
public void onArmorModifierList(@Flags("itemheld") Player player) {
Locale locale = plugin.getUser(player).getLocale();
ItemStack item = player.getInventory().getItemInMainHand();
Expand All @@ -104,7 +104,7 @@ public void onArmorModifierList(@Flags("itemheld") Player player) {

@Subcommand("modifier removeall")
@CommandPermission("auraskills.command.armor.modifier")
@Description("Removes all armor stat modifiers from the item held.")
@Description("%desc_armor_modifier_removeall")
public void onArmorModifierRemoveAll(@Flags("itemheld") Player player) {
Locale locale = plugin.getUser(player).getLocale();
SkillsItem skillsItem = new SkillsItem(player.getInventory().getItemInMainHand(), plugin);
Expand All @@ -117,7 +117,7 @@ public void onArmorModifierRemoveAll(@Flags("itemheld") Player player) {
@Subcommand("trait add")
@CommandCompletion("@traits @nothing false|true")
@CommandPermission("auraskills.command.armor.modifier")
@Description("Adds an armor trait modifier to the item held, along with lore by default.")
@Description("%desc_armor_trait_add")
public void onItemTraitAdd(@Flags("itemheld") Player player, Trait trait, double value, @Default("true") boolean lore) {
Locale locale = plugin.getUser(player).getLocale();
ItemStack item = player.getInventory().getItemInMainHand();
Expand All @@ -142,7 +142,7 @@ public void onItemTraitAdd(@Flags("itemheld") Player player, Trait trait, double
@Subcommand("trait remove")
@CommandCompletion("@traits")
@CommandPermission("auraskills.command.armor.modifier")
@Description("Removes an armor trait modifier from the item held.")
@Description("%desc_armor_trait_remove")
public void onItemTraitRemove(@Flags("itemheld") Player player, Trait trait) {
Locale locale = plugin.getUser(player).getLocale();
ItemStack item = player.getInventory().getItemInMainHand();
Expand All @@ -167,7 +167,7 @@ public void onItemTraitRemove(@Flags("itemheld") Player player, Trait trait) {

@Subcommand("trait list")
@CommandPermission("auraskills.command.armor.modifier")
@Description("Lists all item trait modifiers on the item held.")
@Description("%desc_armor_trait_list")
public void onItemTraitList(@Flags("itemheld") Player player) {
Locale locale = plugin.getUser(player).getLocale();
ItemStack item = player.getInventory().getItemInMainHand();
Expand All @@ -181,7 +181,7 @@ public void onItemTraitList(@Flags("itemheld") Player player) {

@Subcommand("trait removeall")
@CommandPermission("auraskills.command.armor.modifier")
@Description("Removes all armor trait modifiers from the item held.")
@Description("%desc_armor_trait_removeall")
public void onItemTraitRemoveAll(@Flags("itemheld") Player player) {
Locale locale = plugin.getUser(player).getLocale();

Expand All @@ -198,7 +198,7 @@ public void onItemTraitRemoveAll(@Flags("itemheld") Player player) {
@Subcommand("requirement add")
@CommandPermission("auraskills.command.armor.requirement")
@CommandCompletion("@skills @nothing false|true")
@Description("Adds an armor requirement to the item held, along with lore by default")
@Description("%desc_armor_requirement_add")
public void onArmorRequirementAdd(@Flags("itemheld") Player player, Skill skill, int level, @Default("true") boolean lore) {
Locale locale = plugin.getUser(player).getLocale();
ItemStack item = player.getInventory().getItemInMainHand();
Expand All @@ -222,7 +222,7 @@ public void onArmorRequirementAdd(@Flags("itemheld") Player player, Skill skill,
@Subcommand("requirement remove")
@CommandPermission("auraskills.command.armor.requirement")
@CommandCompletion("@skills false|true")
@Description("Removes an armor requirement from the item held, along with the lore associated it by default.")
@Description("%desc_armor_requirement_remove")
public void onArmorRequirementRemove(@Flags("itemheld") Player player, Skill skill, @Default("true") boolean lore) {
Locale locale = plugin.getUser(player).getLocale();
ItemStack item = player.getInventory().getItemInMainHand();
Expand All @@ -245,7 +245,7 @@ public void onArmorRequirementRemove(@Flags("itemheld") Player player, Skill ski

@Subcommand("requirement list")
@CommandPermission("auraskills.command.armor.requirement")
@Description("Lists the armor requirements on the item held.")
@Description("%desc_armor_requirement_list")
public void onArmorRequirementList(@Flags("itemheld") Player player) {
Locale locale = plugin.getUser(player).getLocale();
player.sendMessage(plugin.getMsg(CommandMessage.ARMOR_REQUIREMENT_LIST_HEADER, locale));
Expand All @@ -259,7 +259,7 @@ public void onArmorRequirementList(@Flags("itemheld") Player player) {

@Subcommand("requirement removeall")
@CommandPermission("auraskills.command.armor.requirement")
@Description("Removes all armor requirements from the item held.")
@Description("%desc_armor_requirement_removeall")
public void onArmorRequirementRemoveAll(@Flags("itemheld") Player player) {
Locale locale = plugin.getUser(player).getLocale();
SkillsItem skillsItem = new SkillsItem(player.getInventory().getItemInMainHand(), plugin);
Expand All @@ -272,7 +272,7 @@ public void onArmorRequirementRemoveAll(@Flags("itemheld") Player player) {
@Subcommand("multiplier add")
@CommandCompletion("@skills_global @nothing true|false")
@CommandPermission("auraskills.command.armor.multiplier")
@Description("Adds an armor multiplier to the held item to global or a specific skill where value is the percent more XP gained.")
@Description("%desc_armor_multiplier_add")
public void onArmorMultiplierAdd(@Flags("itemheld") Player player, String target, double value, @Default("true") boolean lore) {
ItemStack item = player.getInventory().getItemInMainHand();
Skill skill = plugin.getSkillRegistry().getOrNull(NamespacedId.fromDefault(target));
Expand Down Expand Up @@ -320,7 +320,7 @@ public void onArmorMultiplierAdd(@Flags("itemheld") Player player, String target
@Subcommand("multiplier remove")
@CommandCompletion("@skills_global")
@CommandPermission("auraskills.command.armor.multiplier")
@Description("Removes an armor multiplier of a the specified skill or global from the held item.")
@Description("%desc_armor_multiplier_remove")
public void onArmorMultiplierRemove(@Flags("itemheld") Player player, String target) {
Locale locale = plugin.getUser(player).getLocale();
ItemStack item = player.getInventory().getItemInMainHand();
Expand Down Expand Up @@ -357,7 +357,7 @@ public void onArmorMultiplierRemove(@Flags("itemheld") Player player, String tar

@Subcommand("multiplier list")
@CommandPermission("auraskills.command.armor.multiplier")
@Description("Lists all armor multipliers on the held item.")
@Description("%desc_armor_multiplier_list")
public void onArmorMultiplierList(@Flags("itemheld") Player player) {
Locale locale = plugin.getUser(player).getLocale();
ItemStack item = player.getInventory().getItemInMainHand();
Expand All @@ -378,7 +378,7 @@ public void onArmorMultiplierList(@Flags("itemheld") Player player) {

@Subcommand("multiplier removeall")
@CommandPermission("auraskills.command.armor.multiplier")
@Description("Removes all armor multipliers from the item held.")
@Description("%desc_armor_multiplier_removeall")
public void onArmorMultiplierRemoveAll(@Flags("itemheld") Player player) {
Locale locale = plugin.getUser(player).getLocale();
SkillsItem skillsItem = new SkillsItem(player.getInventory().getItemInMainHand(), plugin);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import co.aikar.commands.CommandIssuer;
import co.aikar.commands.annotation.CommandAlias;
import co.aikar.commands.annotation.CommandPermission;
import co.aikar.commands.annotation.Description;
import co.aikar.commands.annotation.Subcommand;
import dev.aurelium.auraskills.bukkit.AuraSkills;
import dev.aurelium.auraskills.common.message.MessageBuilder;
Expand All @@ -27,6 +28,7 @@ public BackupCommand(AuraSkills plugin) {

@Subcommand("save")
@CommandPermission("auraskills.command.backup.save")
@Description("%desc_backup_save")
public void onBackupSave(CommandIssuer issuer) {
BackupProvider backupProvider = plugin.getBackupProvider();
if (backupProvider != null) {
Expand All @@ -50,6 +52,7 @@ public void onBackupSave(CommandIssuer issuer) {

@Subcommand("load")
@CommandPermission("auraskills.command.backup.load")
@Description("%desc_backup_load")
public void onBackupLoad(CommandIssuer issuer, String fileName) {
StorageProvider storageProvider = plugin.getStorageProvider();
Locale locale = plugin.getLocale(issuer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@
import dev.aurelium.auraskills.api.trait.Trait;
import dev.aurelium.auraskills.bukkit.AuraSkills;
import dev.aurelium.auraskills.bukkit.menus.SourcesMenu.SortType;
import dev.aurelium.auraskills.common.commands.Command;
import dev.aurelium.auraskills.common.commands.ManaCommand;
import dev.aurelium.auraskills.common.config.Option;
import dev.aurelium.auraskills.common.message.MessageKey;
import dev.aurelium.auraskills.common.message.type.CommandMessage;
import dev.aurelium.auraskills.common.user.User;
import org.bukkit.Bukkit;
Expand All @@ -35,8 +37,8 @@ public PaperCommandManager registerCommands() {
var manager = new PaperCommandManager(plugin);
manager.enableUnstableAPI("help");
manager.usePerIssuerLocale(true, false);
manager.getCommandReplacements().addReplacement("skills_alias", "skills|sk|skill");

registerReplacements(manager);
registerConditions(manager);
registerContexts(manager);
registerCompletions(manager);
Expand All @@ -45,6 +47,21 @@ public PaperCommandManager registerCommands() {
return manager;
}

private void registerReplacements(PaperCommandManager manager) {
var replacements = manager.getCommandReplacements();
replacements.addReplacement("skills_alias", "skills|sk|skill");
// Add description replacements for each command
for (Command command : Command.values()) {
String lower = command.name().toLowerCase(Locale.ROOT);
String placeholder = "desc_" + lower;

var messageKey = MessageKey.of("commands." + lower.replace("_", ".") + ".desc");
String message = plugin.getMsg(messageKey, plugin.getDefaultLanguage());

replacements.addReplacement(placeholder, message);
}
}

private void registerConditions(PaperCommandManager manager) {
manager.getCommandConditions().addCondition(Integer.class, "limits", (c, exec, value) -> {
if (value == null) {
Expand Down
Loading
Loading