Merge CommandService and ProcessService to CommonService

- Replace CommandService and ProcessService with CommonService: a service that offers our typical needs to work with settings, messages and permissions
- Remove validation methods from CommonService: inject ValidationService directly. Validation methods are not used very frequently and therefore don't belong in CommonService. Their presence was a relict from our architecture before injection was used.
This commit is contained in:
ljacqu
2016-12-03 12:10:30 +01:00
parent a38d3a25b8
commit c325d0db41
55 changed files with 317 additions and 553 deletions
@@ -6,7 +6,8 @@ import fr.xephi.authme.data.auth.PlayerCache;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.message.MessageKey;
import fr.xephi.authme.process.AsynchronousProcess;
import fr.xephi.authme.process.ProcessService;
import fr.xephi.authme.service.CommonService;
import fr.xephi.authme.service.ValidationService;
import fr.xephi.authme.settings.properties.RegistrationSettings;
import org.bukkit.entity.Player;
@@ -18,7 +19,7 @@ import javax.inject.Inject;
public class AsyncAddEmail implements AsynchronousProcess {
@Inject
private ProcessService service;
private CommonService service;
@Inject
private DataSource dataSource;
@@ -26,6 +27,9 @@ public class AsyncAddEmail implements AsynchronousProcess {
@Inject
private PlayerCache playerCache;
@Inject
private ValidationService validationService;
AsyncAddEmail() { }
public void addEmail(Player player, String email) {
@@ -37,9 +41,9 @@ public class AsyncAddEmail implements AsynchronousProcess {
if (currentEmail != null && !"your@email.com".equals(currentEmail)) {
service.send(player, MessageKey.USAGE_CHANGE_EMAIL);
} else if (!service.validateEmail(email)) {
} else if (!validationService.validateEmail(email)) {
service.send(player, MessageKey.INVALID_EMAIL);
} else if (!service.isEmailFreeForRegistration(email, player)) {
} else if (!validationService.isEmailFreeForRegistration(email, player)) {
service.send(player, MessageKey.EMAIL_ALREADY_USED_ERROR);
} else {
auth.setEmail(email);