|
@@ -11,6 +11,7 @@ public class SnuviLogger implements ISnuviLogger {
|
|
private boolean printToConsole = true;
|
|
private boolean printToConsole = true;
|
|
private MinecraftServer server = null;
|
|
private MinecraftServer server = null;
|
|
private Permissions perms = null;
|
|
private Permissions perms = null;
|
|
|
|
+ private final RingArray<String> history = new RingArray(100);
|
|
|
|
|
|
public void setConsoleLogging(boolean b) {
|
|
public void setConsoleLogging(boolean b) {
|
|
printToConsole = b;
|
|
printToConsole = b;
|
|
@@ -21,68 +22,46 @@ public class SnuviLogger implements ISnuviLogger {
|
|
this.perms = perms;
|
|
this.perms = perms;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public RingArray<String> getHistory() {
|
|
|
|
+ return history;
|
|
|
|
+ }
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public void print(String message, Exception ex, String function, String scriptname, Script sc, StackTrace lines) {
|
|
public void print(String message, Exception ex, String function, String scriptname, Script sc, StackTrace lines) {
|
|
StringBuilder sb = new StringBuilder();
|
|
StringBuilder sb = new StringBuilder();
|
|
sb.append("[§cLogger§r] ");
|
|
sb.append("[§cLogger§r] ");
|
|
|
|
|
|
String color;
|
|
String color;
|
|
-
|
|
|
|
if(ex == null) {
|
|
if(ex == null) {
|
|
color = "§e";
|
|
color = "§e";
|
|
- sb.append(color);
|
|
|
|
- sb.append("debug: '§r");
|
|
|
|
- sb.append(message);
|
|
|
|
- sb.append(color);
|
|
|
|
- sb.append("'");
|
|
|
|
|
|
+ sb.append(color).append("debug: '§r").append(message).append(color).append("'");
|
|
} else {
|
|
} else {
|
|
color = "§c";
|
|
color = "§c";
|
|
- sb.append(color);
|
|
|
|
- sb.append(ex.getClass().getSimpleName());
|
|
|
|
- sb.append("§r: '");
|
|
|
|
- sb.append(color);
|
|
|
|
- sb.append(ex.getMessage());
|
|
|
|
|
|
+ sb.append(color).append(ex.getClass().getSimpleName()).append("§r: '").append(color).append(ex.getMessage());
|
|
if(message != null && !message.isEmpty()) {
|
|
if(message != null && !message.isEmpty()) {
|
|
- sb.append(" - ");
|
|
|
|
- sb.append(message);
|
|
|
|
|
|
+ sb.append(" - ").append(message);
|
|
}
|
|
}
|
|
sb.append("§r'");
|
|
sb.append("§r'");
|
|
}
|
|
}
|
|
-
|
|
|
|
if(scriptname != null && !scriptname.isEmpty()) {
|
|
if(scriptname != null && !scriptname.isEmpty()) {
|
|
- sb.append(" in script '");
|
|
|
|
- sb.append(color);
|
|
|
|
- sb.append(scriptname);
|
|
|
|
- sb.append("§r'");
|
|
|
|
|
|
+ sb.append(" in script '").append(color).append(scriptname).append("§r'");
|
|
}
|
|
}
|
|
-
|
|
|
|
if(sc != null) {
|
|
if(sc != null) {
|
|
- sb.append(" id '");
|
|
|
|
- sb.append(color);
|
|
|
|
- sb.append(sc.getId());
|
|
|
|
- sb.append("§r'");
|
|
|
|
|
|
+ sb.append(" id '").append(color).append(sc.getId()).append("§r'");
|
|
}
|
|
}
|
|
-
|
|
|
|
if(function != null && !function.isEmpty()) {
|
|
if(function != null && !function.isEmpty()) {
|
|
- sb.append(" in function '");
|
|
|
|
- sb.append(color);
|
|
|
|
- sb.append(function);
|
|
|
|
- sb.append("§r'");
|
|
|
|
|
|
+ sb.append(" in function '").append(color).append(function).append("§r'");
|
|
}
|
|
}
|
|
-
|
|
|
|
if(lines != null) {
|
|
if(lines != null) {
|
|
- sb.append(" in line '");
|
|
|
|
- sb.append(color);
|
|
|
|
- sb.append(lines);
|
|
|
|
- sb.append("§r'");
|
|
|
|
|
|
+ sb.append(" in line '").append(color).append(lines).append("§r'");
|
|
}
|
|
}
|
|
|
|
|
|
- StringTextComponent text = new StringTextComponent(sb.toString());
|
|
|
|
-
|
|
|
|
|
|
+ String s = sb.toString();
|
|
|
|
+ history.add(s);
|
|
|
|
+ StringTextComponent text = new StringTextComponent(s);
|
|
if(printToConsole && server != null) {
|
|
if(printToConsole && server != null) {
|
|
server.sendMessage(text);
|
|
server.sendMessage(text);
|
|
}
|
|
}
|
|
-
|
|
|
|
if(server != null && perms != null && server.getPlayerList() != null) {
|
|
if(server != null && perms != null && server.getPlayerList() != null) {
|
|
server.getPlayerList().getPlayers().forEach(p -> {
|
|
server.getPlayerList().getPlayers().forEach(p -> {
|
|
if(perms.has(p, "script.error")) {
|
|
if(perms.has(p, "script.error")) {
|