mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-01-25 03:12:52 +08:00
Using annotation key translation
This commit is contained in:
parent
ef3579da82
commit
3a5503de72
@ -9,7 +9,7 @@ public @interface Command {
|
||||
|
||||
String usage() default "No usage specified";
|
||||
|
||||
String description() default "No description specified";
|
||||
String description() default "commands.generic.no_description_specified";
|
||||
|
||||
String[] aliases() default {};
|
||||
|
||||
|
@ -7,8 +7,6 @@ import java.util.List;
|
||||
|
||||
public interface CommandHandler {
|
||||
|
||||
default String description() { return null; };
|
||||
|
||||
/**
|
||||
* Send a message to the target.
|
||||
*
|
||||
|
@ -85,14 +85,6 @@ 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.
|
||||
*
|
||||
|
@ -9,14 +9,9 @@ import java.util.List;
|
||||
|
||||
import static emu.grasscutter.utils.Language.translate;
|
||||
|
||||
@Command(label = "account", usage = "account <create|delete> <username> [uid]")
|
||||
@Command(label = "account", usage = "account <create|delete> <username> [uid]", description = "commands.account.description")
|
||||
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) {
|
||||
|
@ -9,14 +9,9 @@ import java.util.List;
|
||||
|
||||
import static emu.grasscutter.utils.Language.translate;
|
||||
|
||||
@Command(label = "broadcast", usage = "broadcast <message>", aliases = {"b"}, permission = "server.broadcast")
|
||||
@Command(label = "broadcast", usage = "broadcast <message>", aliases = {"b"}, permission = "server.broadcast", description = "commands.broadcast.description")
|
||||
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) {
|
||||
|
@ -8,12 +8,8 @@ import java.util.List;
|
||||
|
||||
import static emu.grasscutter.utils.Language.translate;
|
||||
|
||||
@Command(label = "changescene", usage = "changescene <scene id>", aliases = {"scene"}, permission = "player.changescene")
|
||||
@Command(label = "changescene", usage = "changescene <scene id>", aliases = {"scene"}, permission = "player.changescene", description = "commands.changescene.description")
|
||||
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) {
|
||||
|
@ -13,15 +13,11 @@ 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 = "commands.clear.description",
|
||||
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) {
|
||||
|
@ -9,12 +9,8 @@ import java.util.List;
|
||||
|
||||
import static emu.grasscutter.utils.Language.translate;
|
||||
|
||||
@Command(label = "coop", usage = "coop [host UID]", permission = "server.coop")
|
||||
@Command(label = "coop", usage = "coop [host UID]", permission = "server.coop", description = "commands.coop.description")
|
||||
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) {
|
||||
|
@ -13,14 +13,9 @@ import java.util.List;
|
||||
|
||||
import static emu.grasscutter.utils.Language.translate;
|
||||
|
||||
@Command(label = "drop", usage = "drop <itemId|itemName> [amount]", aliases = {"d", "dropitem"}, permission = "server.drop")
|
||||
@Command(label = "drop", usage = "drop <itemId|itemName> [amount]", aliases = {"d", "dropitem"}, permission = "server.drop", description = "commands.drop.description")
|
||||
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) {
|
||||
|
@ -8,12 +8,8 @@ import java.util.List;
|
||||
|
||||
import static emu.grasscutter.utils.Language.translate;
|
||||
|
||||
@Command(label = "enterdungeon", usage = "enterdungeon <dungeon id>", aliases = {"dungeon"}, permission = "player.enterdungeon")
|
||||
@Command(label = "enterdungeon", usage = "enterdungeon <dungeon id>", aliases = {"dungeon"}, permission = "player.enterdungeon", description = "commands.enter_dungeon.description")
|
||||
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) {
|
||||
|
@ -15,14 +15,9 @@ import java.util.*;
|
||||
|
||||
import static emu.grasscutter.utils.Language.translate;
|
||||
|
||||
@Command(label = "giveall", usage = "giveall [amount]", aliases = {"givea"}, permission = "player.giveall", threading = true)
|
||||
@Command(label = "giveall", usage = "giveall [amount]", aliases = {"givea"}, permission = "player.giveall", threading = true, description = "commands.giveAll.description")
|
||||
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) {
|
||||
|
@ -16,12 +16,8 @@ import java.util.List;
|
||||
|
||||
import static emu.grasscutter.utils.Language.translate;
|
||||
|
||||
@Command(label = "giveart", usage = "giveart <artifactId> <mainPropId> [<appendPropId>[,<times>]]... [level]", aliases = {"gart"}, permission = "player.giveart")
|
||||
@Command(label = "giveart", usage = "giveart <artifactId> <mainPropId> [<appendPropId>[,<times>]]... [level]", aliases = {"gart"}, permission = "player.giveart", description = "commands.giveArtifact.description")
|
||||
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) {
|
||||
|
@ -12,14 +12,9 @@ import java.util.List;
|
||||
|
||||
import static emu.grasscutter.utils.Language.translate;
|
||||
|
||||
@Command(label = "givechar", usage = "givechar <avatarId> [level]", aliases = {"givec"}, permission = "player.givechar")
|
||||
@Command(label = "givechar", usage = "givechar <avatarId> [level]", aliases = {"givec"}, permission = "player.givechar", description = "commands.giveChar.description")
|
||||
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) {
|
||||
|
@ -17,7 +17,7 @@ import java.util.regex.Pattern;
|
||||
import static emu.grasscutter.utils.Language.translate;
|
||||
|
||||
@Command(label = "give", usage = "give <itemId|itemName> [amount] [level]", aliases = {
|
||||
"g", "item", "giveitem"}, permission = "player.give")
|
||||
"g", "item", "giveitem"}, permission = "player.give", description = "commands.give.description")
|
||||
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
|
||||
Pattern refineRegex = Pattern.compile("r(\\d+)");
|
||||
@ -31,11 +31,6 @@ 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) {
|
||||
|
@ -8,14 +8,9 @@ import java.util.List;
|
||||
|
||||
import static emu.grasscutter.utils.Language.translate;
|
||||
|
||||
@Command(label = "godmode", usage = "godmode [on|off|toggle]", permission = "player.godmode")
|
||||
@Command(label = "godmode", usage = "godmode [on|off|toggle]", permission = "player.godmode", description = "commands.godmode.description")
|
||||
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) {
|
||||
|
@ -11,12 +11,8 @@ import java.util.List;
|
||||
|
||||
import static emu.grasscutter.utils.Language.translate;
|
||||
|
||||
@Command(label = "heal", usage = "heal|h", aliases = {"h"}, permission = "player.heal")
|
||||
@Command(label = "heal", usage = "heal|h", aliases = {"h"}, permission = "player.heal", description = "commands.heal.description")
|
||||
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) {
|
||||
|
@ -10,26 +10,21 @@ import java.util.*;
|
||||
|
||||
import static emu.grasscutter.utils.Language.translate;
|
||||
|
||||
@Command(label = "help", usage = "help [command]")
|
||||
@Command(label = "help", usage = "help [command]", description = "commands.help.description")
|
||||
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();
|
||||
HashMap<Command, CommandHandler> annotations = new HashMap<>();
|
||||
List<Command> annotations = new ArrayList<>();
|
||||
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.put(annotation, handlers.get(key));
|
||||
annotations.add(annotation);
|
||||
}
|
||||
}
|
||||
|
||||
@ -43,7 +38,7 @@ public final class HelpCommand implements CommandHandler {
|
||||
} else {
|
||||
Command annotation = handler.getClass().getAnnotation(Command.class);
|
||||
|
||||
builder.append(" ").append(handler.description() == null ? annotation.description(): handler.description()).append("\n");
|
||||
builder.append(" ").append(translate(annotation.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"));
|
||||
@ -60,12 +55,12 @@ public final class HelpCommand implements CommandHandler {
|
||||
}
|
||||
}
|
||||
|
||||
void SendAllHelpMessage(Player player, HashMap<Command, CommandHandler> annotations) {
|
||||
void SendAllHelpMessage(Player player, List<Command> annotations) {
|
||||
if (player == null) {
|
||||
StringBuilder builder = new StringBuilder("\n" + translate("commands.help.available_commands") + "\n");
|
||||
annotations.forEach((annotation, handler) -> {
|
||||
annotations.forEach(annotation -> {
|
||||
builder.append(annotation.label()).append("\n");
|
||||
builder.append(" ").append(handler.description() == null ? annotation.description() : handler.description()).append("\n");
|
||||
builder.append(" ").append(translate(annotation.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"));
|
||||
@ -80,9 +75,9 @@ public final class HelpCommand implements CommandHandler {
|
||||
CommandHandler.sendMessage(null, builder.toString());
|
||||
} else {
|
||||
CommandHandler.sendMessage(player, translate("commands.help.available_commands"));
|
||||
annotations.forEach((annotation, handler) -> {
|
||||
annotations.forEach(annotation -> {
|
||||
StringBuilder builder = new StringBuilder(annotation.label()).append("\n");
|
||||
builder.append(" ").append(handler.description() == null ? annotation.description() : handler.description()).append("\n");
|
||||
builder.append(" ").append(translate(annotation.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"));
|
||||
|
@ -8,14 +8,9 @@ import java.util.List;
|
||||
|
||||
import static emu.grasscutter.utils.Language.translate;
|
||||
|
||||
@Command(label = "kick", usage = "kick", permission = "server.kick")
|
||||
@Command(label = "kick", usage = "kick", permission = "server.kick", description = "commands.kick.description")
|
||||
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) {
|
||||
|
@ -12,14 +12,9 @@ import java.util.List;
|
||||
|
||||
import static emu.grasscutter.utils.Language.translate;
|
||||
|
||||
@Command(label = "killall", usage = "killall [sceneId]", permission = "server.killall")
|
||||
@Command(label = "killall", usage = "killall [sceneId]", permission = "server.killall", description = "commands.kill.description")
|
||||
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) {
|
||||
|
@ -13,14 +13,9 @@ import java.util.List;
|
||||
|
||||
import static emu.grasscutter.utils.Language.translate;
|
||||
|
||||
@Command(label = "killcharacter", usage = "killcharacter", aliases = {"suicide", "kill"}, permission = "player.killcharacter")
|
||||
@Command(label = "killcharacter", usage = "killcharacter", aliases = {"suicide", "kill"}, permission = "player.killcharacter", description = "commands.list.description")
|
||||
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) {
|
||||
|
@ -10,14 +10,9 @@ import java.util.Map;
|
||||
|
||||
import static emu.grasscutter.utils.Language.translate;
|
||||
|
||||
@Command(label = "list", usage = "list [uid]", aliases = {"players"})
|
||||
@Command(label = "list", usage = "list [uid]", aliases = {"players"}, description = "commands.list.description")
|
||||
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,14 +10,9 @@ import java.util.List;
|
||||
|
||||
import static emu.grasscutter.utils.Language.translate;
|
||||
|
||||
@Command(label = "permission", usage = "permission <add|remove> <permission>", permission = "*")
|
||||
@Command(label = "permission", usage = "permission <add|remove> <permission>", permission = "*", description = "commands.permission.description")
|
||||
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,14 +9,9 @@ import java.util.List;
|
||||
|
||||
import static emu.grasscutter.utils.Language.translate;
|
||||
|
||||
@Command(label = "position", usage = "position", aliases = {"pos"})
|
||||
@Command(label = "position", usage = "position", aliases = {"pos"}, description = "commands.position.description")
|
||||
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,14 +9,9 @@ import java.util.List;
|
||||
|
||||
import static emu.grasscutter.utils.Language.translate;
|
||||
|
||||
@Command(label = "reload", usage = "reload", permission = "server.reload")
|
||||
@Command(label = "reload", usage = "reload", permission = "server.reload", description = "commands.reload.description")
|
||||
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,14 +11,9 @@ import java.util.List;
|
||||
import static emu.grasscutter.utils.Language.translate;
|
||||
|
||||
@Command(label = "resetconst", usage = "resetconst [all]",
|
||||
aliases = {"resetconstellation"}, permission = "player.resetconstellation")
|
||||
aliases = {"resetconstellation"}, permission = "player.resetconstellation", description = "commands.resetConst.description")
|
||||
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,12 +9,8 @@ import java.util.List;
|
||||
|
||||
import static emu.grasscutter.utils.Language.translate;
|
||||
|
||||
@Command(label = "resetshop", usage = "resetshop", permission = "server.resetshop")
|
||||
@Command(label = "resetshop", usage = "resetshop", permission = "server.resetshop", description = "commands.status.description")
|
||||
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) {
|
||||
|
@ -8,14 +8,9 @@ import java.util.List;
|
||||
|
||||
import static emu.grasscutter.utils.Language.translate;
|
||||
|
||||
@Command(label = "restart", usage = "restart")
|
||||
@Command(label = "restart", usage = "restart", description = "commands.restart.description")
|
||||
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,7 +13,7 @@ import java.util.List;
|
||||
import static emu.grasscutter.utils.Language.translate;
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
@Command(label = "sendmail", usage = "sendmail <userId|all|help> [templateId]", permission = "server.sendmail")
|
||||
@Command(label = "sendmail", usage = "sendmail <userId|all|help> [templateId]", permission = "server.sendmail", description = "commands.sendMail.description")
|
||||
public final class SendMailCommand implements CommandHandler {
|
||||
|
||||
// TODO: You should be able to do /sendmail and then just send subsequent messages until you finish
|
||||
@ -23,11 +23,6 @@ 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) {
|
||||
@ -44,7 +39,7 @@ public final class SendMailCommand implements CommandHandler {
|
||||
MailBuilder mailBuilder;
|
||||
switch (args.get(0).toLowerCase()) {
|
||||
case "help" -> {
|
||||
CommandHandler.sendMessage(sender, this.description() + "\nUsage: " + this.getClass().getAnnotation(Command.class).usage());
|
||||
CommandHandler.sendMessage(sender, translate(this.getClass().getAnnotation(Command.class).description()) + "\nUsage: " + this.getClass().getAnnotation(Command.class).usage());
|
||||
return;
|
||||
}
|
||||
case "all" -> mailBuilder = new MailBuilder(true, new Mail());
|
||||
|
@ -9,14 +9,9 @@ import java.util.List;
|
||||
import static emu.grasscutter.utils.Language.translate;
|
||||
|
||||
@Command(label = "say", usage = "say <message>",
|
||||
aliases = {"sendservmsg", "sendservermessage", "sendmessage"}, permission = "server.sendmessage")
|
||||
aliases = {"sendservmsg", "sendservermessage", "sendmessage"}, permission = "server.sendmessage", description = "commands.sendMessage.description")
|
||||
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,14 +12,9 @@ import emu.grasscutter.server.packet.send.PacketAvatarFetterDataNotify;
|
||||
import static emu.grasscutter.utils.Language.translate;
|
||||
|
||||
@Command(label = "setfetterlevel", usage = "setfetterlevel <level>",
|
||||
aliases = {"setfetterlvl", "setfriendship"}, permission = "player.setfetterlevel")
|
||||
aliases = {"setfetterlvl", "setfriendship"}, permission = "player.setfetterlevel", description = "commands.setFetterLevel.description")
|
||||
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,7 +15,7 @@ import emu.grasscutter.utils.Language;
|
||||
|
||||
import static emu.grasscutter.utils.Language.translate;
|
||||
|
||||
@Command(label = "setstats", usage = "setstats|stats <stat> <value>", aliases = {"stats"}, permission = "player.setstats")
|
||||
@Command(label = "setstats", usage = "setstats|stats <stat> <value>", aliases = {"stats"}, permission = "player.setstats", description = "commands.setStats.description")
|
||||
public final class SetStatsCommand implements CommandHandler {
|
||||
static class Stat {
|
||||
String name;
|
||||
@ -173,11 +173,6 @@ 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,14 +10,9 @@ import java.util.List;
|
||||
import static emu.grasscutter.utils.Language.translate;
|
||||
|
||||
@Command(label = "setworldlevel", usage = "setworldlevel <level>",
|
||||
aliases = {"setworldlvl"}, permission = "player.setworldlevel")
|
||||
aliases = {"setworldlvl"}, permission = "player.setworldlevel", description = "commands.setWorldLevel.description")
|
||||
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,14 +22,9 @@ import java.util.Random;
|
||||
|
||||
import static emu.grasscutter.utils.Language.translate;
|
||||
|
||||
@Command(label = "spawn", usage = "spawn <entityId> [amount] [level(monster only)]", permission = "server.spawn")
|
||||
@Command(label = "spawn", usage = "spawn <entityId> [amount] [level(monster only)]", permission = "server.spawn", description = "commands.spawn.description")
|
||||
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,14 +9,9 @@ import java.util.List;
|
||||
|
||||
import static emu.grasscutter.utils.Language.translate;
|
||||
|
||||
@Command(label = "stop", usage = "stop", permission = "server.stop")
|
||||
@Command(label = "stop", usage = "stop", permission = "server.stop", description = "commands.stop.description")
|
||||
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,7 +14,7 @@ import java.util.List;
|
||||
|
||||
import static emu.grasscutter.utils.Language.translate;
|
||||
|
||||
@Command(label = "talent", usage = "talent <talentID> <value>", permission = "player.settalent")
|
||||
@Command(label = "talent", usage = "talent <talentID> <value>", permission = "player.settalent", description = "commands.talent.description")
|
||||
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);
|
||||
@ -43,11 +43,6 @@ 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,12 +10,8 @@ import java.util.List;
|
||||
|
||||
import static emu.grasscutter.utils.Language.translate;
|
||||
|
||||
@Command(label = "tpall", usage = "tpall", permission = "player.tpall")
|
||||
@Command(label = "tpall", usage = "tpall", permission = "player.tpall", description = "commands.teleportAll.description")
|
||||
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) {
|
||||
|
@ -10,7 +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"}, permission = "player.teleport")
|
||||
@Command(label = "teleport", usage = "teleport <x> <y> <z> [scene id]", aliases = {"tp"}, permission = "player.teleport", description = "commands.teleport.description")
|
||||
public final class TeleportCommand implements CommandHandler {
|
||||
|
||||
private float parseRelative(String input, Float current) { // TODO: Maybe this will be useful elsewhere later
|
||||
@ -24,11 +24,6 @@ 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,14 +11,9 @@ import java.util.List;
|
||||
|
||||
import static emu.grasscutter.utils.Language.translate;
|
||||
|
||||
@Command(label = "weather", usage = "weather <weatherId> [climateId]", aliases = {"w"}, permission = "player.weather")
|
||||
@Command(label = "weather", usage = "weather <weatherId> [climateId]", aliases = {"w"}, permission = "player.weather", description = "commands.weather.description")
|
||||
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) {
|
||||
|
@ -31,6 +31,8 @@ import emu.grasscutter.data.def.MonsterData;
|
||||
import emu.grasscutter.data.def.SceneData;
|
||||
import emu.grasscutter.utils.Utils;
|
||||
|
||||
import static emu.grasscutter.utils.Language.translate;
|
||||
|
||||
public final class Tools {
|
||||
public static void createGmHandbook() throws Exception {
|
||||
ToolsWithLanguageOption.createGmHandbook(getLanguageOption());
|
||||
@ -113,16 +115,16 @@ final class ToolsWithLanguageOption {
|
||||
writer.println("// Created " + dtf.format(now) + System.lineSeparator() + System.lineSeparator());
|
||||
|
||||
CommandMap cmdMap = new CommandMap(true);
|
||||
HashMap<CommandHandler, Command> cmdList = cmdMap.getHandlersAndAnnotations();
|
||||
List<Command> cmdList = new ArrayList<>(cmdMap.getAnnotationsAsList());
|
||||
|
||||
writer.println("// Commands");
|
||||
cmdList.forEach((handler, command) -> {
|
||||
String cmdName = command.label();
|
||||
for (Command cmd : cmdList) {
|
||||
String cmdName = cmd.label();
|
||||
while (cmdName.length() <= 15) {
|
||||
cmdName = " " + cmdName;
|
||||
}
|
||||
writer.println(cmdName + " : " + (handler.description() == null ? command.description() : handler.description()));
|
||||
});
|
||||
writer.println(cmdName + " : " + translate(cmd.description()));
|
||||
}
|
||||
writer.println();
|
||||
|
||||
list = new ArrayList<>(GameData.getAvatarDataMap().keySet());
|
||||
|
@ -56,6 +56,7 @@
|
||||
"console_execute_error": "This command can only be run from the console.",
|
||||
"player_execute_error": "Run this command in-game.",
|
||||
"command_exist_error": "No command found.",
|
||||
"no_description_specified": "No description specified",
|
||||
"invalid": {
|
||||
"amount": "Invalid amount.",
|
||||
"artifactId": "Invalid artifactId.",
|
||||
|
Loading…
Reference in New Issue
Block a user