mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-21 05:50:18 +08:00
Add compat with aliases
This commit is contained in:
parent
9b6d133b11
commit
f20d85a021
@ -1,5 +1,6 @@
|
||||
package main.java.com.djrapitops.plan.command.commands;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import org.apache.logging.log4j.Level;
|
||||
import org.apache.logging.log4j.Marker;
|
||||
import org.apache.logging.log4j.core.LogEvent;
|
||||
@ -7,6 +8,8 @@ import org.apache.logging.log4j.core.Logger;
|
||||
import org.apache.logging.log4j.core.filter.AbstractFilter;
|
||||
import org.apache.logging.log4j.message.Message;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Filters out WebUser registration command logs.
|
||||
*
|
||||
@ -15,6 +18,8 @@ import org.apache.logging.log4j.message.Message;
|
||||
*/
|
||||
public class RegisterCommandFilter extends AbstractFilter {
|
||||
|
||||
private Set<String> censoredCommands = ImmutableSet.of("/plan web register", "/plan webuser register", "/plan register");
|
||||
|
||||
@Override
|
||||
public Result filter(LogEvent event) {
|
||||
if (event == null) {
|
||||
@ -43,7 +48,7 @@ public class RegisterCommandFilter extends AbstractFilter {
|
||||
return validateMessage(msg.toString());
|
||||
}
|
||||
|
||||
private static Result validateMessage(Message message) {
|
||||
private Result validateMessage(Message message) {
|
||||
if (message == null) {
|
||||
return Result.NEUTRAL;
|
||||
}
|
||||
@ -51,14 +56,18 @@ public class RegisterCommandFilter extends AbstractFilter {
|
||||
return validateMessage(message.getFormattedMessage());
|
||||
}
|
||||
|
||||
private static Result validateMessage(String message) {
|
||||
private Result validateMessage(String message) {
|
||||
return isSensibleCommand(message)
|
||||
? Result.DENY
|
||||
: Result.NEUTRAL;
|
||||
}
|
||||
|
||||
private static boolean isSensibleCommand(String message) {
|
||||
private boolean isSensibleCommand(String message) {
|
||||
message = message.toLowerCase();
|
||||
return message.contains("issued server command:") && message.contains("/plan register");
|
||||
return message.contains("issued server command:") && isSensible(message);
|
||||
}
|
||||
|
||||
private boolean isSensible(String message) {
|
||||
return censoredCommands.stream().anyMatch(message::contains);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user