fix: #178 mail sending lags server
This commit is contained in:
parent
18ce05d07d
commit
92741daaa8
@ -22,6 +22,8 @@ import java.util.Locale;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import static fr.xephi.authme.AuthMe.getScheduler;
|
||||||
|
|
||||||
public class VerificationCodeManager implements SettingsDependent, HasCleanup {
|
public class VerificationCodeManager implements SettingsDependent, HasCleanup {
|
||||||
|
|
||||||
private final EmailService emailService;
|
private final EmailService emailService;
|
||||||
@ -133,17 +135,19 @@ public class VerificationCodeManager implements SettingsDependent, HasCleanup {
|
|||||||
* @param name the name of the player to generate a code for
|
* @param name the name of the player to generate a code for
|
||||||
*/
|
*/
|
||||||
private void generateCode(String name) {
|
private void generateCode(String name) {
|
||||||
DataSourceValue<String> emailResult = dataSource.getEmail(name);
|
getScheduler().runTaskAsynchronously(() -> {
|
||||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy'年'MM'月'dd'日' HH:mm:ss");
|
DataSourceValue<String> emailResult = dataSource.getEmail(name);
|
||||||
Date date = new Date(System.currentTimeMillis());
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy'-'MM'-'dd'-' HH:mm:ss");
|
||||||
if (emailResult.rowExists()) {
|
Date date = new Date(System.currentTimeMillis());
|
||||||
final String email = emailResult.getValue();
|
if (emailResult.rowExists()) {
|
||||||
if (!Utils.isEmailEmpty(email)) {
|
final String email = emailResult.getValue();
|
||||||
String code = RandomStringUtils.generateNum(6); // 6 digits code
|
if (!Utils.isEmailEmpty(email)) {
|
||||||
verificationCodes.put(name.toLowerCase(Locale.ROOT), code);
|
String code = RandomStringUtils.generateNum(6); // 6 digits code
|
||||||
emailService.sendVerificationMail(name, email, code, dateFormat.format(date));
|
verificationCodes.put(name.toLowerCase(Locale.ROOT), code);
|
||||||
|
emailService.sendVerificationMail(name, email, code, dateFormat.format(date));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -144,7 +144,7 @@ public class TeleportationService implements Reloadable {
|
|||||||
if (settings.getProperty(RestrictionSettings.SAVE_QUIT_LOCATION)) {
|
if (settings.getProperty(RestrictionSettings.SAVE_QUIT_LOCATION)) {
|
||||||
Location location = buildLocationFromAuth(player, auth);
|
Location location = buildLocationFromAuth(player, auth);
|
||||||
Location playerLoc = player.getLocation();
|
Location playerLoc = player.getLocation();
|
||||||
if (location.getX() == playerLoc.getX() && location.getY() == location.getY() && location.getZ() == playerLoc.getZ()
|
if (location.getX() == playerLoc.getX() && location.getY() == playerLoc.getY() && location.getZ() == playerLoc.getZ()
|
||||||
&& location.getWorld() == playerLoc.getWorld()) return;
|
&& location.getWorld() == playerLoc.getWorld()) return;
|
||||||
logger.debug("Teleporting `{0}` after login, based on the player auth", player.getName());
|
logger.debug("Teleporting `{0}` after login, based on the player auth", player.getName());
|
||||||
teleportBackFromSpawn(player, location);
|
teleportBackFromSpawn(player, location);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user