#758 Show login usage message on invalid arguments, #1053 send translatable "no permission" message

- Add default method to ExecutableCommand interface that allows to define the message key to show if a command's arguments are invalid. If not defined the behavior is as before: show the output of /<command> help
- Use translatable "no permission" message instead of hardcoded one
This commit is contained in:
ljacqu
2017-01-05 20:47:14 +01:00
parent dcf046dfc5
commit 6cf8789fe0
8 changed files with 85 additions and 24 deletions
@@ -49,4 +49,9 @@ public class ChangePasswordCommand extends PlayerCommand {
management.performPasswordChange(player, oldPassword, newPassword);
}
@Override
protected String getAlternativeCommand() {
return "/authme password <playername> <password>";
}
}
@@ -1,6 +1,7 @@
package fr.xephi.authme.command.executable.login;
import fr.xephi.authme.command.PlayerCommand;
import fr.xephi.authme.message.MessageKey;
import fr.xephi.authme.process.Management;
import org.bukkit.entity.Player;
@@ -20,4 +21,14 @@ public class LoginCommand extends PlayerCommand {
final String password = arguments.get(0);
management.performLogin(player, password);
}
@Override
public MessageKey getArgumentsMismatchMessage() {
return MessageKey.USAGE_LOGIN;
}
@Override
protected String getAlternativeCommand() {
return "/authme forcelogin <player>";
}
}
@@ -72,6 +72,11 @@ public class RegisterCommand extends PlayerCommand {
return "/authme register <playername> <password>";
}
@Override
public MessageKey getArgumentsMismatchMessage() {
return MessageKey.USAGE_LOGIN;
}
private void handlePasswordRegistration(Player player, List<String> arguments) {
if (isSecondArgValidForPasswordRegistration(player, arguments)) {
final String password = arguments.get(0);