#293 Translatable help - show translated description of child commands

- Show translated command descriptions when available
- Fix bug where localized command is registered on the parent each time

Thanks to @Maxetto
This commit is contained in:
ljacqu
2016-10-18 19:47:57 +02:00
parent 3dab5cd70c
commit 1d11824367
9 changed files with 112 additions and 85 deletions
@@ -70,7 +70,7 @@ public class CommandInitializer {
.description("Main command")
.detailedDescription("The main AuthMeReloaded command. The root for all admin commands.")
.executableCommand(AuthMeCommand.class)
.build();
.register();
// Register the register command
CommandDescription.builder()
@@ -82,7 +82,7 @@ public class CommandInitializer {
.withArgument("password", "Password", false)
.permission(AdminPermission.REGISTER)
.executableCommand(RegisterAdminCommand.class)
.build();
.register();
// Register the unregister command
CommandDescription.builder()
@@ -93,7 +93,7 @@ public class CommandInitializer {
.withArgument("player", "Player name", false)
.permission(AdminPermission.UNREGISTER)
.executableCommand(UnregisterAdminCommand.class)
.build();
.register();
// Register the forcelogin command
CommandDescription.builder()
@@ -104,7 +104,7 @@ public class CommandInitializer {
.withArgument("player", "Online player name", true)
.permission(AdminPermission.FORCE_LOGIN)
.executableCommand(ForceLoginCommand.class)
.build();
.register();
// Register the changepassword command
CommandDescription.builder()
@@ -116,7 +116,7 @@ public class CommandInitializer {
.withArgument("pwd", "New password", false)
.permission(AdminPermission.CHANGE_PASSWORD)
.executableCommand(ChangePasswordAdminCommand.class)
.build();
.register();
// Register the last login command
CommandDescription.builder()
@@ -127,7 +127,7 @@ public class CommandInitializer {
.withArgument("player", "Player name", true)
.permission(AdminPermission.LAST_LOGIN)
.executableCommand(LastLoginCommand.class)
.build();
.register();
// Register the accounts command
CommandDescription.builder()
@@ -138,7 +138,7 @@ public class CommandInitializer {
.withArgument("player", "Player name or IP", true)
.permission(AdminPermission.ACCOUNTS)
.executableCommand(AccountsCommand.class)
.build();
.register();
// Register the getemail command
CommandDescription.builder()
@@ -149,7 +149,7 @@ public class CommandInitializer {
.withArgument("player", "Player name", true)
.permission(AdminPermission.GET_EMAIL)
.executableCommand(GetEmailCommand.class)
.build();
.register();
// Register the setemail command
CommandDescription.builder()
@@ -161,7 +161,7 @@ public class CommandInitializer {
.withArgument("email", "Player email", false)
.permission(AdminPermission.CHANGE_EMAIL)
.executableCommand(SetEmailCommand.class)
.build();
.register();
// Register the getip command
CommandDescription.builder()
@@ -172,7 +172,7 @@ public class CommandInitializer {
.withArgument("player", "Player name", false)
.permission(AdminPermission.GET_IP)
.executableCommand(GetIpCommand.class)
.build();
.register();
// Register the spawn command
CommandDescription.builder()
@@ -182,7 +182,7 @@ public class CommandInitializer {
.detailedDescription("Teleport to the spawn.")
.permission(AdminPermission.SPAWN)
.executableCommand(SpawnCommand.class)
.build();
.register();
// Register the setspawn command
CommandDescription.builder()
@@ -192,7 +192,7 @@ public class CommandInitializer {
.detailedDescription("Change the player's spawn to your current position.")
.permission(AdminPermission.SET_SPAWN)
.executableCommand(SetSpawnCommand.class)
.build();
.register();
// Register the firstspawn command
CommandDescription.builder()
@@ -202,7 +202,7 @@ public class CommandInitializer {
.detailedDescription("Teleport to the first spawn.")
.permission(AdminPermission.FIRST_SPAWN)
.executableCommand(FirstSpawnCommand.class)
.build();
.register();
// Register the setfirstspawn command
CommandDescription.builder()
@@ -212,7 +212,7 @@ public class CommandInitializer {
.detailedDescription("Change the first player's spawn to your current position.")
.permission(AdminPermission.SET_FIRST_SPAWN)
.executableCommand(SetFirstSpawnCommand.class)
.build();
.register();
// Register the purge command
CommandDescription.builder()
@@ -224,7 +224,7 @@ public class CommandInitializer {
.withArgument("all", "Add 'all' at the end to also purge players with lastlogin = 0", true)
.permission(AdminPermission.PURGE)
.executableCommand(PurgeCommand.class)
.build();
.register();
// Register the purgelastposition command
CommandDescription.builder()
@@ -236,7 +236,7 @@ public class CommandInitializer {
.withArgument("player/*", "Player name or * for all players", false)
.permission(AdminPermission.PURGE_LAST_POSITION)
.executableCommand(PurgeLastPositionCommand.class)
.build();
.register();
// Register the purgebannedplayers command
CommandDescription.builder()
@@ -246,7 +246,7 @@ public class CommandInitializer {
.detailedDescription("Purge all AuthMeReloaded data for banned players.")
.permission(AdminPermission.PURGE_BANNED_PLAYERS)
.executableCommand(PurgeBannedPlayersCommand.class)
.build();
.register();
// Register the switchantibot command
CommandDescription.builder()
@@ -257,7 +257,7 @@ public class CommandInitializer {
.withArgument("mode", "ON / OFF", true)
.permission(AdminPermission.SWITCH_ANTIBOT)
.executableCommand(SwitchAntiBotCommand.class)
.build();
.register();
// Register the reload command
CommandDescription.builder()
@@ -267,7 +267,7 @@ public class CommandInitializer {
.detailedDescription("Reload the AuthMeReloaded plugin.")
.permission(AdminPermission.RELOAD)
.executableCommand(ReloadCommand.class)
.build();
.register();
// Register the version command
CommandDescription.builder()
@@ -277,7 +277,7 @@ public class CommandInitializer {
.detailedDescription("Show detailed information about the installed AuthMeReloaded version, the "
+ "developers, contributors, and license.")
.executableCommand(VersionCommand.class)
.build();
.register();
CommandDescription.builder()
.parent(AUTHME_BASE)
@@ -288,7 +288,7 @@ public class CommandInitializer {
"royalauth / vauth / sqliteToSql / mysqlToSqlite", false)
.permission(AdminPermission.CONVERTER)
.executableCommand(ConverterCommand.class)
.build();
.register();
CommandDescription.builder()
.parent(AUTHME_BASE)
@@ -297,7 +297,7 @@ public class CommandInitializer {
.detailedDescription("Adds missing messages to the current messages file.")
.permission(AdminPermission.UPDATE_MESSAGES)
.executableCommand(MessagesCommand.class)
.build();
.register();
// Register the base login command
final CommandDescription LOGIN_BASE = CommandDescription.builder()
@@ -308,7 +308,7 @@ public class CommandInitializer {
.withArgument("password", "Login password", false)
.permission(PlayerPermission.LOGIN)
.executableCommand(LoginCommand.class)
.build();
.register();
// Register the base logout command
CommandDescription LOGOUT_BASE = CommandDescription.builder()
@@ -318,7 +318,7 @@ public class CommandInitializer {
.detailedDescription("Command to logout using AuthMeReloaded.")
.permission(PlayerPermission.LOGOUT)
.executableCommand(LogoutCommand.class)
.build();
.register();
// Register the base register command
final CommandDescription REGISTER_BASE = CommandDescription.builder()
@@ -330,7 +330,7 @@ public class CommandInitializer {
.withArgument("verifyPassword", "Verify password", true)
.permission(PlayerPermission.REGISTER)
.executableCommand(RegisterCommand.class)
.build();
.register();
// Register the base unregister command
CommandDescription UNREGISTER_BASE = CommandDescription.builder()
@@ -341,7 +341,7 @@ public class CommandInitializer {
.withArgument("password", "Password", false)
.permission(PlayerPermission.UNREGISTER)
.executableCommand(UnregisterCommand.class)
.build();
.register();
// Register the base changepassword command
final CommandDescription CHANGE_PASSWORD_BASE = CommandDescription.builder()
@@ -353,7 +353,7 @@ public class CommandInitializer {
.withArgument("newPassword", "New Password.", false)
.permission(PlayerPermission.CHANGE_PASSWORD)
.executableCommand(ChangePasswordCommand.class)
.build();
.register();
// Register the base Email command
CommandDescription EMAIL_BASE = CommandDescription.builder()
@@ -362,7 +362,7 @@ public class CommandInitializer {
.description("Email command")
.detailedDescription("The AuthMeReloaded Email command base.")
.executableCommand(EmailBaseCommand.class)
.build();
.register();
// Register the show command
CommandDescription.builder()
@@ -371,7 +371,7 @@ public class CommandInitializer {
.description("Show Email")
.detailedDescription("Show your current email address.")
.executableCommand(ShowEmailCommand.class)
.build();
.register();
// Register the add command
CommandDescription.builder()
@@ -383,7 +383,7 @@ public class CommandInitializer {
.withArgument("verifyEmail", "Email address verification", false)
.permission(PlayerPermission.ADD_EMAIL)
.executableCommand(AddEmailCommand.class)
.build();
.register();
// Register the change command
CommandDescription.builder()
@@ -395,7 +395,7 @@ public class CommandInitializer {
.withArgument("newEmail", "New email address", false)
.permission(PlayerPermission.CHANGE_EMAIL)
.executableCommand(ChangeEmailCommand.class)
.build();
.register();
// Register the recover command
CommandDescription.builder()
@@ -408,7 +408,7 @@ public class CommandInitializer {
.withArgument("code", "Recovery code", true)
.permission(PlayerPermission.RECOVER_EMAIL)
.executableCommand(RecoverEmailCommand.class)
.build();
.register();
// Register the base captcha command
CommandDescription CAPTCHA_BASE = CommandDescription.builder()
@@ -419,7 +419,7 @@ public class CommandInitializer {
.withArgument("captcha", "The Captcha", false)
.permission(PlayerPermission.CAPTCHA)
.executableCommand(CaptchaCommand.class)
.build();
.register();
Set<CommandDescription> baseCommands = ImmutableSet.of(
AUTHME_BASE,
@@ -451,7 +451,7 @@ public class CommandInitializer {
.detailedDescription("View detailed help for /" + base.getLabels().get(0) + " commands.")
.withArgument("query", "The command or query to view help for.", true)
.executableCommand(HelpCommand.class)
.build();
.register();
}
}
}