-
Notifications
You must be signed in to change notification settings - Fork 0
/
CraftCrashReport.java
44 lines (38 loc) · 2.21 KB
/
CraftCrashReport.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package org.bukkit.craftbukkit;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.Arrays;
import java.util.Map;
import net.minecraft.crash.ICrashReportDetail;
import org.bukkit.Bukkit;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginDescriptionFile;
import net.minecraft.server.MinecraftServer;
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
public class CraftCrashReport implements ICrashReportDetail<Object> {
public Object call() throws Exception {
StringWriter value = new StringWriter();
try {
value.append("\n Running: ").append(Bukkit.getName()).append(" version ").append(Bukkit.getVersion()).append(" (Implementing API version ").append(Bukkit.getBukkitVersion()).append(") ").append(String.valueOf(MinecraftServer.getServer().isServerInOnlineMode()));
value.append("\n Plugins: {");
for (Plugin plugin : Bukkit.getPluginManager().getPlugins()) {
PluginDescriptionFile description = plugin.getDescription();
boolean legacy = CraftMagicNumbers.isLegacy(description);
value.append(' ').append(description.getFullName()).append(legacy ? "*" : "").append(' ').append(description.getMain()).append(' ').append(Arrays.toString(description.getAuthors().toArray())).append(',');
}
value.append("}\n Warnings: ").append(Bukkit.getWarningState().name());
value.append("\n Reload Count: ").append(String.valueOf(MinecraftServer.getServer().server.reloadCount));
value.append("\n Threads: {");
for (Map.Entry<Thread, ? extends Object[]> entry : Thread.getAllStackTraces().entrySet()) {
value.append(' ').append(entry.getKey().getState().name()).append(' ').append(entry.getKey().getName()).append(": ").append(Arrays.toString(entry.getValue())).append(',');
}
value.append("}\n ").append(Bukkit.getScheduler().toString());
} catch (Throwable t) {
value.append("\n Failed to handle CraftCrashReport:\n");
PrintWriter writer = new PrintWriter(value);
t.printStackTrace(writer);
writer.flush();
}
return value.toString();
}
}