mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2025-01-04 23:07:44 +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(
|
@EventHandler(
|
||||||
priority = EventPriority.NORMAL)
|
priority = EventPriority.NORMAL)
|
||||||
public void onPlayerLogin(final PlayerLoginEvent event) {
|
public void onPlayerLogin(final PlayerLoginEvent event) {
|
||||||
/*
|
|
||||||
* ____ _ _ _
|
|
||||||
* | _ \| | __ _ _ _ ___ _ __ | | ___ (_)_ __
|
|
||||||
* | |_) | |/ _` | | | |/ _ \ '__| _ | |/ _ \| | '_ \
|
|
||||||
* | __/| | (_| | |_| | __/ | | |_| | (_) | | | | |
|
|
||||||
* |_| |_|\__,_|\__, |\___|_| \___/ \___/|_|_| |_|
|
|
||||||
* |___/
|
|
||||||
*/
|
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
final ChatConfig cc = ChatConfig.getConfig(player);
|
final ChatConfig cc = ChatConfig.getConfig(player);
|
||||||
|
final ChatData data = ChatData.getData(player);
|
||||||
|
|
||||||
// Tell TickTask to update cached permissions.
|
// Tell TickTask to update cached permissions.
|
||||||
TickTask.requestPermissionUpdate(player.getName(), CheckType.CHAT);
|
TickTask.requestPermissionUpdate(player.getName(), CheckType.CHAT);
|
||||||
@ -219,11 +213,15 @@ public class ChatListener implements Listener, INotifyReload {
|
|||||||
TickTask.updatePermissions();
|
TickTask.updatePermissions();
|
||||||
|
|
||||||
// Reset captcha of player if needed.
|
// 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(
|
@EventHandler(
|
||||||
@ -232,11 +230,13 @@ public class ChatListener implements Listener, INotifyReload {
|
|||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
final ChatConfig cc = ChatConfig.getConfig(player);
|
final ChatConfig cc = ChatConfig.getConfig(player);
|
||||||
final ChatData data = ChatData.getData(player);
|
final ChatData data = ChatData.getData(player);
|
||||||
if (captcha.isEnabled(player) && captcha.shouldCheckCaptcha(cc, data)){
|
synchronized (data) {
|
||||||
// shouldCheckCaptcha: only if really enabled.
|
if (captcha.isEnabled(player) && captcha.shouldCheckCaptcha(cc, data)){
|
||||||
// Later: add check for cc.captchaOnLogin or so.
|
// shouldCheckCaptcha: only if really enabled.
|
||||||
// TODO: maybe schedule this to coma after other plugins messages.
|
// TODO: Later: add check for cc.captchaOnLogin or so (before shouldCheckCaptcha).
|
||||||
captcha.sendNewCaptcha(player, cc, data);
|
// 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);
|
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.
|
* Check (Join), only call from synchronized code.
|
||||||
*
|
*
|
||||||
@ -47,7 +24,7 @@ public class Relog extends Check {
|
|||||||
* the data
|
* the data
|
||||||
* @return true, if successful
|
* @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;
|
boolean cancel = false;
|
||||||
|
|
||||||
final long now = System.currentTimeMillis();
|
final long now = System.currentTimeMillis();
|
||||||
|
Loading…
Reference in New Issue
Block a user