Skip to content

Commit

Permalink
fix: Fixed initial Command checks not applying
Browse files Browse the repository at this point in the history
  • Loading branch information
4drian3d committed May 14, 2023
1 parent 2b2827d commit 183138c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public final class SyntaxCheck implements Check {
SyntaxCheck(Collection<String> allowedCommands) {
this.allowedCommands = allowedCommands;
}

@Override
public @NotNull CheckResult check(@NotNull InfractionPlayer player, @NotNull String string) {
final String command = Commands.getFirstArgument(requireNonNull(string));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ private boolean checkIfCanCheck(final String command) {
cooldownProvider
).detect(infractionPlayer, event.getCommand())
.exceptionally(ex -> {
logger.error("An error occurred while checking Command and Syntax", ex);
logger.error("An error occurred while checking initial command checks", ex);
return CheckResult.allowed();
})
.thenCompose(checkResult -> {
Expand Down Expand Up @@ -110,16 +110,17 @@ private boolean checkIfCanCheck(final String command) {
infractionPlayer.onDenied(deniedResult, event.getCommand());
event.setResult(CommandExecuteEvent.CommandResult.denied());
continuation.resume();
return null;
}
if (result.shouldModify()) {
final CheckResult.ReplaceCheckResult replaceResult = (CheckResult.ReplaceCheckResult) result;
final String replacedCommand = replaceResult.replaced();
infractionPlayer.getChain(SourceType.COMMAND).executed(replacedCommand);
event.setResult(CommandExecuteEvent.CommandResult.command(replacedCommand));
continuation.resume();
} else {
infractionPlayer.getChain(SourceType.COMMAND).executed(event.getCommand());
event.setResult(CommandExecuteEvent.CommandResult.allowed());
}
infractionPlayer.getChain(SourceType.COMMAND).executed(event.getCommand());
event.setResult(CommandExecuteEvent.CommandResult.allowed());
continuation.resume();
}
return null;
Expand Down

0 comments on commit 183138c

Please sign in to comment.