#427 Define registration type with two options - one configuring the 2nd argument
- Split sole setting to two: one defining the registration type, and one defining what the register command should take as second argument - Contains ugly code that will be fixed with a later issue
This commit is contained in:
@@ -1,9 +1,5 @@
|
||||
package fr.xephi.authme.process.email;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.data.auth.PlayerAuth;
|
||||
import fr.xephi.authme.data.auth.PlayerCache;
|
||||
@@ -13,6 +9,10 @@ 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;
|
||||
|
||||
/**
|
||||
* Async task to add an email to an account.
|
||||
@@ -65,7 +65,10 @@ public class AsyncAddEmail implements AsynchronousProcess {
|
||||
if (dataSource.isAuthAvailable(player.getName())) {
|
||||
service.send(player, MessageKey.LOGIN_MESSAGE);
|
||||
} else {
|
||||
service.send(player, service.getProperty(RegistrationSettings.REGISTRATION_TYPE).getMessageKey());
|
||||
MessageKey registerMessage = Utils.getRegisterMessage(
|
||||
service.getProperty(RegistrationSettings.REGISTRATION_TYPE),
|
||||
service.getProperty(RegistrationSettings.REGISTER_SECOND_ARGUMENT));
|
||||
service.send(player, registerMessage);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
package fr.xephi.authme.process.email;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import fr.xephi.authme.data.auth.PlayerAuth;
|
||||
import fr.xephi.authme.data.auth.PlayerCache;
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
@@ -12,6 +8,10 @@ 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;
|
||||
|
||||
/**
|
||||
* Async task for changing the email.
|
||||
@@ -68,7 +68,10 @@ public class AsyncChangeEmail implements AsynchronousProcess {
|
||||
if (dataSource.isAuthAvailable(player.getName())) {
|
||||
service.send(player, MessageKey.LOGIN_MESSAGE);
|
||||
} else {
|
||||
service.send(player, service.getProperty(RegistrationSettings.REGISTRATION_TYPE).getMessageKey());
|
||||
MessageKey registerMessage = Utils.getRegisterMessage(
|
||||
service.getProperty(RegistrationSettings.REGISTRATION_TYPE),
|
||||
service.getProperty(RegistrationSettings.REGISTER_SECOND_ARGUMENT));
|
||||
service.send(player, registerMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package fr.xephi.authme.process.register;
|
||||
|
||||
/**
|
||||
* Type of the second argument of the {@code /register} command.
|
||||
*/
|
||||
public enum RegisterSecondaryArgument {
|
||||
|
||||
/** No second argument. */
|
||||
NONE,
|
||||
|
||||
/** Confirmation of the first argument. */
|
||||
CONFIRMATION,
|
||||
|
||||
/** For password registration, mandatory secondary argument is email. */
|
||||
EMAIL_MANDATORY,
|
||||
|
||||
/** For password registration, optional secondary argument is email. */
|
||||
EMAIL_OPTIONAL
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package fr.xephi.authme.process.register;
|
||||
|
||||
/**
|
||||
* Registration type.
|
||||
*/
|
||||
public enum RegistrationType {
|
||||
|
||||
/**
|
||||
* Password registration: account is registered with a password supplied by the player.
|
||||
*/
|
||||
PASSWORD,
|
||||
|
||||
/**
|
||||
* Email registration: account is registered with an email supplied by the player. A password
|
||||
* is generated and sent to the email address.
|
||||
*/
|
||||
EMAIL
|
||||
|
||||
}
|
||||
-4
@@ -18,10 +18,6 @@ public class RegistrationExecutorProvider {
|
||||
RegistrationExecutorProvider() {
|
||||
}
|
||||
|
||||
public RegistrationExecutor getPasswordRegisterExecutor(Player player, String password) {
|
||||
return getPasswordRegisterExecutor(player, password, null);
|
||||
}
|
||||
|
||||
public RegistrationExecutor getPasswordRegisterExecutor(Player player, String password, String email) {
|
||||
return passwordRegisterExecutorProvider.new PasswordRegisterExecutor(player, password, email);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user