Commit a46d58e5 authored by 方块君's avatar 方块君 Committed by Melledy
Browse files

Add command description multilingual

parent 257a92f3
......@@ -10,10 +10,14 @@ import java.util.Map;
import static emu.grasscutter.utils.Language.translate;
@Command(label = "list", usage = "list [uid]",
description = "List online players", aliases = {"players"})
@Command(label = "list", usage = "list [uid]", aliases = {"players"})
public final class ListCommand implements CommandHandler {
@Override
public String description() {
return translate("commands.list.description");
}
@Override
public void execute(Player sender, Player targetPlayer, List<String> args) {
Map<Integer, Player> playersMap = Grasscutter.getGameServer().getPlayers();
......
......@@ -10,10 +10,14 @@ import java.util.List;
import static emu.grasscutter.utils.Language.translate;
@Command(label = "permission", usage = "permission <add|remove> <permission>",
description = "Grants or removes a permission for a user", permission = "*")
@Command(label = "permission", usage = "permission <add|remove> <permission>", permission = "*")
public final class PermissionCommand implements CommandHandler {
@Override
public String description() {
return translate("commands.permission.description");
}
@Override
public void execute(Player sender, Player targetPlayer, List<String> args) {
if (targetPlayer == null) {
......
......@@ -9,10 +9,14 @@ import java.util.List;
import static emu.grasscutter.utils.Language.translate;
@Command(label = "position", usage = "position", aliases = {"pos"},
description = "Get coordinates.")
@Command(label = "position", usage = "position", aliases = {"pos"})
public final class PositionCommand implements CommandHandler {
@Override
public String description() {
return translate("commands.position.description");
}
@Override
public void execute(Player sender, Player targetPlayer, List<String> args) {
if (targetPlayer == null) {
......
......@@ -9,10 +9,14 @@ import java.util.List;
import static emu.grasscutter.utils.Language.translate;
@Command(label = "reload", usage = "reload",
description = "Reload server config", permission = "server.reload")
@Command(label = "reload", usage = "reload", permission = "server.reload")
public final class ReloadCommand implements CommandHandler {
@Override
public String description() {
return translate("commands.reload.description");
}
@Override
public void execute(Player sender, Player targetPlayer, List<String> args) {
CommandHandler.sendMessage(sender, translate("commands.reload.reload_start"));
......
......@@ -11,10 +11,14 @@ import java.util.List;
import static emu.grasscutter.utils.Language.translate;
@Command(label = "resetconst", usage = "resetconst [all]",
description = "Resets the constellation level on your current active character, will need to relog after using the command to see any changes.",
aliases = {"resetconstellation"}, permission = "player.resetconstellation")
public final class ResetConstCommand implements CommandHandler {
@Override
public String description() {
return translate("commands.resetConst.description");
}
@Override
public void execute(Player sender, Player targetPlayer, List<String> args) {
if (targetPlayer == null) {
......
......@@ -9,9 +9,13 @@ import java.util.List;
import static emu.grasscutter.utils.Language.translate;
@Command(label = "resetshop", usage = "resetshop",
description = "Reset target player's shop refresh time.", permission = "server.resetshop")
@Command(label = "resetshop", usage = "resetshop", permission = "server.resetshop")
public final class ResetShopLimitCommand implements CommandHandler {
@Override
public String description() {
return translate("commands.status.description");
}
@Override
public void execute(Player sender, Player targetPlayer, List<String> args) {
if (targetPlayer == null) {
......
......@@ -6,9 +6,16 @@ import emu.grasscutter.game.player.Player;
import java.util.List;
@Command(label = "restart", usage = "restart - Restarts the current session")
import static emu.grasscutter.utils.Language.translate;
@Command(label = "restart", usage = "restart")
public final class RestartCommand implements CommandHandler {
@Override
public String description() {
return translate("commands.restart.description");
}
@Override
public void execute(Player sender, Player targetPlayer, List<String> args) {
if (sender == null) {
......
......@@ -13,8 +13,7 @@ import java.util.List;
import static emu.grasscutter.utils.Language.translate;
@SuppressWarnings("ConstantConditions")
@Command(label = "sendmail", usage = "sendmail <userId|all|help> [templateId]",
description = "Sends mail to the specified user. The usage of this command changes based on it's composition state.", permission = "server.sendmail")
@Command(label = "sendmail", usage = "sendmail <userId|all|help> [templateId]", permission = "server.sendmail")
public final class SendMailCommand implements CommandHandler {
// TODO: You should be able to do /sendmail and then just send subsequent messages until you finish
......@@ -24,6 +23,11 @@ public final class SendMailCommand implements CommandHandler {
// Key = User that is constructing the mail.
private static final HashMap<Integer, MailBuilder> mailBeingConstructed = new HashMap<Integer, MailBuilder>();
@Override
public String description() {
return translate("commands.sendMail.description");
}
// Yes this is awful and I hate it.
@Override
public void execute(Player sender, Player targetPlayer, List<String> args) {
......@@ -40,7 +44,7 @@ public final class SendMailCommand implements CommandHandler {
MailBuilder mailBuilder;
switch (args.get(0).toLowerCase()) {
case "help" -> {
CommandHandler.sendMessage(sender, this.getClass().getAnnotation(Command.class).description() + "\nUsage: " + this.getClass().getAnnotation(Command.class).usage());
CommandHandler.sendMessage(sender, this.description() + "\nUsage: " + this.getClass().getAnnotation(Command.class).usage());
return;
}
case "all" -> mailBuilder = new MailBuilder(true, new Mail());
......
......@@ -8,10 +8,15 @@ import java.util.List;
import static emu.grasscutter.utils.Language.translate;
@Command(label = "say", usage = "say <message>", description = "Sends a message to a player as the server",
@Command(label = "say", usage = "say <message>",
aliases = {"sendservmsg", "sendservermessage", "sendmessage"}, permission = "server.sendmessage")
public final class SendMessageCommand implements CommandHandler {
@Override
public String description() {
return translate("commands.sendMessage.description");
}
@Override
public void execute(Player sender, Player targetPlayer, List<String> args) {
if (targetPlayer == null) {
......
......@@ -12,10 +12,14 @@ import emu.grasscutter.server.packet.send.PacketAvatarFetterDataNotify;
import static emu.grasscutter.utils.Language.translate;
@Command(label = "setfetterlevel", usage = "setfetterlevel <level>",
description = "Sets your fetter level for your current active character",
aliases = {"setfetterlvl", "setfriendship"}, permission = "player.setfetterlevel")
public final class SetFetterLevelCommand implements CommandHandler {
@Override
public String description() {
return translate("commands.setFetterLevel.description");
}
@Override
public void execute(Player sender, Player targetPlayer, List<String> args) {
if (targetPlayer == null) {
......
......@@ -15,8 +15,7 @@ import emu.grasscutter.utils.Language;
import static emu.grasscutter.utils.Language.translate;
@Command(label = "setstats", usage = "setstats|stats <stat> <value>",
description = "Set fight property for your current active character", aliases = {"stats"}, permission = "player.setstats")
@Command(label = "setstats", usage = "setstats|stats <stat> <value>", aliases = {"stats"}, permission = "player.setstats")
public final class SetStatsCommand implements CommandHandler {
static class Stat {
String name;
......@@ -174,6 +173,11 @@ public final class SetStatsCommand implements CommandHandler {
stats.put("_nonextra_physical_add_hurt", new Stat("NONEXTRA_PHYSICAL_ADD_HURT", FightProperty.FIGHT_PROP_NONEXTRA_PHYSICAL_ADD_HURT, true));
}
@Override
public String description() {
return translate("commands.setStats.description");
}
@Override
public void execute(Player sender, Player targetPlayer, List<String> args) {
String syntax = sender == null ? translate("commands.setStats.usage_console") : translate("commands.setStats.ingame");
......
......@@ -10,10 +10,14 @@ import java.util.List;
import static emu.grasscutter.utils.Language.translate;
@Command(label = "setworldlevel", usage = "setworldlevel <level>",
description = "Sets your world level (Relog to see proper effects)",
aliases = {"setworldlvl"}, permission = "player.setworldlevel")
public final class SetWorldLevelCommand implements CommandHandler {
@Override
public String description() {
return translate("commands.setWorldLevel.description");
}
@Override
public void execute(Player sender, Player targetPlayer, List<String> args) {
if (targetPlayer == null) {
......
......@@ -22,10 +22,14 @@ import java.util.Random;
import static emu.grasscutter.utils.Language.translate;
@Command(label = "spawn", usage = "spawn <entityId> [amount] [level(monster only)]",
description = "Spawns an entity near you", permission = "server.spawn")
@Command(label = "spawn", usage = "spawn <entityId> [amount] [level(monster only)]", permission = "server.spawn")
public final class SpawnCommand implements CommandHandler {
@Override
public String description() {
return translate("commands.spawn.description");
}
@Override
public void execute(Player sender, Player targetPlayer, List<String> args) {
if (targetPlayer == null) {
......
......@@ -9,10 +9,14 @@ import java.util.List;
import static emu.grasscutter.utils.Language.translate;
@Command(label = "stop", usage = "stop",
description = "Stops the server", permission = "server.stop")
@Command(label = "stop", usage = "stop", permission = "server.stop")
public final class StopCommand implements CommandHandler {
@Override
public String description() {
return translate("commands.stop.description");
}
@Override
public void execute(Player sender, Player targetPlayer, List<String> args) {
CommandHandler.sendMessage(null, translate("commands.stop.success"));
......
......@@ -14,8 +14,7 @@ import java.util.List;
import static emu.grasscutter.utils.Language.translate;
@Command(label = "talent", usage = "talent <talentID> <value>",
description = "Set talent level for your current active character", permission = "player.settalent")
@Command(label = "talent", usage = "talent <talentID> <value>", permission = "player.settalent")
public final class TalentCommand implements CommandHandler {
private void setTalentLevel(Player sender, Player player, Avatar avatar, int talentId, int talentLevel) {
int oldLevel = avatar.getSkillLevelMap().get(talentId);
......@@ -44,6 +43,11 @@ public final class TalentCommand implements CommandHandler {
CommandHandler.sendMessage(sender, translate(successMessage, talentLevel));
}
@Override
public String description() {
return translate("commands.talent.description");
}
@Override
public void execute(Player sender, Player targetPlayer, List<String> args) {
if (targetPlayer == null) {
......
......@@ -10,9 +10,13 @@ import java.util.List;
import static emu.grasscutter.utils.Language.translate;
@Command(label = "tpall", usage = "tpall",
description = "Teleports all players in your world to your position", permission = "player.tpall")
@Command(label = "tpall", usage = "tpall", permission = "player.tpall")
public final class TeleportAllCommand implements CommandHandler {
@Override
public String description() {
return translate("commands.teleportAll.description");
}
@Override
public void execute(Player sender, Player targetPlayer, List<String> args) {
if (targetPlayer == null) {
......
......@@ -10,8 +10,7 @@ import java.util.List;
import static emu.grasscutter.utils.Language.translate;
@Command(label = "teleport", usage = "teleport <x> <y> <z> [scene id]", aliases = {"tp"},
description = "Change the player's position.", permission = "player.teleport")
@Command(label = "teleport", usage = "teleport <x> <y> <z> [scene id]", aliases = {"tp"}, permission = "player.teleport")
public final class TeleportCommand implements CommandHandler {
private float parseRelative(String input, Float current) { // TODO: Maybe this will be useful elsewhere later
......@@ -25,6 +24,11 @@ public final class TeleportCommand implements CommandHandler {
return current;
}
@Override
public String description() {
return translate("commands.teleport.description");
}
@Override
public void execute(Player sender, Player targetPlayer, List<String> args) {
if (targetPlayer == null) {
......
......@@ -11,10 +11,14 @@ import java.util.List;
import static emu.grasscutter.utils.Language.translate;
@Command(label = "weather", usage = "weather <weatherId> [climateId]",
description = "Changes the weather.", aliases = {"w"}, permission = "player.weather")
@Command(label = "weather", usage = "weather <weatherId> [climateId]", aliases = {"w"}, permission = "player.weather")
public final class WeatherCommand implements CommandHandler {
@Override
public String description() {
return translate("commands.weather.description");
}
@Override
public void execute(Player sender, Player targetPlayer, List<String> args) {
if (targetPlayer == null) {
......
......@@ -21,6 +21,7 @@ import com.google.gson.reflect.TypeToken;
import emu.grasscutter.GameConstants;
import emu.grasscutter.Grasscutter;
import emu.grasscutter.command.Command;
import emu.grasscutter.command.CommandHandler;
import emu.grasscutter.command.CommandMap;
import emu.grasscutter.data.GameData;
import emu.grasscutter.data.ResourceLoader;
......@@ -112,17 +113,16 @@ final class ToolsWithLanguageOption {
writer.println("// Created " + dtf.format(now) + System.lineSeparator() + System.lineSeparator());
CommandMap cmdMap = new CommandMap(true);
List<Command> cmdList = new ArrayList<>(cmdMap.getAnnotationsAsList());
HashMap<CommandHandler, Command> cmdList = cmdMap.getHandlersAndAnnotations();
writer.println("// Commands");
for (Command cmd : cmdList) {
String cmdName = cmd.label();
cmdList.forEach((handler, command) -> {
String cmdName = command.label();
while (cmdName.length() <= 15) {
cmdName = " " + cmdName;
}
writer.println(cmdName + " : " + cmd.description());
}
writer.println(cmdName + " : " + handler.description());
});
writer.println();
list = new ArrayList<>(GameData.getAvatarDataMap().keySet());
......
......@@ -95,17 +95,20 @@
"create": "Account created with UID %s.",
"delete": "Account deleted.",
"no_account": "Account not found.",
"command_usage": "Usage: account <create|delete> <username> [uid]"
"command_usage": "Usage: account <create|delete> <username> [uid]",
"description": "Modify user accounts"
},
"broadcast": {
"command_usage": "Usage: broadcast <message>",
"message_sent": "Message sent."
"message_sent": "Message sent.",
"description": "Sends a message to all the players"
},
"changescene": {
"usage": "Usage: changescene <sceneId>",
"already_in_scene": "You are already in that scene.",
"success": "Changed to scene %s.",
"exists_error": "The specified scene does not exist."
"exists_error": "The specified scene does not exist.",
"description": "Changes your scene"
},
"clear": {
"command_usage": "Usage: clear <all|wp|art|mat>",
......@@ -115,35 +118,41 @@
"furniture": "Cleared furniture for %s.",
"displays": "Cleared displays for %s.",
"virtuals": "Cleared virtuals for %s.",
"everything": "Cleared everything for %s."
"everything": "Cleared everything for %s.",
"description": "Deletes unequipped unlocked items, including yellow rarity ones from your inventory"
},
"coop": {
"usage": "Usage: coop <playerId> <target playerId>",
"success": "Summoned %s to %s's world."
"success": "Summoned %s to %s's world.",
"description": "Forces someone to join the world of others"
},
"enter_dungeon": {
"usage": "Usage: enterdungeon <dungeon id>",
"changed": "Changed to dungeon %s",
"not_found_error": "Dungeon does not exist",
"in_dungeon_error": "You are already in that dungeon"
"in_dungeon_error": "You are already in that dungeon",
"description": "Enter a dungeon"
},
"giveAll": {
"usage": "Usage: giveall [player] [amount]",
"started": "Receiving all items...",
"success": "Successfully gave all items to %s.",
"invalid_amount_or_playerId": "Invalid amount or player ID."
"invalid_amount_or_playerId": "Invalid amount or player ID.",
"description": "Gives all items"
},
"giveArtifact": {
"usage": "Usage: giveart|gart [player] <artifactId> <mainPropId> [<appendPropId>[,<times>]]... [level]",
"id_error": "Invalid artifact ID.",
"success": "Given %s to %s."
"success": "Given %s to %s.",
"description": "Gives the player a specified artifact"
},
"giveChar": {
"usage": "Usage: givechar <player> <itemId|itemName> [amount]",
"given": "Given %s with level %s to %s.",
"invalid_avatar_id": "Invalid avatar id.",
"invalid_avatar_level": "Invalid avatar level.",
"invalid_avatar_or_player_id": "Invalid avatar or player ID."
"invalid_avatar_or_player_id": "Invalid avatar or player ID.",
"description": "Gives the player a specified character"
},
"give": {
"usage": "Usage: give <player> <itemId|itemName> [amount] [level]",
......@@ -151,29 +160,36 @@
"refinement_must_between_1_and_5": "Refinement must be between 1 and 5.",
"given": "Given %s of %s to %s.",
"given_with_level_and_refinement": "Given %s with level %s, refinement %s %s times to %s",
"given_level": "Given %s with level %s %s times to %s"
"given_level": "Given %s with level %s %s times to %s",
"description": "Gives an item to you or the specified player"
},
"godmode": {
"success": "Godmode is now %s for %s."
"success": "Godmode is now %s for %s.",
"description": "Prevents you from taking damage. Defaults to toggle."
},
"heal": {
"success": "All characters have been healed."
"success": "All characters have been healed.",
"description": "Heal all characters in your current team."
},
"kick": {
"player_kick_player": "Player [%s:%s] has kicked player [%s:%s]",
"server_kick_player": "Kicking player [%s:%s]"
"server_kick_player": "Kicking player [%s:%s]",
"description": "Kicks the specified player from the server (WIP)"
},
"kill": {
"usage": "Usage: killall [playerUid] [sceneId]",
"scene_not_found_in_player_world": "Scene not found in player world",
"kill_monsters_in_scene": "Killing %s monsters in scene %s"
"kill_monsters_in_scene": "Killing %s monsters in scene %s",
"description": "Kill all entities"
},
"killCharacter": {
"usage": "Usage: /killcharacter [playerId]",
"success": "Killed %s's current character."
"success": "Killed %s's current character.",
"description": "Kills the players current character"
},
"list": {
"success": "There are %s player(s) online:"
"success": "There are %s player(s) online:",
"description": "List online players"
},
"permission": {
"usage": "Usage: permission <add|remove> <username> <permission>",
......@@ -181,21 +197,26 @@
"has_error": "They already have this permission!",
"remove": "Permission removed.",
"not_have_error": "They don't have this permission!",
"account_error": "The account cannot be found."
"account_error": "The account cannot be found.",
"description": "Grants or removes a permission for a user"
},
"position": {
"success": "Coordinates: %s, %s, %s\nScene id: %s"
"success": "Coordinates: %s, %s, %s\nScene id: %s",
"description": "Get coordinates."
},
"reload": {
"reload_start": "Reloading config.",
"reload_done": "Reload complete."
"reload_done": "Reload complete.",
"description": "Reload server config"
},
"resetConst": {
"reset_all": "Reset all avatars' constellations.",
"success": "Constellations for %s have been reset. Please relog to see changes."
"success": "Constellations for %s have been reset. Please relog to see changes.",
"description": "Resets the constellation level on your current active character, will need to relog after using the command to see any changes."
},
"resetShopLimit": {
"usage": "Usage: /resetshop <player id>"
"usage": "Usage: /resetshop <player id>",
"description": "Reset target player's shop refresh time."
},
"sendMail": {
"usage": "Usage: give [player] <itemId|itemName> [amount]",
......@@ -217,17 +238,20 @@
"message": "<message>",
"sender": "<sender>",
"arguments": "<itemId|itemName|finish> [amount] [level]",
"error": "ERROR: invalid construction stage %s. Check console for stacktrace."
"error": "ERROR: invalid construction stage %s. Check console for stacktrace.",
"description": "Sends mail to the specified user. The usage of this command changes based on it's composition state."
},
"sendMessage": {
"usage": "Usage: sendmessage <player> <message>",
"success": "Message sent."
"success": "Message sent.",
"description": "Sends a message to a player as the server"
},
"setFetterLevel": {
"usage": "Usage: setfetterlevel <level>",
"range_error": "Fetter level must be between 0 and 10.",
"success": "Fetter level set to %s",
"level_error": "Invalid fetter level."
"level_error": "Invalid fetter level.",
"description": "Sets your fetter level for your current active character"
},
"setStats": {
"usage_console": "Usage: setstats|stats @<UID> <stat> <value>",
......@@ -238,20 +262,24 @@
"player_error": "Player not found or offline.",
"set_self": "%s set to %s.",
"set_for_uid": "%s for %s set to %s.",
"set_max_hp": "MAX HP set to %s."
"set_max_hp": "MAX HP set to %s.",
"description": "Set fight property for your current active character"
},
"setWorldLevel": {
"usage": "Usage: setworldlevel <level>",
"value_error": "World level must be between 0-8",
"success": "World level set to %s.",
"invalid_world_level": "Invalid world level."
"invalid_world_level": "Invalid world level.",
"description": "Sets your world level (Relog to see proper effects)"
},
"spawn": {
"usage": "Usage: spawn <entityId> [amount] [level(monster only)]",
"success": "Spawned %s of %s."
"success": "Spawned %s of %s.",
"description": "Spawns an entity near you"
},
"stop": {
"success": "Server shutting down..."
"success": "Server shutting down...",
"description": "Stops the server"
},
"talent": {
"usage_1": "To set talent level: /talent set <talentID> <value>",
......@@ -267,32 +295,41 @@
"invalid_level": "Invalid talent level.",
"normal_attack_id": "Normal Attack ID %s.",
"e_skill_id": "E skill ID %s.",
"q_skill_id": "Q skill ID %s."
"q_skill_id": "Q skill ID %s.",
"description": "Set talent level for your current active character"
},
"teleportAll": {
"success": "Summoned all players to your location.",
"error": "You only can use this command in MP mode."
"error": "You only can use this command in MP mode.",
"description": "Teleports all players in your world to your position"
},
"teleport": {
"usage_server": "Usage: /tp @<player id> <x> <y> <z> [scene id]",
"usage": "Usage: /tp [@<player id>] <x> <y> <z> [scene id]",
"specify_player_id": "You must specify a player id.",
"invalid_position": "Invalid position.",
"success": "Teleported %s to %s, %s, %s in scene %s"
"success": "Teleported %s to %s, %s, %s in scene %s",
"description": "Change the player's position."
},
"weather": {
"usage": "Usage: weather <weatherId> [climateId]",
"success": "Changed weather to %s with climate %s",
"invalid_id": "Invalid ID."
"invalid_id": "Invalid ID.",
"description": "Changes the weather."
},
"drop": {
"command_usage": "Usage: drop <itemId|itemName> [amount]",
"success": "Dropped %s of %s."
"success": "Dropped %s of %s.",
"description": "Drops an item near you"
},
"help": {
"usage": "Usage: ",
"aliases": "Aliases: ",
"available_commands": "Available commands: "
"available_commands": "Available commands: ",
"description": "Sends the help message or shows information about a specified command"
},
"restart": {
"description": "Restarts the current session"
}
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment