Skip to content

Commit

Permalink
fix: #178 mail sending lags server
Browse files Browse the repository at this point in the history
  • Loading branch information
HaHaWTH committed Jul 11, 2024
1 parent 18ce05d commit 92741da
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
24 changes: 14 additions & 10 deletions src/main/java/fr/xephi/authme/data/VerificationCodeManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
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;
Expand Down Expand Up @@ -133,17 +135,19 @@ public void codeExistOrGenerateNew(String name) {
* @param name the name of the player to generate a code for
*/
private void generateCode(String name) {
DataSourceValue<String> 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<String> 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));
}
}
}
});
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public void teleportOnLogin(final Player player, PlayerAuth auth, LimboPlayer li
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);
Expand Down

0 comments on commit 92741da

Please sign in to comment.