Various code householding
- Adjust javadoc - Remove unused PlayerAuth constructor - Replace legacy Settings with NewSetting calls - Add process service to all (a)sync processes - Change IP manager to only cache the calls to the VeryGames API
This commit is contained in:
@@ -11,7 +11,6 @@ import fr.xephi.authme.process.logout.AsynchronousLogout;
|
||||
import fr.xephi.authme.process.quit.AsynchronousQuit;
|
||||
import fr.xephi.authme.process.register.AsyncRegister;
|
||||
import fr.xephi.authme.process.unregister.AsynchronousUnregister;
|
||||
import fr.xephi.authme.settings.NewSetting;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
|
||||
@@ -24,22 +23,13 @@ public class Management {
|
||||
private final ProcessService processService;
|
||||
private final DataSource dataSource;
|
||||
private final PlayerCache playerCache;
|
||||
private final NewSetting settings;
|
||||
|
||||
/**
|
||||
* Constructor for Management.
|
||||
*
|
||||
* @param plugin AuthMe
|
||||
*/
|
||||
public Management(AuthMe plugin, ProcessService processService, DataSource dataSource, PlayerCache playerCache) {
|
||||
this.plugin = plugin;
|
||||
this.sched = this.plugin.getServer().getScheduler();
|
||||
this.processService = processService;
|
||||
this.dataSource = dataSource;
|
||||
this.playerCache = playerCache;
|
||||
|
||||
// FIXME don't pass settings anymore -> go through the service in the processes
|
||||
this.settings = processService.getSettings();
|
||||
}
|
||||
|
||||
public void performLogin(final Player player, final String password, final boolean forceLogin) {
|
||||
@@ -47,13 +37,7 @@ public class Management {
|
||||
}
|
||||
|
||||
public void performLogout(final Player player) {
|
||||
sched.runTaskAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
new AsynchronousLogout(player, plugin, plugin.getDataSource()).process();
|
||||
}
|
||||
});
|
||||
runTask(new AsynchronousLogout(player, plugin, dataSource, processService));
|
||||
}
|
||||
|
||||
public void performRegister(final Player player, final String password, final String email) {
|
||||
@@ -77,7 +61,7 @@ public class Management {
|
||||
}
|
||||
|
||||
public void performChangeEmail(final Player player, final String oldEmail, final String newEmail) {
|
||||
runTask(new AsyncChangeEmail(player, plugin, oldEmail, newEmail, dataSource, playerCache, settings));
|
||||
runTask(new AsyncChangeEmail(player, oldEmail, newEmail, dataSource, playerCache, processService));
|
||||
}
|
||||
|
||||
private void runTask(Process process) {
|
||||
|
||||
@@ -4,6 +4,8 @@ import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.cache.IpAddressManager;
|
||||
import fr.xephi.authme.output.MessageKey;
|
||||
import fr.xephi.authme.output.Messages;
|
||||
import fr.xephi.authme.security.PasswordSecurity;
|
||||
import fr.xephi.authme.security.crypts.HashedPassword;
|
||||
import fr.xephi.authme.settings.NewSetting;
|
||||
import fr.xephi.authme.settings.domain.Property;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -19,12 +21,15 @@ public class ProcessService {
|
||||
private final Messages messages;
|
||||
private final AuthMe authMe;
|
||||
private final IpAddressManager ipAddressManager;
|
||||
private final PasswordSecurity passwordSecurity;
|
||||
|
||||
public ProcessService(NewSetting settings, Messages messages, AuthMe authMe, IpAddressManager ipAddressManager) {
|
||||
public ProcessService(NewSetting settings, Messages messages, AuthMe authMe, IpAddressManager ipAddressManager,
|
||||
PasswordSecurity passwordSecurity) {
|
||||
this.settings = settings;
|
||||
this.messages = messages;
|
||||
this.authMe = authMe;
|
||||
this.ipAddressManager = ipAddressManager;
|
||||
this.passwordSecurity = passwordSecurity;
|
||||
}
|
||||
|
||||
public <T> T getProperty(Property<T> property) {
|
||||
@@ -75,4 +80,8 @@ public class ProcessService {
|
||||
return ipAddressManager;
|
||||
}
|
||||
|
||||
public HashedPassword computeHash(String password, String username) {
|
||||
return passwordSecurity.computeHash(password, username);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
package fr.xephi.authme.process.email;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
import fr.xephi.authme.output.MessageKey;
|
||||
import fr.xephi.authme.output.Messages;
|
||||
import fr.xephi.authme.process.Process;
|
||||
import fr.xephi.authme.settings.NewSetting;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
import fr.xephi.authme.process.ProcessService;
|
||||
import fr.xephi.authme.settings.properties.RegistrationSettings;
|
||||
import fr.xephi.authme.util.Utils;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@@ -20,20 +18,18 @@ public class AsyncChangeEmail implements Process {
|
||||
private final Player player;
|
||||
private final String oldEmail;
|
||||
private final String newEmail;
|
||||
private final Messages m;
|
||||
private final NewSetting settings;
|
||||
private final ProcessService service;
|
||||
private final PlayerCache playerCache;
|
||||
private final DataSource dataSource;
|
||||
|
||||
public AsyncChangeEmail(Player player, AuthMe plugin, String oldEmail, String newEmail, DataSource dataSource,
|
||||
PlayerCache playerCache, NewSetting settings) {
|
||||
this.m = plugin.getMessages();
|
||||
public AsyncChangeEmail(Player player, String oldEmail, String newEmail, DataSource dataSource,
|
||||
PlayerCache playerCache, ProcessService service) {
|
||||
this.player = player;
|
||||
this.oldEmail = oldEmail;
|
||||
this.newEmail = newEmail;
|
||||
this.playerCache = playerCache;
|
||||
this.dataSource = dataSource;
|
||||
this.settings = settings;
|
||||
this.service = service;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -44,13 +40,13 @@ public class AsyncChangeEmail implements Process {
|
||||
final String currentEmail = auth.getEmail();
|
||||
|
||||
if (currentEmail == null) {
|
||||
m.send(player, MessageKey.USAGE_ADD_EMAIL);
|
||||
} else if (newEmail == null || !Utils.isEmailCorrect(newEmail, settings)) {
|
||||
m.send(player, MessageKey.INVALID_NEW_EMAIL);
|
||||
service.send(player, MessageKey.USAGE_ADD_EMAIL);
|
||||
} else if (newEmail == null || !Utils.isEmailCorrect(newEmail, service.getSettings())) {
|
||||
service.send(player, MessageKey.INVALID_NEW_EMAIL);
|
||||
} else if (!oldEmail.equals(currentEmail)) {
|
||||
m.send(player, MessageKey.INVALID_OLD_EMAIL);
|
||||
service.send(player, MessageKey.INVALID_OLD_EMAIL);
|
||||
} else if (dataSource.isEmailStored(newEmail)) {
|
||||
m.send(player, MessageKey.EMAIL_ALREADY_USED_ERROR);
|
||||
service.send(player, MessageKey.EMAIL_ALREADY_USED_ERROR);
|
||||
} else {
|
||||
saveNewEmail(auth);
|
||||
}
|
||||
@@ -63,20 +59,20 @@ public class AsyncChangeEmail implements Process {
|
||||
auth.setEmail(newEmail);
|
||||
if (dataSource.updateEmail(auth)) {
|
||||
playerCache.updatePlayer(auth);
|
||||
m.send(player, MessageKey.EMAIL_CHANGED_SUCCESS);
|
||||
service.send(player, MessageKey.EMAIL_CHANGED_SUCCESS);
|
||||
} else {
|
||||
m.send(player, MessageKey.ERROR);
|
||||
service.send(player, MessageKey.ERROR);
|
||||
auth.setEmail(newEmail);
|
||||
}
|
||||
}
|
||||
|
||||
private void outputUnloggedMessage() {
|
||||
if (dataSource.isAuthAvailable(player.getName())) {
|
||||
m.send(player, MessageKey.LOGIN_MESSAGE);
|
||||
} else if (Settings.emailRegistration) {
|
||||
m.send(player, MessageKey.REGISTER_EMAIL_MESSAGE);
|
||||
service.send(player, MessageKey.LOGIN_MESSAGE);
|
||||
} else if (service.getProperty(RegistrationSettings.USE_EMAIL_REGISTRATION)) {
|
||||
service.send(player, MessageKey.REGISTER_EMAIL_MESSAGE);
|
||||
} else {
|
||||
m.send(player, MessageKey.REGISTER_MESSAGE);
|
||||
service.send(player, MessageKey.REGISTER_MESSAGE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ import fr.xephi.authme.process.Process;
|
||||
import fr.xephi.authme.process.ProcessService;
|
||||
import fr.xephi.authme.security.RandomString;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
import fr.xephi.authme.settings.properties.DatabaseSettings;
|
||||
import fr.xephi.authme.settings.properties.RegistrationSettings;
|
||||
import fr.xephi.authme.settings.properties.SecuritySettings;
|
||||
import fr.xephi.authme.task.MessageTask;
|
||||
@@ -98,7 +99,7 @@ public class AsynchronousLogin implements Process {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!Settings.getMySQLColumnGroup.isEmpty() && pAuth.getGroupId() == Settings.getNonActivatedGroup) {
|
||||
if (!service.getProperty(DatabaseSettings.MYSQL_COL_GROUP).isEmpty() && pAuth.getGroupId() == Settings.getNonActivatedGroup) {
|
||||
service.send(player, MessageKey.ACCOUNT_NOT_ACTIVATED);
|
||||
return null;
|
||||
}
|
||||
@@ -146,7 +147,7 @@ public class AsynchronousLogin implements Process {
|
||||
.build();
|
||||
database.updateSession(auth);
|
||||
|
||||
if (Settings.useCaptcha) {
|
||||
if (service.getProperty(SecuritySettings.USE_CAPTCHA)) {
|
||||
if (plugin.captcha.containsKey(name)) {
|
||||
plugin.captcha.remove(name);
|
||||
}
|
||||
|
||||
@@ -6,22 +6,22 @@ import fr.xephi.authme.cache.auth.PlayerCache;
|
||||
import fr.xephi.authme.cache.limbo.LimboCache;
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
import fr.xephi.authme.output.MessageKey;
|
||||
import fr.xephi.authme.output.Messages;
|
||||
import fr.xephi.authme.process.Process;
|
||||
import fr.xephi.authme.process.ProcessService;
|
||||
import fr.xephi.authme.util.Utils;
|
||||
import fr.xephi.authme.util.Utils.GroupType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class AsynchronousLogout {
|
||||
public class AsynchronousLogout implements Process {
|
||||
|
||||
protected final Player player;
|
||||
protected final String name;
|
||||
protected final AuthMe plugin;
|
||||
protected final DataSource database;
|
||||
protected boolean canLogout = true;
|
||||
private final Messages m;
|
||||
private final Player player;
|
||||
private final String name;
|
||||
private final AuthMe plugin;
|
||||
private final DataSource database;
|
||||
private boolean canLogout = true;
|
||||
private final ProcessService service;
|
||||
|
||||
/**
|
||||
* Constructor for AsynchronousLogout.
|
||||
@@ -29,29 +29,30 @@ public class AsynchronousLogout {
|
||||
* @param player Player
|
||||
* @param plugin AuthMe
|
||||
* @param database DataSource
|
||||
* @param service The process service
|
||||
*/
|
||||
public AsynchronousLogout(Player player, AuthMe plugin, DataSource database) {
|
||||
this.m = plugin.getMessages();
|
||||
public AsynchronousLogout(Player player, AuthMe plugin, DataSource database, ProcessService service) {
|
||||
this.player = player;
|
||||
this.plugin = plugin;
|
||||
this.database = database;
|
||||
this.name = player.getName().toLowerCase();
|
||||
this.service = service;
|
||||
}
|
||||
|
||||
private void preLogout() {
|
||||
if (!PlayerCache.getInstance().isAuthenticated(name)) {
|
||||
m.send(player, MessageKey.NOT_LOGGED_IN);
|
||||
service.send(player, MessageKey.NOT_LOGGED_IN);
|
||||
canLogout = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void process() {
|
||||
@Override
|
||||
public void run() {
|
||||
preLogout();
|
||||
if (!canLogout) {
|
||||
return;
|
||||
}
|
||||
final Player p = player;
|
||||
BukkitScheduler scheduler = p.getServer().getScheduler();
|
||||
PlayerAuth auth = PlayerCache.getInstance().getAuth(name);
|
||||
database.updateSession(auth);
|
||||
auth.setQuitLocX(p.getLocation().getX());
|
||||
@@ -62,7 +63,7 @@ public class AsynchronousLogout {
|
||||
|
||||
PlayerCache.getInstance().removePlayer(name);
|
||||
database.setUnlogged(name);
|
||||
scheduler.scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
service.scheduleSyncDelayedTask(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Utils.teleportToSpawn(p);
|
||||
@@ -73,6 +74,6 @@ public class AsynchronousLogout {
|
||||
}
|
||||
LimboCache.getInstance().addLimboPlayer(player);
|
||||
Utils.setGroup(player, GroupType.NOTLOGGEDIN);
|
||||
scheduler.scheduleSyncDelayedTask(plugin, new ProcessSyncronousPlayerLogout(p, plugin));
|
||||
service.scheduleSyncDelayedTask(new ProcessSynchronousPlayerLogout(p, plugin, service));
|
||||
}
|
||||
}
|
||||
|
||||
+19
-22
@@ -7,37 +7,40 @@ import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.cache.limbo.LimboCache;
|
||||
import fr.xephi.authme.events.LogoutEvent;
|
||||
import fr.xephi.authme.output.MessageKey;
|
||||
import fr.xephi.authme.output.Messages;
|
||||
import fr.xephi.authme.process.Process;
|
||||
import fr.xephi.authme.process.ProcessService;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
import fr.xephi.authme.settings.properties.RegistrationSettings;
|
||||
import fr.xephi.authme.settings.properties.RestrictionSettings;
|
||||
import fr.xephi.authme.task.MessageTask;
|
||||
import fr.xephi.authme.task.TimeoutTask;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class ProcessSyncronousPlayerLogout implements Runnable {
|
||||
public class ProcessSynchronousPlayerLogout implements Process {
|
||||
|
||||
protected final Player player;
|
||||
protected final AuthMe plugin;
|
||||
protected final String name;
|
||||
private final Messages m;
|
||||
private final Player player;
|
||||
private final AuthMe plugin;
|
||||
private final String name;
|
||||
private final ProcessService service;
|
||||
|
||||
/**
|
||||
* Constructor for ProcessSyncronousPlayerLogout.
|
||||
* Constructor for ProcessSynchronousPlayerLogout.
|
||||
*
|
||||
* @param player Player
|
||||
* @param plugin AuthMe
|
||||
* @param service The process service
|
||||
*/
|
||||
public ProcessSyncronousPlayerLogout(Player player, AuthMe plugin) {
|
||||
this.m = plugin.getMessages();
|
||||
public ProcessSynchronousPlayerLogout(Player player, AuthMe plugin, ProcessService service) {
|
||||
this.player = player;
|
||||
this.plugin = plugin;
|
||||
this.name = player.getName().toLowerCase();
|
||||
this.service = service;
|
||||
}
|
||||
|
||||
protected void sendBungeeMessage() {
|
||||
@@ -56,11 +59,6 @@ public class ProcessSyncronousPlayerLogout implements Runnable {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method run.
|
||||
*
|
||||
* @see java.lang.Runnable#run()
|
||||
*/
|
||||
@Override
|
||||
public void run() {
|
||||
if (plugin.sessions.containsKey(name)) {
|
||||
@@ -70,19 +68,18 @@ public class ProcessSyncronousPlayerLogout implements Runnable {
|
||||
if (Settings.protectInventoryBeforeLogInEnabled) {
|
||||
plugin.inventoryProtector.sendBlankInventoryPacket(player);
|
||||
}
|
||||
int timeOut = Settings.getRegistrationTimeout * 20;
|
||||
int interval = Settings.getWarnMessageInterval;
|
||||
BukkitScheduler sched = player.getServer().getScheduler();
|
||||
int timeOut = service.getProperty(RestrictionSettings.TIMEOUT) * 20;
|
||||
int interval = service.getProperty(RegistrationSettings.MESSAGE_INTERVAL);
|
||||
if (timeOut != 0) {
|
||||
BukkitTask id = sched.runTaskLater(plugin, new TimeoutTask(plugin, name, player), timeOut);
|
||||
BukkitTask id = service.runTaskLater(new TimeoutTask(plugin, name, player), timeOut);
|
||||
LimboCache.getInstance().getLimboPlayer(name).setTimeoutTaskId(id);
|
||||
}
|
||||
BukkitTask msgT = sched.runTask(plugin, new MessageTask(plugin, name, MessageKey.LOGIN_MESSAGE, interval));
|
||||
BukkitTask msgT = service.runTask(new MessageTask(plugin, name, MessageKey.LOGIN_MESSAGE, interval));
|
||||
LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(msgT);
|
||||
if (player.isInsideVehicle() && player.getVehicle() != null) {
|
||||
player.getVehicle().eject();
|
||||
}
|
||||
if (Settings.applyBlindEffect) {
|
||||
if (service.getProperty(RegistrationSettings.APPLY_BLIND_EFFECT)) {
|
||||
player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, timeOut, 2));
|
||||
}
|
||||
player.setOp(false);
|
||||
@@ -92,7 +89,7 @@ public class ProcessSyncronousPlayerLogout implements Runnable {
|
||||
if (Settings.bungee) {
|
||||
sendBungeeMessage();
|
||||
}
|
||||
m.send(player, MessageKey.LOGOUT_SUCCESS);
|
||||
service.send(player, MessageKey.LOGOUT_SUCCESS);
|
||||
ConsoleLogger.info(player.getName() + " logged out");
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@ import fr.xephi.authme.settings.Settings;
|
||||
import fr.xephi.authme.settings.properties.RestrictionSettings;
|
||||
import fr.xephi.authme.util.StringUtils;
|
||||
import fr.xephi.authme.util.Utils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
@@ -54,7 +53,12 @@ public class AsynchronousQuit implements Process {
|
||||
.realName(player.getName()).build();
|
||||
database.updateQuitLoc(auth);
|
||||
}
|
||||
PlayerAuth auth = new PlayerAuth(name, ip, System.currentTimeMillis(), player.getName());
|
||||
PlayerAuth auth = PlayerAuth.builder()
|
||||
.name(name)
|
||||
.realName(player.getName())
|
||||
.ip(ip)
|
||||
.lastLogin(System.currentTimeMillis())
|
||||
.build();
|
||||
database.updateSession(auth);
|
||||
}
|
||||
|
||||
@@ -92,7 +96,7 @@ public class AsynchronousQuit implements Process {
|
||||
|
||||
service.getIpAddressManager().removeCache(player.getName());
|
||||
if (plugin.isEnabled()) {
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new ProcessSyncronousPlayerQuit(plugin, player, isOp, needToChange));
|
||||
service.scheduleSyncDelayedTask(new ProcessSyncronousPlayerQuit(plugin, player, isOp, needToChange));
|
||||
}
|
||||
// remove player from cache
|
||||
if (database instanceof CacheDataSource) {
|
||||
|
||||
@@ -1,10 +1,5 @@
|
||||
package fr.xephi.authme.process.register;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||
@@ -22,6 +17,8 @@ import fr.xephi.authme.util.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class AsyncRegister implements Process {
|
||||
@@ -82,10 +79,11 @@ public class AsyncRegister implements Process {
|
||||
&& !ip.equalsIgnoreCase("127.0.0.1")
|
||||
&& !ip.equalsIgnoreCase("localhost")
|
||||
&& !plugin.getPermissionsManager().hasPermission(player, PlayerStatePermission.ALLOW_MULTIPLE_ACCOUNTS)) {
|
||||
Integer maxReg = Settings.getmaxRegPerIp;
|
||||
int maxReg = Settings.getmaxRegPerIp;
|
||||
List<String> otherAccounts = database.getAllAuthsByIp(ip);
|
||||
if (otherAccounts.size() >= maxReg) {
|
||||
m.send(player, MessageKey.MAX_REGISTER_EXCEEDED, maxReg.toString(), Integer.toString(otherAccounts.size()), otherAccounts.toString());
|
||||
service.send(player, MessageKey.MAX_REGISTER_EXCEEDED, Integer.toString(maxReg),
|
||||
Integer.toString(otherAccounts.size()), StringUtils.join(", ", otherAccounts.toString()));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -104,18 +102,19 @@ public class AsyncRegister implements Process {
|
||||
}
|
||||
|
||||
private void emailRegister() {
|
||||
if(Settings.getmaxRegPerEmail > 0
|
||||
if (Settings.getmaxRegPerEmail > 0
|
||||
&& !ip.equalsIgnoreCase("127.0.0.1")
|
||||
&& !ip.equalsIgnoreCase("localhost")
|
||||
&& !plugin.getPermissionsManager().hasPermission(player, PlayerStatePermission.ALLOW_MULTIPLE_ACCOUNTS)) {
|
||||
Integer maxReg = Settings.getmaxRegPerIp;
|
||||
int maxReg = Settings.getmaxRegPerIp;
|
||||
List<String> otherAccounts = database.getAllAuthsByIp(ip);
|
||||
if (otherAccounts.size() >= maxReg) {
|
||||
m.send(player, MessageKey.MAX_REGISTER_EXCEEDED, maxReg.toString(), Integer.toString(otherAccounts.size()), otherAccounts.toString());
|
||||
service.send(player, MessageKey.MAX_REGISTER_EXCEEDED, Integer.toString(maxReg),
|
||||
Integer.toString(otherAccounts.size()), StringUtils.join(", ", otherAccounts.toString()));
|
||||
return;
|
||||
}
|
||||
}
|
||||
final HashedPassword hashedPassword = plugin.getPasswordSecurity().computeHash(password, name);
|
||||
final HashedPassword hashedPassword = service.computeHash(password, name);
|
||||
PlayerAuth auth = PlayerAuth.builder()
|
||||
.name(name)
|
||||
.realName(player.getName())
|
||||
@@ -133,12 +132,12 @@ public class AsyncRegister implements Process {
|
||||
database.updateSession(auth);
|
||||
plugin.mail.main(auth, password);
|
||||
ProcessSyncEmailRegister sync = new ProcessSyncEmailRegister(player, service);
|
||||
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, sync);
|
||||
service.scheduleSyncDelayedTask(sync);
|
||||
|
||||
}
|
||||
|
||||
private void passwordRegister() {
|
||||
final HashedPassword hashedPassword = plugin.getPasswordSecurity().computeHash(password, name);
|
||||
final HashedPassword hashedPassword = service.computeHash(password, name);
|
||||
PlayerAuth auth = PlayerAuth.builder()
|
||||
.name(name)
|
||||
.realName(player.getName())
|
||||
@@ -163,7 +162,7 @@ public class AsyncRegister implements Process {
|
||||
service.scheduleSyncDelayedTask(sync);
|
||||
|
||||
//give the user the secret code to setup their app code generation
|
||||
if (Settings.getPasswordHash == HashAlgorithm.TWO_FACTOR) {
|
||||
if (service.getProperty(SecuritySettings.PASSWORD_HASH) == HashAlgorithm.TWO_FACTOR) {
|
||||
String qrCodeUrl = TwoFactor.getQRBarcodeURL(player.getName(), Bukkit.getIp(), hashedPassword.getHash());
|
||||
service.send(player, MessageKey.TWO_FACTOR_CREATE, hashedPassword.getHash(), qrCodeUrl);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.cache.limbo.LimboCache;
|
||||
import fr.xephi.authme.cache.limbo.LimboPlayer;
|
||||
import fr.xephi.authme.output.MessageKey;
|
||||
import fr.xephi.authme.process.Process;
|
||||
import fr.xephi.authme.process.ProcessService;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
import fr.xephi.authme.settings.properties.RegistrationSettings;
|
||||
@@ -17,10 +18,10 @@ import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class ProcessSyncEmailRegister implements Runnable {
|
||||
public class ProcessSyncEmailRegister implements Process {
|
||||
|
||||
protected final Player player;
|
||||
protected final String name;
|
||||
private final Player player;
|
||||
private final String name;
|
||||
private final ProcessService service;
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user