Change verbose output slightly
This commit is contained in:
parent
7083d55a9b
commit
d7094909c0
@ -13,6 +13,7 @@ loading-error: "Permissions data could not be loaded. Please try again later."
|
||||
op-disabled: "&bThe vanilla OP system is disabled on this server."
|
||||
op-disabled-sponge: "&2Server Operator status has no effect when a permission plugin is installed. Please edit user data directly."
|
||||
log: "&3LOG &3&l> {0}"
|
||||
verbose-log: "&3VERBOSE &3&l> {0}"
|
||||
export-log: "&3EXPORT &3&l> &f{0}"
|
||||
export-log-progress: "&3EXPORT &3&l> &7{0}"
|
||||
migration-log: "&3MIGRATION &7[&3{0}&7] &3&l> &f{1}"
|
||||
|
@ -57,7 +57,7 @@ public class UserInfo extends SubCommand<User> {
|
||||
Message.USER_INFO_GENERAL.send(sender,
|
||||
user.getName().orElse("Unknown"),
|
||||
user.getUuid(),
|
||||
plugin.getPlayerStatus(user.getUuid()),
|
||||
plugin.getPlayerStatus(user.getUuid()).asString(plugin.getLocaleManager()),
|
||||
user.getPrimaryGroup().getValue(),
|
||||
user.getPermanentNodes().size(),
|
||||
user.getTemporaryNodes().size(),
|
||||
|
@ -57,6 +57,7 @@ public enum Message {
|
||||
OP_DISABLED("&bThe vanilla OP system is disabled on this server.", false),
|
||||
OP_DISABLED_SPONGE("&2Server Operator status has no effect when a permission plugin is installed. Please edit user data directly.", true),
|
||||
LOG("&3LOG &3&l> {0}", true),
|
||||
VERBOSE_LOG("&3VERBOSE &3&l> {0}", true),
|
||||
|
||||
EXPORT_LOG("&3EXPORT &3&l> &f{0}", true),
|
||||
EXPORT_LOG_PROGRESS("&3EXPORT &3&l> &7{0}", true),
|
||||
|
@ -78,7 +78,7 @@ public class TreeView {
|
||||
builder.add("```");
|
||||
ret.clear();
|
||||
|
||||
return PasteUtils.paste("luckperms-tree.md", "LuckPerms Permission Tree", builder.build().stream().collect(Collectors.joining("\n")));
|
||||
return PasteUtils.paste("LuckPerms Permission Tree", ImmutableList.of(Maps.immutableEntry("luckperms-tree.md", builder.build().stream().collect(Collectors.joining("\n")))));
|
||||
}
|
||||
|
||||
public String uploadPasteData(String version, String username, PermissionData checker) {
|
||||
@ -98,7 +98,7 @@ public class TreeView {
|
||||
builder.add("```");
|
||||
ret.clear();
|
||||
|
||||
return PasteUtils.paste("luckperms-tree.md", "LuckPerms Permission Tree", builder.build().stream().collect(Collectors.joining("\n")));
|
||||
return PasteUtils.paste("LuckPerms Permission Tree", ImmutableList.of(Maps.immutableEntry("luckperms-tree.md", builder.build().stream().collect(Collectors.joining("\n")))));
|
||||
}
|
||||
|
||||
private static String getTristateDiffPrefix(Tristate t) {
|
||||
|
@ -36,10 +36,12 @@ import java.io.StringWriter;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class PasteUtils {
|
||||
|
||||
public static String paste(String name, String desc, String contents) {
|
||||
public static String paste(String desc, List<Map.Entry<String, String>> files) {
|
||||
HttpURLConnection connection = null;
|
||||
try {
|
||||
connection = (HttpURLConnection) new URL("https://api.github.com/gists").openConnection();
|
||||
@ -49,16 +51,19 @@ public class PasteUtils {
|
||||
|
||||
try (OutputStream os = connection.getOutputStream()) {
|
||||
StringWriter sw = new StringWriter();
|
||||
new JsonWriter(sw).beginObject()
|
||||
|
||||
JsonWriter jw = new JsonWriter(sw)
|
||||
.beginObject()
|
||||
.name("description").value(desc)
|
||||
.name("public").value(false)
|
||||
.name("files")
|
||||
.beginObject().name(name)
|
||||
.beginObject().name("content").value(contents)
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject();
|
||||
.beginObject();
|
||||
|
||||
for (Map.Entry<String, String> file : files) {
|
||||
jw.name(file.getKey()).beginObject().name("content").value(file.getValue()).endObject();
|
||||
}
|
||||
|
||||
jw.endObject().endObject();
|
||||
os.write(sw.toString().getBytes(StandardCharsets.UTF_8));
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,9 @@ package me.lucko.luckperms.common.verbose;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import me.lucko.luckperms.api.Tristate;
|
||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||
import me.lucko.luckperms.common.locale.Message;
|
||||
import me.lucko.luckperms.common.utils.DateUtil;
|
||||
@ -39,16 +41,28 @@ import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.script.ScriptEngine;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
public class VerboseListener {
|
||||
private static final int DATA_TRUNCATION = 3500;
|
||||
private static final int DATA_TRUNCATION = 10000;
|
||||
private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z");
|
||||
private static final Function<Tristate, String> TRISTATE_COLOR = tristate -> {
|
||||
switch (tristate) {
|
||||
case TRUE:
|
||||
return "&2";
|
||||
case FALSE:
|
||||
return "&c";
|
||||
default:
|
||||
return "&7";
|
||||
}
|
||||
};
|
||||
|
||||
private final long startTime = System.currentTimeMillis();
|
||||
|
||||
@ -73,7 +87,7 @@ public class VerboseListener {
|
||||
}
|
||||
|
||||
if (notify) {
|
||||
Message.LOG.send(holder, "&7Checking &a" + data.getChecked() + "&7 for: &a" + data.getNode() + " &f(&7" + data.getValue().toString() + "&f)");
|
||||
Message.VERBOSE_LOG.send(holder, "&a" + data.getChecked() + "&7 -- &a" + data.getNode() + "&7 -- " + TRISTATE_COLOR.apply(data.getValue()) + data.getValue().name().toLowerCase() + "");
|
||||
}
|
||||
}
|
||||
|
||||
@ -198,14 +212,25 @@ public class VerboseListener {
|
||||
.add("___")
|
||||
.add("");
|
||||
|
||||
List<String> ret = results.stream()
|
||||
.map(c -> "`" + c.getChecked() + "` - " + c.getNode() + " - **" + c.getValue().toString() + "** ")
|
||||
.collect(Collectors.toList());
|
||||
ImmutableList.Builder<String> data = ImmutableList.<String>builder()
|
||||
.add("User,Permission,Result");
|
||||
|
||||
output.addAll(ret);
|
||||
results.stream()
|
||||
.peek(c -> output.add("`" + c.getChecked() + "` - " + c.getNode() + " - **" + c.getValue().toString() + "** "))
|
||||
.forEach(c -> data.add(escapeCommas(c.getChecked()) + "," + escapeCommas(c.getNode()) + "," + c.getValue().name().toLowerCase()));
|
||||
|
||||
results.clear();
|
||||
return PasteUtils.paste("luckperms-verbose.md", "LuckPerms Verbose Checking Output", output.build().stream().collect(Collectors.joining("\n")));
|
||||
|
||||
List<Map.Entry<String, String>> content = ImmutableList.of(
|
||||
Maps.immutableEntry("luckperms-verbose.md", output.build().stream().collect(Collectors.joining("\n"))),
|
||||
Maps.immutableEntry("raw-data.csv", data.build().stream().collect(Collectors.joining("\n")))
|
||||
);
|
||||
|
||||
return PasteUtils.paste("LuckPerms Verbose Checking Output", content);
|
||||
}
|
||||
|
||||
private static String escapeCommas(String s) {
|
||||
return s.contains(",") ? "\"" + s + "\"" : s;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user