mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-12-29 12:37:40 +01:00
Verbose command shouldn't be able to run as console
This commit is contained in:
parent
8996cf02af
commit
fe0e82f285
@ -37,7 +37,7 @@ public enum CommandPermission {
|
||||
EDITOR("editor", Type.NONE),
|
||||
DEBUG("debug", Type.NONE),
|
||||
VERBOSE("verbose", Type.NONE),
|
||||
VERBOSE_COMMAND_OTHER("verbose.commandother", Type.NONE),
|
||||
VERBOSE_COMMAND_OTHERS("verbose.command.others", Type.NONE),
|
||||
TREE("tree", Type.NONE),
|
||||
SEARCH("search", Type.NONE),
|
||||
CHECK("check", Type.NONE),
|
||||
|
@ -74,24 +74,25 @@ public class VerboseCommand extends SingleCommand {
|
||||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
|
||||
String executorName = args.get(1);
|
||||
String name = args.get(1);
|
||||
Sender executor;
|
||||
|
||||
if (executorName.equalsIgnoreCase("me") || executorName.equalsIgnoreCase(sender.getName())) {
|
||||
if (name.equals("me") || name.equals("self") || name.equalsIgnoreCase(sender.getName())) {
|
||||
executor = sender;
|
||||
} else {
|
||||
if (!CommandPermission.VERBOSE_COMMAND_OTHER.isAuthorized(sender)) {
|
||||
if (!CommandPermission.VERBOSE_COMMAND_OTHERS.isAuthorized(sender)) {
|
||||
Message.COMMAND_NO_PERMISSION.send(sender);
|
||||
return CommandResult.NO_PERMISSION;
|
||||
}
|
||||
|
||||
executor = plugin.getOnlineSenders()
|
||||
.filter(s -> s.getName().equalsIgnoreCase(executorName))
|
||||
.filter(s -> !s.isConsole())
|
||||
.filter(s -> s.getName().equalsIgnoreCase(name))
|
||||
.findAny()
|
||||
.orElse(null);
|
||||
|
||||
if (executor == null) {
|
||||
Message.USER_NOT_ONLINE.send(sender, executorName);
|
||||
Message.USER_NOT_ONLINE.send(sender, name);
|
||||
return CommandResult.STATE_ERROR;
|
||||
}
|
||||
}
|
||||
|
@ -42,29 +42,24 @@ public final class VerboseFilter {
|
||||
private final AST ast;
|
||||
|
||||
public static VerboseFilter acceptAll() {
|
||||
return new VerboseFilter();
|
||||
return new VerboseFilter("", AST.ALWAYS_TRUE);
|
||||
}
|
||||
|
||||
public static VerboseFilter compile(String expression) throws InvalidFilterException {
|
||||
return new VerboseFilter(expression);
|
||||
}
|
||||
|
||||
private VerboseFilter(String expression) throws InvalidFilterException {
|
||||
this.expression = expression;
|
||||
if (expression.isEmpty()) {
|
||||
this.ast = AST.ALWAYS_TRUE;
|
||||
} else {
|
||||
try {
|
||||
this.ast = BooleanExpressionCompiler.compile(expression);
|
||||
} catch (LexerException | ParserException e) {
|
||||
throw new InvalidFilterException("Exception occurred whilst generating an expression for '" + expression + "'", e);
|
||||
}
|
||||
return acceptAll();
|
||||
}
|
||||
|
||||
try {
|
||||
return new VerboseFilter(expression, BooleanExpressionCompiler.compile(expression));
|
||||
} catch (LexerException | ParserException e) {
|
||||
throw new InvalidFilterException("Exception occurred whilst generating an expression for '" + expression + "'", e);
|
||||
}
|
||||
}
|
||||
|
||||
private VerboseFilter() {
|
||||
this.expression = "";
|
||||
this.ast = AST.ALWAYS_TRUE;
|
||||
private VerboseFilter(String expression, AST ast) {
|
||||
this.expression = expression;
|
||||
this.ast = ast;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user