Adding /bug and automated BungeeCord [ERROR] tracking
Dieser Commit ist enthalten in:
Ursprung
ec7d1c34d2
Commit
94ccf7cc75
@ -52,6 +52,7 @@ public class BungeeCore extends Plugin {
|
|||||||
setInstance(this);
|
setInstance(this);
|
||||||
loadConfig();
|
loadConfig();
|
||||||
|
|
||||||
|
new ErrorLogger();
|
||||||
new ConnectionListener();
|
new ConnectionListener();
|
||||||
new Forge();
|
new Forge();
|
||||||
new LabyMod();
|
new LabyMod();
|
||||||
@ -101,6 +102,7 @@ public class BungeeCore extends Plugin {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable(){
|
public void onDisable(){
|
||||||
|
ErrorLogger.stop();
|
||||||
SQL.close();
|
SQL.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
50
src/de/steamwar/bungeecore/ErrorLogger.java
Normale Datei
50
src/de/steamwar/bungeecore/ErrorLogger.java
Normale Datei
@ -0,0 +1,50 @@
|
|||||||
|
package de.steamwar.bungeecore;
|
||||||
|
|
||||||
|
import de.steamwar.bungeecore.sql.SWException;
|
||||||
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
|
|
||||||
|
import java.util.logging.Handler;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.LogRecord;
|
||||||
|
|
||||||
|
public class ErrorLogger extends Handler {
|
||||||
|
private static ErrorLogger instance;
|
||||||
|
|
||||||
|
ErrorLogger(){
|
||||||
|
ProxyServer.getInstance().getLogger().addHandler(this);
|
||||||
|
instance = this;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void stop(){
|
||||||
|
ProxyServer.getInstance().getLogger().removeHandler(instance);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void publish(LogRecord record) {
|
||||||
|
if(record.getLevel() != Level.SEVERE)
|
||||||
|
return;
|
||||||
|
|
||||||
|
StringBuilder stacktrace = new StringBuilder(record.getSourceClassName() + "\n" + record.getSourceMethodName());
|
||||||
|
Throwable thrown = record.getThrown();
|
||||||
|
while(thrown != null){
|
||||||
|
stacktrace.append("\nCaused by").append(thrown.getMessage());
|
||||||
|
|
||||||
|
for(StackTraceElement ste : thrown.getStackTrace())
|
||||||
|
stacktrace.append("\n").append(ste.toString());
|
||||||
|
|
||||||
|
thrown = thrown.getCause();
|
||||||
|
}
|
||||||
|
|
||||||
|
SWException.log("Bungee", record.getMessage(), stacktrace.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void flush() {
|
||||||
|
//ignored
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void close() {
|
||||||
|
//ignored
|
||||||
|
}
|
||||||
|
}
|
24
src/de/steamwar/bungeecore/commands/BugCommand.java
Normale Datei
24
src/de/steamwar/bungeecore/commands/BugCommand.java
Normale Datei
@ -0,0 +1,24 @@
|
|||||||
|
package de.steamwar.bungeecore.commands;
|
||||||
|
|
||||||
|
import de.steamwar.bungeecore.sql.SWException;
|
||||||
|
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||||
|
import net.md_5.bungee.api.CommandSender;
|
||||||
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
|
||||||
|
public class BugCommand extends BasicCommand {
|
||||||
|
public BugCommand() {
|
||||||
|
super("bug", null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(CommandSender sender, String[] args) {
|
||||||
|
if(!(sender instanceof ProxiedPlayer))
|
||||||
|
return;
|
||||||
|
|
||||||
|
ProxiedPlayer player = (ProxiedPlayer) sender;
|
||||||
|
String server = player.getServer().getInfo().getName();
|
||||||
|
String message = String.join(" ", args);
|
||||||
|
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||||
|
SWException.log(server, message, player.getName() + " " + user.getId());
|
||||||
|
}
|
||||||
|
}
|
9
src/de/steamwar/bungeecore/sql/SWException.java
Normale Datei
9
src/de/steamwar/bungeecore/sql/SWException.java
Normale Datei
@ -0,0 +1,9 @@
|
|||||||
|
package de.steamwar.bungeecore.sql;
|
||||||
|
|
||||||
|
public class SWException {
|
||||||
|
private SWException(){}
|
||||||
|
|
||||||
|
public static void log(String server, String message, String stacktrace){
|
||||||
|
SQL.update("INSERT INTO Exception (server, meassage, stacktrace) VALUES (?, ?, ?)", server, message, stacktrace);
|
||||||
|
}
|
||||||
|
}
|
In neuem Issue referenzieren
Einen Benutzer sperren