mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-12-28 03:57:36 +01:00
Add more info the importer error output
This commit is contained in:
parent
1142cbcb2c
commit
74f275eb69
@ -333,6 +333,7 @@ public enum Message {
|
|||||||
IMPORT_END_ERROR_HEADER(
|
IMPORT_END_ERROR_HEADER(
|
||||||
PREFIX + "&e(Import) &7------------> &6Showing Error #&e%s &7<------------" + "\n" +
|
PREFIX + "&e(Import) &7------------> &6Showing Error #&e%s &7<------------" + "\n" +
|
||||||
PREFIX + "&e(Import) &6Whilst executing: &fCommand #%s" + "\n" +
|
PREFIX + "&e(Import) &6Whilst executing: &fCommand #%s" + "\n" +
|
||||||
|
PREFIX + "&e(Import) &6Command: &7%s" + "\n" +
|
||||||
PREFIX + "&e(Import) &6Type: &f%s" + "\n" +
|
PREFIX + "&e(Import) &6Type: &f%s" + "\n" +
|
||||||
PREFIX + "&e(Import) &6Output:",
|
PREFIX + "&e(Import) &6Output:",
|
||||||
false
|
false
|
||||||
|
@ -88,7 +88,7 @@ public class Importer {
|
|||||||
Message.IMPORT_START.send(executor);
|
Message.IMPORT_START.send(executor);
|
||||||
final Sender fake = new FakeSender(this);
|
final Sender fake = new FakeSender(this);
|
||||||
|
|
||||||
int index = 0;
|
int index = 1;
|
||||||
for (String command : commands) {
|
for (String command : commands) {
|
||||||
if (lastMsg < (System.currentTimeMillis() / 1000) - 5) {
|
if (lastMsg < (System.currentTimeMillis() / 1000) - 5) {
|
||||||
lastMsg = System.currentTimeMillis() / 1000;
|
lastMsg = System.currentTimeMillis() / 1000;
|
||||||
@ -99,10 +99,10 @@ public class Importer {
|
|||||||
executing = index;
|
executing = index;
|
||||||
try {
|
try {
|
||||||
CommandResult result = commandManager.onCommand(fake, "perms", Arrays.asList(Patterns.SPACE.split(command)));
|
CommandResult result = commandManager.onCommand(fake, "perms", Arrays.asList(Patterns.SPACE.split(command)));
|
||||||
getResult(index).setResult(result);
|
getResult(index, command).setResult(result);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
getResult(index).setResult(CommandResult.FAILURE);
|
getResult(index, command).setResult(CommandResult.FAILURE);
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
index++;
|
index++;
|
||||||
@ -129,7 +129,7 @@ public class Importer {
|
|||||||
int errIndex = 1;
|
int errIndex = 1;
|
||||||
for (Map.Entry<Integer, Result> e : cmdResult.entrySet()) {
|
for (Map.Entry<Integer, Result> e : cmdResult.entrySet()) {
|
||||||
if (e.getValue().getResult() != null && !e.getValue().getResult().booleanValue()) {
|
if (e.getValue().getResult() != null && !e.getValue().getResult().booleanValue()) {
|
||||||
Message.IMPORT_END_ERROR_HEADER.send(executor, errIndex, e.getKey(), e.getValue().getResult().toString());
|
Message.IMPORT_END_ERROR_HEADER.send(executor, errIndex, e.getKey(), e.getValue().getCommand(), e.getValue().getResult().toString());
|
||||||
for (String s : e.getValue().getOutput()) {
|
for (String s : e.getValue().getOutput()) {
|
||||||
Message.IMPORT_END_ERROR_CONTENT.send(executor, s);
|
Message.IMPORT_END_ERROR_CONTENT.send(executor, s);
|
||||||
}
|
}
|
||||||
@ -158,22 +158,28 @@ public class Importer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Result getResult(int executing) {
|
private Result getResult(int executing, String command) {
|
||||||
if (!cmdResult.containsKey(executing)) {
|
if (!cmdResult.containsKey(executing)) {
|
||||||
cmdResult.put(executing, new Result());
|
cmdResult.put(executing, new Result(command));
|
||||||
}
|
}
|
||||||
|
|
||||||
return cmdResult.get(executing);
|
Result existing = cmdResult.get(executing);
|
||||||
|
|
||||||
|
if (!command.equals("") && existing.getCommand().equals("")) {
|
||||||
|
existing.setCommand(command);
|
||||||
|
}
|
||||||
|
|
||||||
|
return existing;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void logMessage(String msg) {
|
private void logMessage(String msg) {
|
||||||
getResult(executing).getOutput().add(Util.stripColor(msg));
|
getResult(executing, "").getOutput().add(Util.stripColor(msg));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class FakeSender implements Sender {
|
private static class FakeSender implements Sender {
|
||||||
private final Importer instance;
|
private final Importer instance;
|
||||||
|
|
||||||
public FakeSender(Importer instance) {
|
private FakeSender(Importer instance) {
|
||||||
this.instance = instance;
|
this.instance = instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -199,6 +205,9 @@ public class Importer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static class Result {
|
private static class Result {
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
private String command;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private final List<String> output = new ArrayList<>();
|
private final List<String> output = new ArrayList<>();
|
||||||
@ -206,6 +215,10 @@ public class Importer {
|
|||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
private CommandResult result = CommandResult.FAILURE;
|
private CommandResult result = CommandResult.FAILURE;
|
||||||
|
|
||||||
|
private Result(String command) {
|
||||||
|
this.command = command;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user