Add command description multilingual

This commit is contained in:
方块君 2022-05-08 10:33:53 +08:00 committed by Melledy
parent b69c58cab1
commit 05e1e5502c
40 changed files with 306 additions and 115 deletions

View File

@ -9,8 +9,6 @@ public @interface Command {
String usage() default "No usage specified";
String description() default "No description specified";
String[] aliases() default {};
String permission() default "";

View File

@ -6,6 +6,9 @@ import emu.grasscutter.game.player.Player;
import java.util.List;
public interface CommandHandler {
String description();
/**
* Send a message to the target.
*

View File

@ -85,6 +85,14 @@ public final class CommandMap {
return new LinkedHashMap<>(this.annotations);
}
public HashMap<CommandHandler, Command> getHandlersAndAnnotations() {
HashMap<CommandHandler, Command> hashMap = new HashMap<>();
this.commands.forEach((key, handler) -> {
hashMap.put(handler, this.annotations.get(key));
});
return hashMap;
}
/**
* Returns a list of all registered commands.
*

View File

@ -9,9 +9,14 @@ import java.util.List;
import static emu.grasscutter.utils.Language.translate;
@Command(label = "account", usage = "account <create|delete> <username> [uid]", description = "Modify user accounts")
@Command(label = "account", usage = "account <create|delete> <username> [uid]")
public final class AccountCommand implements CommandHandler {
@Override
public String description() {
return translate("commands.account.description");
}
@Override
public void execute(Player sender, Player targetPlayer, List<String> args) {
if (sender != null) {

View File

@ -9,10 +9,14 @@ import java.util.List;
import static emu.grasscutter.utils.Language.translate;
@Command(label = "broadcast", usage = "broadcast <message>",
description = "Sends a message to all the players", aliases = {"b"}, permission = "server.broadcast")
@Command(label = "broadcast", usage = "broadcast <message>", aliases = {"b"}, permission = "server.broadcast")
public final class BroadcastCommand implements CommandHandler {
@Override
public String description() {
return translate("commands.broadcast.description");
}
@Override
public void execute(Player sender, Player targetPlayer, List<String> args) {
if (args.size() < 1) {

View File

@ -8,9 +8,13 @@ import java.util.List;
import static emu.grasscutter.utils.Language.translate;
@Command(label = "changescene", usage = "changescene <scene id>",
description = "Changes your scene", aliases = {"scene"}, permission = "player.changescene")
@Command(label = "changescene", usage = "changescene <scene id>", aliases = {"scene"}, permission = "player.changescene")
public final class ChangeSceneCommand implements CommandHandler {
@Override
public String description() {
return translate("commands.changescene.description");
}
@Override
public void execute(Player sender, Player targetPlayer, List<String> args) {
if (targetPlayer == null) {

View File

@ -13,11 +13,15 @@ import java.util.List;
import static emu.grasscutter.utils.Language.translate;
@Command(label = "clear", usage = "clear <all|wp|art|mat>", //Merged /clearartifacts and /clearweapons to /clear <args> [uid]
description = "Deletes unequipped unlocked items, including yellow rarity ones from your inventory",
aliases = {"clear"}, permission = "player.clearinv")
public final class ClearCommand implements CommandHandler {
@Override
public String description() {
return translate("commands.clear.description");
}
@Override
public void execute(Player sender, Player targetPlayer, List<String> args) {
if (targetPlayer == null) {

View File

@ -9,9 +9,13 @@ import java.util.List;
import static emu.grasscutter.utils.Language.translate;
@Command(label = "coop", usage = "coop [host UID]",
description = "Forces someone to join the world of others", permission = "server.coop")
@Command(label = "coop", usage = "coop [host UID]", permission = "server.coop")
public final class CoopCommand implements CommandHandler {
@Override
public String description() {
return translate("commands.coop.description");
}
@Override
public void execute(Player sender, Player targetPlayer, List<String> args) {
if (targetPlayer == null) {

View File

@ -13,10 +13,14 @@ import java.util.List;
import static emu.grasscutter.utils.Language.translate;
@Command(label = "drop", usage = "drop <itemId|itemName> [amount]",
description = "Drops an item near you", aliases = {"d", "dropitem"}, permission = "server.drop")
@Command(label = "drop", usage = "drop <itemId|itemName> [amount]", aliases = {"d", "dropitem"}, permission = "server.drop")
public final class DropCommand implements CommandHandler {
@Override
public String description() {
return translate("commands.drop.description");
}
@Override
public void execute(Player sender, Player targetPlayer, List<String> args) {
if (targetPlayer == null) {

View File

@ -8,9 +8,13 @@ import java.util.List;
import static emu.grasscutter.utils.Language.translate;
@Command(label = "enterdungeon", usage = "enterdungeon <dungeon id>",
description = "Enter a dungeon", aliases = {"dungeon"}, permission = "player.enterdungeon")
@Command(label = "enterdungeon", usage = "enterdungeon <dungeon id>", aliases = {"dungeon"}, permission = "player.enterdungeon")
public final class EnterDungeonCommand implements CommandHandler {
@Override
public String description() {
return translate("commands.enter_dungeon.description");
}
@Override
public void execute(Player sender, Player targetPlayer, List<String> args) {
if (targetPlayer == null) {

View File

@ -15,10 +15,14 @@ import java.util.*;
import static emu.grasscutter.utils.Language.translate;
@Command(label = "giveall", usage = "giveall [amount]",
description = "Gives all items", aliases = {"givea"}, permission = "player.giveall", threading = true)
@Command(label = "giveall", usage = "giveall [amount]", aliases = {"givea"}, permission = "player.giveall", threading = true)
public final class GiveAllCommand implements CommandHandler {
@Override
public String description() {
return translate("commands.giveAll.description");
}
@Override
public void execute(Player sender, Player targetPlayer, List<String> args) {
if (targetPlayer == null) {

View File

@ -16,8 +16,13 @@ import java.util.List;
import static emu.grasscutter.utils.Language.translate;
@Command(label = "giveart", usage = "giveart <artifactId> <mainPropId> [<appendPropId>[,<times>]]... [level]", description = "Gives the player a specified artifact", aliases = {"gart"}, permission = "player.giveart")
@Command(label = "giveart", usage = "giveart <artifactId> <mainPropId> [<appendPropId>[,<times>]]... [level]", aliases = {"gart"}, permission = "player.giveart")
public final class GiveArtifactCommand implements CommandHandler {
@Override
public String description() {
return translate("commands.giveArtifact.description");
}
@Override
public void execute(Player sender, Player targetPlayer, List<String> args) {
if (targetPlayer == null) {

View File

@ -12,10 +12,14 @@ import java.util.List;
import static emu.grasscutter.utils.Language.translate;
@Command(label = "givechar", usage = "givechar <avatarId> [level]",
description = "Gives the player a specified character", aliases = {"givec"}, permission = "player.givechar")
@Command(label = "givechar", usage = "givechar <avatarId> [level]", aliases = {"givec"}, permission = "player.givechar")
public final class GiveCharCommand implements CommandHandler {
@Override
public String description() {
return translate("commands.giveChar.description");
}
@Override
public void execute(Player sender, Player targetPlayer, List<String> args) {
if (targetPlayer == null) {

View File

@ -1,6 +1,5 @@
package emu.grasscutter.command.commands;
import emu.grasscutter.Grasscutter;
import emu.grasscutter.command.Command;
import emu.grasscutter.command.CommandHandler;
import emu.grasscutter.data.GameData;
@ -12,12 +11,12 @@ import emu.grasscutter.game.props.ActionReason;
import java.util.LinkedList;
import java.util.List;
import java.util.regex.Pattern;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static emu.grasscutter.utils.Language.translate;
@Command(label = "give", usage = "give <itemId|itemName> [amount] [level]", description = "Gives an item to you or the specified player", aliases = {
@Command(label = "give", usage = "give <itemId|itemName> [amount] [level]", aliases = {
"g", "item", "giveitem"}, permission = "player.give")
public final class GiveCommand implements CommandHandler {
Pattern lvlRegex = Pattern.compile("l(?:vl?)?(\\d+)"); // Java is a joke of a proglang that doesn't have raw string literals
@ -32,6 +31,11 @@ public final class GiveCommand implements CommandHandler {
return -1;
}
@Override
public String description() {
return translate("commands.give.description");
}
@Override
public void execute(Player sender, Player targetPlayer, List<String> args) {
if (targetPlayer == null) {

View File

@ -1,6 +1,5 @@
package emu.grasscutter.command.commands;
import emu.grasscutter.Grasscutter;
import emu.grasscutter.command.Command;
import emu.grasscutter.command.CommandHandler;
import emu.grasscutter.game.player.Player;
@ -9,10 +8,14 @@ import java.util.List;
import static emu.grasscutter.utils.Language.translate;
@Command(label = "godmode", usage = "godmode [on|off|toggle]",
description = "Prevents you from taking damage. Defaults to toggle.", permission = "player.godmode")
@Command(label = "godmode", usage = "godmode [on|off|toggle]", permission = "player.godmode")
public final class GodModeCommand implements CommandHandler {
@Override
public String description() {
return translate("commands.godmode.description");
}
@Override
public void execute(Player sender, Player targetPlayer, List<String> args) {
if (targetPlayer == null) {

View File

@ -11,9 +11,13 @@ import java.util.List;
import static emu.grasscutter.utils.Language.translate;
@Command(label = "heal", usage = "heal|h", aliases = {"h"},
description = "Heal all characters in your current team.", permission = "player.heal")
@Command(label = "heal", usage = "heal|h", aliases = {"h"}, permission = "player.heal")
public final class HealCommand implements CommandHandler {
@Override
public String description() {
return translate("commands.heal.description");
}
@Override
public void execute(Player sender, Player targetPlayer, List<String> args) {
if (targetPlayer == null) {

View File

@ -10,22 +10,26 @@ import java.util.*;
import static emu.grasscutter.utils.Language.translate;
@Command(label = "help", usage = "help [command]",
description = "Sends the help message or shows information about a specified command")
@Command(label = "help", usage = "help [command]")
public final class HelpCommand implements CommandHandler {
@Override
public String description() {
return translate("commands.help.description");
}
@Override
public void execute(Player player, Player targetPlayer, List<String> args) {
if (args.size() < 1) {
HashMap<String, CommandHandler> handlers = CommandMap.getInstance().getHandlers();
List<Command> annotations = new ArrayList<>();
HashMap<Command, CommandHandler> annotations = new HashMap<>();
for (String key : handlers.keySet()) {
Command annotation = handlers.get(key).getClass().getAnnotation(Command.class);
if (!Arrays.asList(annotation.aliases()).contains(key)) {
if (player != null && !Objects.equals(annotation.permission(), "") && !player.getAccount().hasPermission(annotation.permission()))
continue;
annotations.add(annotation);
annotations.put(annotation, handlers.get(key));
}
}
@ -39,7 +43,7 @@ public final class HelpCommand implements CommandHandler {
} else {
Command annotation = handler.getClass().getAnnotation(Command.class);
builder.append(" ").append(annotation.description()).append("\n");
builder.append(" ").append(handler.description()).append("\n");
builder.append(translate("commands.help.usage")).append(annotation.usage());
if (annotation.aliases().length >= 1) {
builder.append("\n").append(translate("commands.help.aliases"));
@ -56,12 +60,12 @@ public final class HelpCommand implements CommandHandler {
}
}
void SendAllHelpMessage(Player player, List<Command> annotations) {
void SendAllHelpMessage(Player player, HashMap<Command, CommandHandler> annotations) {
if (player == null) {
StringBuilder builder = new StringBuilder("\n" + translate("commands.help.available_commands") + "\n");
annotations.forEach(annotation -> {
annotations.forEach((annotation, handler) -> {
builder.append(annotation.label()).append("\n");
builder.append(" ").append(annotation.description()).append("\n");
builder.append(" ").append(handler.description()).append("\n");
builder.append(translate("commands.help.usage")).append(annotation.usage());
if (annotation.aliases().length >= 1) {
builder.append("\n").append(translate("commands.help.aliases"));
@ -76,9 +80,9 @@ public final class HelpCommand implements CommandHandler {
CommandHandler.sendMessage(null, builder.toString());
} else {
CommandHandler.sendMessage(player, translate("commands.help.available_commands"));
annotations.forEach(annotation -> {
annotations.forEach((annotation, handler) -> {
StringBuilder builder = new StringBuilder(annotation.label()).append("\n");
builder.append(" ").append(annotation.description()).append("\n");
builder.append(" ").append(handler.description()).append("\n");
builder.append(translate("commands.help.usage")).append(annotation.usage());
if (annotation.aliases().length >= 1) {
builder.append("\n").append(translate("commands.help.aliases"));

View File

@ -8,10 +8,14 @@ import java.util.List;
import static emu.grasscutter.utils.Language.translate;
@Command(label = "kick", usage = "kick",
description = "Kicks the specified player from the server (WIP)", permission = "server.kick")
@Command(label = "kick", usage = "kick", permission = "server.kick")
public final class KickCommand implements CommandHandler {
@Override
public String description() {
return translate("commands.kick.description");
}
@Override
public void execute(Player sender, Player targetPlayer, List<String> args) {
if (targetPlayer == null) {

View File

@ -12,10 +12,14 @@ import java.util.List;
import static emu.grasscutter.utils.Language.translate;
@Command(label = "killall", usage = "killall [sceneId]",
description = "Kill all entities", permission = "server.killall")
@Command(label = "killall", usage = "killall [sceneId]", permission = "server.killall")
public final class KillAllCommand implements CommandHandler {
@Override
public String description() {
return translate("commands.kill.description");
}
@Override
public void execute(Player sender, Player targetPlayer, List<String> args) {
if (targetPlayer == null) {

View File

@ -13,10 +13,14 @@ import java.util.List;
import static emu.grasscutter.utils.Language.translate;
@Command(label = "killcharacter", usage = "killcharacter", aliases = {"suicide", "kill"},
description = "Kills the players current character", permission = "player.killcharacter")
@Command(label = "killcharacter", usage = "killcharacter", aliases = {"suicide", "kill"}, permission = "player.killcharacter")
public final class KillCharacterCommand implements CommandHandler {
@Override
public String description() {
return translate("commands.killCharacter.description");
}
@Override
public void execute(Player sender, Player targetPlayer, List<String> args) {
if (targetPlayer == null) {

View File

@ -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();

View File

@ -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) {

View File

@ -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) {

View File

@ -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"));

View File

@ -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) {

View File

@ -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) {

View File

@ -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) {

View File

@ -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());

View File

@ -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) {

View File

@ -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) {

View File

@ -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");

View File

@ -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) {

View File

@ -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) {

View File

@ -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"));

View File

@ -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) {

View File

@ -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) {

View File

@ -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) {

View File

@ -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) {

View File

@ -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());

View File

@ -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"
}
}
}