mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-12-20 15:47:38 +01:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
9ce680f56e
@ -64,9 +64,18 @@ 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"),
|
||||
|
@ -1,5 +1,9 @@
|
||||
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;
|
||||
@ -9,10 +13,6 @@ 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.settings.properties.RegistrationArgumentType.Execution;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
/**
|
||||
* Async task to add an email to an account.
|
||||
@ -64,10 +64,8 @@ public class AsyncAddEmail implements AsynchronousProcess {
|
||||
private void sendUnloggedMessage(Player player) {
|
||||
if (dataSource.isAuthAvailable(player.getName())) {
|
||||
service.send(player, MessageKey.LOGIN_MESSAGE);
|
||||
} else if (service.getProperty(RegistrationSettings.REGISTRATION_TYPE).getExecution() == Execution.EMAIL) {
|
||||
service.send(player, MessageKey.REGISTER_EMAIL_MESSAGE);
|
||||
} else {
|
||||
service.send(player, MessageKey.REGISTER_MESSAGE);
|
||||
service.send(player, service.getProperty(RegistrationSettings.REGISTRATION_TYPE).getMessageKey());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,9 @@
|
||||
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;
|
||||
@ -8,10 +12,6 @@ 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.settings.properties.RegistrationArgumentType.Execution;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
/**
|
||||
* Async task for changing the email.
|
||||
@ -67,10 +67,8 @@ public class AsyncChangeEmail implements AsynchronousProcess {
|
||||
private void outputUnloggedMessage(Player player) {
|
||||
if (dataSource.isAuthAvailable(player.getName())) {
|
||||
service.send(player, MessageKey.LOGIN_MESSAGE);
|
||||
} else if (service.getProperty(RegistrationSettings.REGISTRATION_TYPE).getExecution() == Execution.EMAIL) {
|
||||
service.send(player, MessageKey.REGISTER_EMAIL_MESSAGE);
|
||||
} else {
|
||||
service.send(player, MessageKey.REGISTER_MESSAGE);
|
||||
service.send(player, service.getProperty(RegistrationSettings.REGISTRATION_TYPE).getMessageKey());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,27 +1,30 @@
|
||||
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),
|
||||
PASSWORD(Execution.PASSWORD, 1, MessageKey.REGISTER_NO_REPEAT_MESSAGE),
|
||||
|
||||
/** /register [password] [password] */
|
||||
PASSWORD_WITH_CONFIRMATION(Execution.PASSWORD, 2),
|
||||
PASSWORD_WITH_CONFIRMATION(Execution.PASSWORD, 2, MessageKey.REGISTER_MESSAGE),
|
||||
|
||||
/** /register [email] */
|
||||
EMAIL(Execution.EMAIL, 1),
|
||||
EMAIL(Execution.EMAIL, 1, MessageKey.REGISTER_EMAIL_NO_REPEAT_MESSAGE),
|
||||
|
||||
/** /register [email] [email] */
|
||||
EMAIL_WITH_CONFIRMATION(Execution.EMAIL, 2),
|
||||
EMAIL_WITH_CONFIRMATION(Execution.EMAIL, 2, MessageKey.REGISTER_EMAIL_MESSAGE),
|
||||
|
||||
/** /register [password] [email] */
|
||||
PASSWORD_WITH_EMAIL(Execution.PASSWORD, 2);
|
||||
PASSWORD_WITH_EMAIL(Execution.PASSWORD, 2, MessageKey.REGISTER_PASSWORD_EMAIL_MESSAGE);
|
||||
|
||||
private final Execution execution;
|
||||
private final int requiredNumberOfArgs;
|
||||
private final MessageKey messageKey;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
@ -29,9 +32,10 @@ public enum RegistrationArgumentType {
|
||||
* @param execution the registration process
|
||||
* @param requiredNumberOfArgs the required number of arguments
|
||||
*/
|
||||
RegistrationArgumentType(Execution execution, int requiredNumberOfArgs) {
|
||||
RegistrationArgumentType(Execution execution, int requiredNumberOfArgs, MessageKey messageKey) {
|
||||
this.execution = execution;
|
||||
this.requiredNumberOfArgs = requiredNumberOfArgs;
|
||||
this.messageKey = messageKey;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -40,6 +44,10 @@ public enum RegistrationArgumentType {
|
||||
public Execution getExecution() {
|
||||
return execution;
|
||||
}
|
||||
|
||||
public MessageKey getMessageKey(){
|
||||
return messageKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return number of arguments required to process the register command
|
||||
@ -55,6 +63,5 @@ public enum RegistrationArgumentType {
|
||||
|
||||
PASSWORD,
|
||||
EMAIL
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,13 @@
|
||||
package fr.xephi.authme.task;
|
||||
|
||||
import static fr.xephi.authme.service.BukkitService.TICKS_PER_SECOND;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.data.auth.PlayerCache;
|
||||
import fr.xephi.authme.data.limbo.LimboCache;
|
||||
@ -9,15 +17,7 @@ import fr.xephi.authme.message.Messages;
|
||||
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.RegistrationArgumentType.Execution;
|
||||
import fr.xephi.authme.settings.properties.RestrictionSettings;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import static fr.xephi.authme.service.BukkitService.TICKS_PER_SECOND;
|
||||
|
||||
/**
|
||||
* Registers tasks associated with a PlayerData.
|
||||
@ -96,9 +96,7 @@ public class LimboPlayerTaskManager {
|
||||
if (isRegistered) {
|
||||
return MessageKey.LOGIN_MESSAGE;
|
||||
} else {
|
||||
return settings.getProperty(RegistrationSettings.REGISTRATION_TYPE).getExecution() == Execution.EMAIL
|
||||
? MessageKey.REGISTER_EMAIL_MESSAGE
|
||||
: MessageKey.REGISTER_MESSAGE;
|
||||
return settings.getProperty(RegistrationSettings.REGISTRATION_TYPE).getMessageKey();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,10 @@ no_perm: '&4You don''t have the permission to perform this action!'
|
||||
error: '&4An unexpected error occurred, please contact an administrator!'
|
||||
login_msg: '&cPlease, login with the command "/login <password>"'
|
||||
reg_msg: '&3Please, register to the server with the command "/register <password> <ConfirmPassword>"'
|
||||
reg_no_repeat_msg: '&3Please, register to the server with the command "/register <password>"'
|
||||
reg_email_msg: '&3Please, register to the server with the command "/register <email> <confirmEmail>"'
|
||||
reg_email_no_repeat_msg: '&3Please, register to the server with the command "/register <email>"'
|
||||
reg_psw_email_msg: '&3Please, register to the server with the command "/register <password> <email>"'
|
||||
usage_unreg: '&cUsage: /unregister <password>'
|
||||
pwd_changed: '&2Password changed successfully!'
|
||||
user_unknown: '&cThis user isn''t registered!'
|
||||
|
@ -179,7 +179,7 @@ public class AsyncAddEmailTest {
|
||||
asyncAddEmail.addEmail(player, "test@mail.com");
|
||||
|
||||
// then
|
||||
verify(service).send(player, MessageKey.REGISTER_EMAIL_MESSAGE);
|
||||
verify(service).send(player, MessageKey.REGISTER_EMAIL_NO_REPEAT_MESSAGE);
|
||||
verify(playerCache, never()).updatePlayer(any(PlayerAuth.class));
|
||||
}
|
||||
|
||||
|
@ -210,7 +210,7 @@ public class AsyncChangeEmailTest {
|
||||
// then
|
||||
verify(dataSource, never()).updateEmail(any(PlayerAuth.class));
|
||||
verify(playerCache, never()).updatePlayer(any(PlayerAuth.class));
|
||||
verify(service).send(player, MessageKey.REGISTER_MESSAGE);
|
||||
verify(service).send(player, MessageKey.REGISTER_NO_REPEAT_MESSAGE);
|
||||
}
|
||||
|
||||
private static PlayerAuth authWithMail(String email) {
|
||||
|
@ -120,7 +120,7 @@ public class LimboPlayerTaskManagerTest {
|
||||
|
||||
String name = "bobby";
|
||||
given(limboCache.getPlayerData(name)).willReturn(limboPlayer);
|
||||
given(messages.retrieve(MessageKey.REGISTER_EMAIL_MESSAGE))
|
||||
given(messages.retrieve(MessageKey.REGISTER_EMAIL_NO_REPEAT_MESSAGE))
|
||||
.willReturn(new String[]{"Please register", "Use /register"});
|
||||
|
||||
given(settings.getProperty(RegistrationSettings.MESSAGE_INTERVAL)).willReturn(8);
|
||||
@ -131,7 +131,7 @@ public class LimboPlayerTaskManagerTest {
|
||||
|
||||
// then
|
||||
verify(limboPlayer).setMessageTask(any(MessageTask.class));
|
||||
verify(messages).retrieve(MessageKey.REGISTER_EMAIL_MESSAGE);
|
||||
verify(messages).retrieve(MessageKey.REGISTER_EMAIL_NO_REPEAT_MESSAGE);
|
||||
verify(existingMessageTask).cancel();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user