mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-11-28 05:35:26 +01:00
Allow multiple verbose filters
This commit is contained in:
parent
f72819a664
commit
2dd0858960
@ -29,11 +29,13 @@ import me.lucko.luckperms.common.commands.SingleMainCommand;
|
|||||||
import me.lucko.luckperms.common.constants.Message;
|
import me.lucko.luckperms.common.constants.Message;
|
||||||
import me.lucko.luckperms.common.constants.Permission;
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class VerboseCommand extends SingleMainCommand {
|
public class VerboseCommand extends SingleMainCommand {
|
||||||
public VerboseCommand() {
|
public VerboseCommand() {
|
||||||
super("Verbose", "/%s verbose <true|false> [query]", 1, Permission.VERBOSE);
|
super("Verbose", "/%s verbose <true|false> [filters]", 1, Permission.VERBOSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -54,10 +56,15 @@ public class VerboseCommand extends SingleMainCommand {
|
|||||||
return CommandResult.SUCCESS;
|
return CommandResult.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
String query = args.size() == 1 ? "" : args.get(1);
|
List<String> filters = new ArrayList<>();
|
||||||
plugin.getDebugHandler().register(sender, query);
|
if (args.size() != 1) {
|
||||||
if (!query.equals("")) {
|
filters.addAll(args.subList(1, args.size() + 1));
|
||||||
Message.VERBOSE_ON_QUERY.send(sender, query);
|
}
|
||||||
|
|
||||||
|
|
||||||
|
plugin.getDebugHandler().register(sender, filters);
|
||||||
|
if (!filters.isEmpty()) {
|
||||||
|
Message.VERBOSE_ON_QUERY.send(sender, filters.stream().collect(Collectors.joining("&7, &f")));
|
||||||
} else {
|
} else {
|
||||||
Message.VERBOSE_ON.send(sender);
|
Message.VERBOSE_ON.send(sender);
|
||||||
}
|
}
|
||||||
|
@ -85,7 +85,7 @@ public enum Message {
|
|||||||
* Commands
|
* Commands
|
||||||
*/
|
*/
|
||||||
VERBOSE_ON("&bVerbose checking output set to &aTRUE &bfor all permissions.", true),
|
VERBOSE_ON("&bVerbose checking output set to &aTRUE &bfor all permissions.", true),
|
||||||
VERBOSE_ON_QUERY("&bVerbose checking output set to &aTRUE &bfor permissions starting with &f\"{0}\"&b.", true),
|
VERBOSE_ON_QUERY("&bVerbose checking output set to &aTRUE &bfor permissions matching the following filters: &f{0}", true),
|
||||||
VERBOSE_OFF("&bVerbose checking output set to &cFALSE&b.", true),
|
VERBOSE_OFF("&bVerbose checking output set to &cFALSE&b.", true),
|
||||||
|
|
||||||
CREATE_SUCCESS("&b{0}&a was successfully created.", true),
|
CREATE_SUCCESS("&b{0}&a was successfully created.", true),
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
|
|
||||||
package me.lucko.luckperms.common.utils;
|
package me.lucko.luckperms.common.utils;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
@ -29,23 +30,39 @@ import me.lucko.luckperms.api.Tristate;
|
|||||||
import me.lucko.luckperms.common.commands.Sender;
|
import me.lucko.luckperms.common.commands.Sender;
|
||||||
import me.lucko.luckperms.common.constants.Message;
|
import me.lucko.luckperms.common.constants.Message;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
public class DebugHandler {
|
public class DebugHandler {
|
||||||
private final Map<Reciever, String> listeners = new ConcurrentHashMap<>();
|
private final Map<Reciever, List<String>> listeners = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
public void printOutput(String checked, String node, Tristate value) {
|
public void printOutput(String checked, String node, Tristate value) {
|
||||||
for (Map.Entry<Reciever, String> e : listeners.entrySet()) {
|
for (Map.Entry<Reciever, List<String>> e : listeners.entrySet()) {
|
||||||
if (node.toLowerCase().startsWith(e.getValue().toLowerCase())) {
|
List<String> filters = e.getValue();
|
||||||
Message.LOG.send(e.getKey().getSender(), "&7Checking &a" + checked + "&7 for: &a" + node + " &f(&7" + value.toString() + "&f)");
|
|
||||||
|
find:
|
||||||
|
if (!filters.isEmpty()) {
|
||||||
|
for (String filter : filters) {
|
||||||
|
if (node.toLowerCase().startsWith(filter.toLowerCase())) {
|
||||||
|
break find;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (checked.equalsIgnoreCase(filter)) {
|
||||||
|
break find;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Message.LOG.send(e.getKey().getSender(), "&7Checking &a" + checked + "&7 for: &a" + node + " &f(&7" + value.toString() + "&f)");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void register(Sender sender, String s) {
|
public void register(Sender sender, List<String> filters) {
|
||||||
listeners.put(new Reciever(sender.getUuid(), sender), s);
|
listeners.put(new Reciever(sender.getUuid(), sender), ImmutableList.copyOf(filters));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void unregister(UUID uuid) {
|
public void unregister(UUID uuid) {
|
||||||
|
Loading…
Reference in New Issue
Block a user