mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-11-30 22:23:54 +01:00
Run database check async
* reduce lag if unlogged in player spamming the chat while cache is disabled
This commit is contained in:
parent
e80c098e3d
commit
30cdf6b1e0
@ -61,7 +61,7 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
for (Player p : Utils.getOnlinePlayers()) {
|
for (Player p : Utils.getOnlinePlayers()) {
|
||||||
if (!PlayerCache.getInstance().isAuthenticated(p.getName())) {
|
if (!PlayerCache.getInstance().isAuthenticated(p.getName())) {
|
||||||
event.getRecipients().remove(p); // TODO: it should be configurable
|
event.getRecipients().remove(p); // TODO: it should be configurable
|
||||||
@ -69,6 +69,9 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
plugin.getServer().getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
if (plugin.database.isAuthAvailable(player.getName().toLowerCase())) {
|
if (plugin.database.isAuthAvailable(player.getName().toLowerCase())) {
|
||||||
m.send(player, MessageKey.LOGIN_MESSAGE);
|
m.send(player, MessageKey.LOGIN_MESSAGE);
|
||||||
} else {
|
} else {
|
||||||
@ -78,7 +81,8 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
m.send(player, MessageKey.REGISTER_MESSAGE);
|
m.send(player, MessageKey.REGISTER_MESSAGE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user