mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2025-01-02 13:57:49 +01:00
Adjust Synchronization with captcha.
This commit is contained in:
parent
1e423b85d4
commit
74b3c1c84f
@ -202,16 +202,10 @@ public class ChatListener implements Listener, INotifyReload {
|
||||
@EventHandler(
|
||||
priority = EventPriority.NORMAL)
|
||||
public void onPlayerLogin(final PlayerLoginEvent event) {
|
||||
/*
|
||||
* ____ _ _ _
|
||||
* | _ \| | __ _ _ _ ___ _ __ | | ___ (_)_ __
|
||||
* | |_) | |/ _` | | | |/ _ \ '__| _ | |/ _ \| | '_ \
|
||||
* | __/| | (_| | |_| | __/ | | |_| | (_) | | | | |
|
||||
* |_| |_|\__,_|\__, |\___|_| \___/ \___/|_|_| |_|
|
||||
* |___/
|
||||
*/
|
||||
|
||||
final Player player = event.getPlayer();
|
||||
final ChatConfig cc = ChatConfig.getConfig(player);
|
||||
final ChatData data = ChatData.getData(player);
|
||||
|
||||
// Tell TickTask to update cached permissions.
|
||||
TickTask.requestPermissionUpdate(player.getName(), CheckType.CHAT);
|
||||
@ -219,11 +213,15 @@ public class ChatListener implements Listener, INotifyReload {
|
||||
TickTask.updatePermissions();
|
||||
|
||||
// Reset captcha of player if needed.
|
||||
captcha.resetCaptcha(player);
|
||||
synchronized(data){
|
||||
captcha.resetCaptcha(cc, data);
|
||||
// Execute the no pwnage check.
|
||||
if (relog.isEnabled(player) && relog.unsafeLoginCheck(player, cc, data))
|
||||
event.disallow(Result.KICK_OTHER, cc.relogKickMessage);
|
||||
|
||||
// TODO: Logins check.
|
||||
}
|
||||
|
||||
// Execute the no pwnage check.
|
||||
if (relog.isEnabled(player) && relog.checkLogin(player))
|
||||
event.disallow(Result.KICK_OTHER, cc.relogKickMessage);
|
||||
}
|
||||
|
||||
@EventHandler(
|
||||
@ -232,11 +230,13 @@ public class ChatListener implements Listener, INotifyReload {
|
||||
final Player player = event.getPlayer();
|
||||
final ChatConfig cc = ChatConfig.getConfig(player);
|
||||
final ChatData data = ChatData.getData(player);
|
||||
if (captcha.isEnabled(player) && captcha.shouldCheckCaptcha(cc, data)){
|
||||
// shouldCheckCaptcha: only if really enabled.
|
||||
// Later: add check for cc.captchaOnLogin or so.
|
||||
// TODO: maybe schedule this to coma after other plugins messages.
|
||||
captcha.sendNewCaptcha(player, cc, data);
|
||||
synchronized (data) {
|
||||
if (captcha.isEnabled(player) && captcha.shouldCheckCaptcha(cc, data)){
|
||||
// shouldCheckCaptcha: only if really enabled.
|
||||
// TODO: Later: add check for cc.captchaOnLogin or so (before shouldCheckCaptcha).
|
||||
// TODO: maybe schedule this to come after other plugins messages.
|
||||
captcha.sendNewCaptcha(player, cc, data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -13,29 +13,6 @@ public class Relog extends Check {
|
||||
super(CheckType.CHAT_RELOG);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks a player (join).
|
||||
*
|
||||
* Only called from the main thread.
|
||||
*
|
||||
* @param player
|
||||
* the player
|
||||
* @return true, if successful
|
||||
*/
|
||||
public boolean checkLogin(final Player player) {
|
||||
if (!isEnabled(player))
|
||||
return false;
|
||||
|
||||
final ChatConfig cc = ChatConfig.getConfig(player);
|
||||
final ChatData data = ChatData.getData(player);
|
||||
|
||||
// Keep related to ChatData/NoPwnage/Color used lock.
|
||||
synchronized (data) {
|
||||
return unsafeLoginCheck(player, cc, data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check (Join), only call from synchronized code.
|
||||
*
|
||||
@ -47,7 +24,7 @@ public class Relog extends Check {
|
||||
* the data
|
||||
* @return true, if successful
|
||||
*/
|
||||
private boolean unsafeLoginCheck(final Player player, final ChatConfig cc, final ChatData data) {
|
||||
public boolean unsafeLoginCheck(final Player player, final ChatConfig cc, final ChatData data) {
|
||||
boolean cancel = false;
|
||||
|
||||
final long now = System.currentTimeMillis();
|
||||
|
Loading…
Reference in New Issue
Block a user