mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-12-26 18:47:37 +01:00
run task async, fix #200
This commit is contained in:
parent
5a9c6278b6
commit
90c7187bab
@ -25,8 +25,8 @@ public class ChangePasswordCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command cmnd, String label,
|
public boolean onCommand(final CommandSender sender, Command cmnd, String label,
|
||||||
String[] args) {
|
final String[] args) {
|
||||||
if (!(sender instanceof Player)) {
|
if (!(sender instanceof Player)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -36,8 +36,8 @@ public class ChangePasswordCommand implements CommandExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Player player = (Player) sender;
|
final Player player = (Player) sender;
|
||||||
String name = player.getName().toLowerCase();
|
final String name = player.getName().toLowerCase();
|
||||||
if (!PlayerCache.getInstance().isAuthenticated(name)) {
|
if (!PlayerCache.getInstance().isAuthenticated(name)) {
|
||||||
m.send(player, "not_logged_in");
|
m.send(player, "not_logged_in");
|
||||||
return true;
|
return true;
|
||||||
@ -67,30 +67,35 @@ public class ChangePasswordCommand implements CommandExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try {
|
plugin.getServer().getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||||
String hashnew = PasswordSecurity.getHash(Settings.getPasswordHash, args[1], name);
|
@Override
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
String hashnew = PasswordSecurity.getHash(Settings.getPasswordHash, args[1], name);
|
||||||
|
|
||||||
if (PasswordSecurity.comparePasswordWithHash(args[0], PlayerCache.getInstance().getAuth(name).getHash(), player.getName())) {
|
if (PasswordSecurity.comparePasswordWithHash(args[0], PlayerCache.getInstance().getAuth(name).getHash(), player.getName())) {
|
||||||
PlayerAuth auth = PlayerCache.getInstance().getAuth(name);
|
PlayerAuth auth = PlayerCache.getInstance().getAuth(name);
|
||||||
auth.setHash(hashnew);
|
auth.setHash(hashnew);
|
||||||
if (PasswordSecurity.userSalt.containsKey(name) && PasswordSecurity.userSalt.get(name) != null)
|
if (PasswordSecurity.userSalt.containsKey(name) && PasswordSecurity.userSalt.get(name) != null)
|
||||||
auth.setSalt(PasswordSecurity.userSalt.get(name));
|
auth.setSalt(PasswordSecurity.userSalt.get(name));
|
||||||
else auth.setSalt("");
|
else auth.setSalt("");
|
||||||
if (!plugin.database.updatePassword(auth)) {
|
if (!plugin.database.updatePassword(auth)) {
|
||||||
m.send(player, "error");
|
m.send(player, "error");
|
||||||
return true;
|
return;
|
||||||
|
}
|
||||||
|
plugin.database.updateSalt(auth);
|
||||||
|
PlayerCache.getInstance().updatePlayer(auth);
|
||||||
|
m.send(player, "pwd_changed");
|
||||||
|
ConsoleLogger.info(player.getName() + " changed his password");
|
||||||
|
} else {
|
||||||
|
m.send(player, "wrong_pwd");
|
||||||
|
}
|
||||||
|
} catch (NoSuchAlgorithmException ex) {
|
||||||
|
ConsoleLogger.showError(ex.getMessage());
|
||||||
|
m.send(sender, "error");
|
||||||
}
|
}
|
||||||
plugin.database.updateSalt(auth);
|
|
||||||
PlayerCache.getInstance().updatePlayer(auth);
|
|
||||||
m.send(player, "pwd_changed");
|
|
||||||
ConsoleLogger.info(player.getName() + " changed his password");
|
|
||||||
} else {
|
|
||||||
m.send(player, "wrong_pwd");
|
|
||||||
}
|
}
|
||||||
} catch (NoSuchAlgorithmException ex) {
|
});
|
||||||
ConsoleLogger.showError(ex.getMessage());
|
|
||||||
m.send(sender, "error");
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user