mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2025-01-07 00:08:20 +01:00
Integrate captcha into commands check.
This commit is contained in:
parent
8b92bd74dc
commit
af8623ee81
@ -24,6 +24,18 @@ public class Commands extends Check {
|
|||||||
final ChatConfig cc = ChatConfig.getConfig(player);
|
final ChatConfig cc = ChatConfig.getConfig(player);
|
||||||
final ChatData data = ChatData.getData(player);
|
final ChatData data = ChatData.getData(player);
|
||||||
|
|
||||||
|
final boolean captchaEnabled = captcha.isEnabled(player);
|
||||||
|
if (captchaEnabled){
|
||||||
|
synchronized (data) {
|
||||||
|
if (captcha.shouldCheckCaptcha(cc, data)){
|
||||||
|
captcha.checkCaptcha(player, message, cc, data, true);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Rest of the check is done without sync, because the data is only used by this check.
|
||||||
|
|
||||||
// Weight might later be read from some prefix tree (also known / unknown).
|
// Weight might later be read from some prefix tree (also known / unknown).
|
||||||
final float weight = 1f;
|
final float weight = 1f;
|
||||||
|
|
||||||
@ -42,7 +54,14 @@ public class Commands extends Check {
|
|||||||
|
|
||||||
if (violation > 0.0){
|
if (violation > 0.0){
|
||||||
data.commandsVL += violation;
|
data.commandsVL += violation;
|
||||||
if (executeActions(player, data.commandsVL, violation, cc.commandsActions))
|
// TODO: Evaluate if sync(data) is necessary or better for executeActions.
|
||||||
|
if (captchaEnabled){
|
||||||
|
synchronized (data) {
|
||||||
|
captcha.sendNewCaptcha(player, cc, data);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (executeActions(player, data.commandsVL, violation, cc.commandsActions))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
Loading…
Reference in New Issue
Block a user