diff --git a/src/main/java/fr/xephi/authme/data/VerificationCodeManager.java b/src/main/java/fr/xephi/authme/data/VerificationCodeManager.java index ad1b778d..1fc1e13b 100644 --- a/src/main/java/fr/xephi/authme/data/VerificationCodeManager.java +++ b/src/main/java/fr/xephi/authme/data/VerificationCodeManager.java @@ -22,6 +22,8 @@ import java.util.Locale; import java.util.Set; import java.util.concurrent.TimeUnit; +import static fr.xephi.authme.AuthMe.getScheduler; + public class VerificationCodeManager implements SettingsDependent, HasCleanup { 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 */ private void generateCode(String name) { - DataSourceValue emailResult = dataSource.getEmail(name); - SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy'年'MM'月'dd'日' HH:mm:ss"); - Date date = new Date(System.currentTimeMillis()); - if (emailResult.rowExists()) { - final String email = emailResult.getValue(); - if (!Utils.isEmailEmpty(email)) { - String code = RandomStringUtils.generateNum(6); // 6 digits code - verificationCodes.put(name.toLowerCase(Locale.ROOT), code); - emailService.sendVerificationMail(name, email, code, dateFormat.format(date)); + getScheduler().runTaskAsynchronously(() -> { + DataSourceValue emailResult = dataSource.getEmail(name); + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy'-'MM'-'dd'-' HH:mm:ss"); + Date date = new Date(System.currentTimeMillis()); + if (emailResult.rowExists()) { + final String email = emailResult.getValue(); + if (!Utils.isEmailEmpty(email)) { + String code = RandomStringUtils.generateNum(6); // 6 digits code + verificationCodes.put(name.toLowerCase(Locale.ROOT), code); + emailService.sendVerificationMail(name, email, code, dateFormat.format(date)); + } } - } + }); } /** diff --git a/src/main/java/fr/xephi/authme/service/TeleportationService.java b/src/main/java/fr/xephi/authme/service/TeleportationService.java index c50b0129..4693d1fd 100644 --- a/src/main/java/fr/xephi/authme/service/TeleportationService.java +++ b/src/main/java/fr/xephi/authme/service/TeleportationService.java @@ -144,7 +144,7 @@ public class TeleportationService implements Reloadable { if (settings.getProperty(RestrictionSettings.SAVE_QUIT_LOCATION)) { Location location = buildLocationFromAuth(player, auth); 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; logger.debug("Teleporting `{0}` after login, based on the player auth", player.getName()); teleportBackFromSpawn(player, location);