Minor: Use CommonService for permission lookup

- Some changes found in a very old patch :) - drop injection of PermissionsManager in favor of CommonService
- Rename IsEqualByReflectionMatcher's method to something more specific to differentiate it better from Hamcrest's equalTo() matcher
This commit is contained in:
ljacqu
2018-02-23 23:37:24 +01:00
parent 329657bd5f
commit 8d5afa7fbc
9 changed files with 28 additions and 34 deletions
@@ -5,7 +5,6 @@ import fr.xephi.authme.data.auth.PlayerAuth;
import fr.xephi.authme.data.auth.PlayerCache;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.message.MessageKey;
import fr.xephi.authme.permission.PermissionsManager;
import fr.xephi.authme.process.AsynchronousProcess;
import fr.xephi.authme.process.register.executors.RegistrationExecutor;
import fr.xephi.authme.process.register.executors.RegistrationMethod;
@@ -35,8 +34,6 @@ public class AsyncRegister implements AsynchronousProcess {
@Inject
private CommonService service;
@Inject
private PermissionsManager permissionsManager;
@Inject
private SingletonStore<RegistrationExecutor> registrationExecutorFactory;
@Inject
private BungeeSender bungeeSender;
@@ -106,7 +103,7 @@ public class AsyncRegister implements AsynchronousProcess {
if (maxRegPerIp > 0
&& !"127.0.0.1".equalsIgnoreCase(ip)
&& !"localhost".equalsIgnoreCase(ip)
&& !permissionsManager.hasPermission(player, ALLOW_MULTIPLE_ACCOUNTS)) {
&& !service.hasPermission(player, ALLOW_MULTIPLE_ACCOUNTS)) {
List<String> otherAccounts = database.getAllAuthsByIp(ip);
if (otherAccounts.size() >= maxRegPerIp) {
service.send(player, MessageKey.MAX_REGISTER_EXCEEDED, Integer.toString(maxRegPerIp),
@@ -4,7 +4,6 @@ import fr.xephi.authme.data.auth.PlayerAuth;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.mail.EmailService;
import fr.xephi.authme.message.MessageKey;
import fr.xephi.authme.permission.PermissionsManager;
import fr.xephi.authme.process.SyncProcessManager;
import fr.xephi.authme.security.PasswordSecurity;
import fr.xephi.authme.security.crypts.HashedPassword;
@@ -25,9 +24,6 @@ import static fr.xephi.authme.settings.properties.EmailSettings.RECOVERY_PASSWOR
*/
class EmailRegisterExecutor implements RegistrationExecutor<EmailRegisterParams> {
@Inject
private PermissionsManager permissionsManager;
@Inject
private DataSource dataSource;
@@ -46,7 +42,7 @@ class EmailRegisterExecutor implements RegistrationExecutor<EmailRegisterParams>
@Override
public boolean isRegistrationAdmitted(EmailRegisterParams params) {
final int maxRegPerEmail = commonService.getProperty(EmailSettings.MAX_REG_PER_EMAIL);
if (maxRegPerEmail > 0 && !permissionsManager.hasPermission(params.getPlayer(), ALLOW_MULTIPLE_ACCOUNTS)) {
if (maxRegPerEmail > 0 && !commonService.hasPermission(params.getPlayer(), ALLOW_MULTIPLE_ACCOUNTS)) {
int otherAccounts = dataSource.countAuthsByEmail(params.getEmail());
if (otherAccounts >= maxRegPerEmail) {
commonService.send(params.getPlayer(), MessageKey.MAX_REGISTER_EXCEEDED,