#1055 Remove multiple "please register" messages

Part 1:
- Use only one message entry for "Please register", that may have to be adapted to reflect the proper /register arguments
- Remove other message entries from code and from the messages files

Breaking change: reg_email_msg is also removed
This commit is contained in:
ljacqu
2017-01-07 09:01:03 +01:00
parent 044e3e3845
commit 385f7d6b1d
39 changed files with 13 additions and 295 deletions
@@ -59,7 +59,7 @@ public class RecoverEmailCommand extends PlayerCommand {
PlayerAuth auth = dataSource.getAuth(playerName); // TODO: Create method to get email only
if (auth == null) {
commonService.send(player, MessageKey.REGISTER_EMAIL_MESSAGE);
commonService.send(player, MessageKey.USAGE_REGISTER);
return;
}
@@ -64,18 +64,6 @@ public enum MessageKey {
/** Please, register to the server with the command "/register <password> <ConfirmPassword>" */
REGISTER_MESSAGE("reg_msg"),
/** Please, register to the server with the command "/register <password>" */
REGISTER_NO_REPEAT_MESSAGE("reg_no_repeat_msg"),
/** Please, register to the server with the command "/register <email> <confirmEmail>" */
REGISTER_EMAIL_MESSAGE("reg_email_msg"),
/** Please, register to the server with the command "/register <email>" */
REGISTER_EMAIL_NO_REPEAT_MESSAGE("reg_email_no_repeat_msg"),
/** Please, register to the server with the command "/register <password> <email>" */
REGISTER_PASSWORD_EMAIL_MESSAGE("reg_psw_email_msg"),
/** You have exceeded the maximum number of registrations (%reg_count/%max_acc %reg_names) for your connection! */
MAX_REGISTER_EXCEEDED("max_reg", "%max_acc", "%reg_count", "%reg_names"),
@@ -8,8 +8,6 @@ import fr.xephi.authme.message.MessageKey;
import fr.xephi.authme.process.AsynchronousProcess;
import fr.xephi.authme.service.CommonService;
import fr.xephi.authme.service.ValidationService;
import fr.xephi.authme.settings.properties.RegistrationSettings;
import fr.xephi.authme.util.Utils;
import org.bukkit.entity.Player;
import javax.inject.Inject;
@@ -65,10 +63,7 @@ public class AsyncAddEmail implements AsynchronousProcess {
if (dataSource.isAuthAvailable(player.getName())) {
service.send(player, MessageKey.LOGIN_MESSAGE);
} else {
MessageKey registerMessage = Utils.getRegisterMessage(
service.getProperty(RegistrationSettings.REGISTRATION_TYPE),
service.getProperty(RegistrationSettings.REGISTER_SECOND_ARGUMENT));
service.send(player, registerMessage);
service.send(player, MessageKey.REGISTER_MESSAGE);
}
}
@@ -7,8 +7,6 @@ import fr.xephi.authme.message.MessageKey;
import fr.xephi.authme.process.AsynchronousProcess;
import fr.xephi.authme.service.CommonService;
import fr.xephi.authme.service.ValidationService;
import fr.xephi.authme.settings.properties.RegistrationSettings;
import fr.xephi.authme.util.Utils;
import org.bukkit.entity.Player;
import javax.inject.Inject;
@@ -68,10 +66,7 @@ public class AsyncChangeEmail implements AsynchronousProcess {
if (dataSource.isAuthAvailable(player.getName())) {
service.send(player, MessageKey.LOGIN_MESSAGE);
} else {
MessageKey registerMessage = Utils.getRegisterMessage(
service.getProperty(RegistrationSettings.REGISTRATION_TYPE),
service.getProperty(RegistrationSettings.REGISTER_SECOND_ARGUMENT));
service.send(player, registerMessage);
service.send(player, MessageKey.REGISTER_MESSAGE);
}
}
}
@@ -1,67 +0,0 @@
package fr.xephi.authme.settings.properties;
import fr.xephi.authme.message.MessageKey;
/**
* Type of arguments used for the login command.
*/
public enum RegistrationArgumentType {
/** /register [password] */
PASSWORD(Execution.PASSWORD, 1, MessageKey.REGISTER_NO_REPEAT_MESSAGE),
/** /register [password] [password] */
PASSWORD_WITH_CONFIRMATION(Execution.PASSWORD, 2, MessageKey.REGISTER_MESSAGE),
/** /register [email] */
EMAIL(Execution.EMAIL, 1, MessageKey.REGISTER_EMAIL_NO_REPEAT_MESSAGE),
/** /register [email] [email] */
EMAIL_WITH_CONFIRMATION(Execution.EMAIL, 2, MessageKey.REGISTER_EMAIL_MESSAGE),
/** /register [password] [email] */
PASSWORD_WITH_EMAIL(Execution.PASSWORD, 1, MessageKey.REGISTER_PASSWORD_EMAIL_MESSAGE);
private final Execution execution;
private final int requiredNumberOfArgs;
private final MessageKey messageKey;
/**
* Constructor.
*
* @param execution the registration process
* @param requiredNumberOfArgs the required number of arguments
*/
RegistrationArgumentType(Execution execution, int requiredNumberOfArgs, MessageKey messageKey) {
this.execution = execution;
this.requiredNumberOfArgs = requiredNumberOfArgs;
this.messageKey = messageKey;
}
/**
* @return the registration execution that is used for this argument type
*/
public Execution getExecution() {
return execution;
}
public MessageKey getMessageKey(){
return messageKey;
}
/**
* @return number of arguments required to process the register command
*/
public int getRequiredNumberOfArgs() {
return requiredNumberOfArgs;
}
/**
* Registration execution (the type of registration).
*/
public enum Execution {
PASSWORD,
EMAIL
}
}
@@ -10,7 +10,6 @@ import fr.xephi.authme.service.BukkitService;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.properties.RegistrationSettings;
import fr.xephi.authme.settings.properties.RestrictionSettings;
import fr.xephi.authme.util.Utils;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.scheduler.BukkitTask;
@@ -96,9 +95,7 @@ public class LimboPlayerTaskManager {
if (isRegistered) {
return MessageKey.LOGIN_MESSAGE;
} else {
return Utils.getRegisterMessage(
settings.getProperty(RegistrationSettings.REGISTRATION_TYPE),
settings.getProperty(RegistrationSettings.REGISTER_SECOND_ARGUMENT));
return MessageKey.REGISTER_MESSAGE;
}
}
@@ -1,9 +1,6 @@
package fr.xephi.authme.util;
import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.message.MessageKey;
import fr.xephi.authme.process.register.RegisterSecondaryArgument;
import fr.xephi.authme.process.register.RegistrationType;
import java.util.regex.Pattern;
@@ -62,30 +59,4 @@ public final class Utils {
return Runtime.getRuntime().availableProcessors();
}
/**
* Returns the proper message key for the given registration types.
*
* @param registrationType the registration type
* @param secondaryArgType secondary argument type for the register command
* @return the message key
*/
// TODO #1037: Remove this method
public static MessageKey getRegisterMessage(RegistrationType registrationType,
RegisterSecondaryArgument secondaryArgType) {
if (registrationType == RegistrationType.PASSWORD) {
if (secondaryArgType == RegisterSecondaryArgument.CONFIRMATION) {
return MessageKey.REGISTER_MESSAGE;
} else if (secondaryArgType == RegisterSecondaryArgument.NONE) {
return MessageKey.REGISTER_NO_REPEAT_MESSAGE;
} else { /* EMAIL_MANDATORY || EMAIL_OPTIONAL */
return MessageKey.REGISTER_PASSWORD_EMAIL_MESSAGE;
}
} else { /* registrationType == EMAIL */
if (secondaryArgType == RegisterSecondaryArgument.NONE) {
return MessageKey.REGISTER_EMAIL_NO_REPEAT_MESSAGE;
} else { /* CONFIRMATION || EMAIL_MANDATORY || EMAIL_OPTIONAL */
return MessageKey.REGISTER_EMAIL_MESSAGE;
}
}
}
}