Print number of force loaded chunks per plugin in crash reports

This commit is contained in:
md_5 2019-07-08 12:34:15 +10:00
parent 07b5b06d2c
commit 087a2cf4db

View File

@ -3,10 +3,13 @@ package org.bukkit.craftbukkit;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.Arrays;
import java.util.Collection;
import java.util.Map;
import net.minecraft.server.CrashReportCallable;
import net.minecraft.server.MinecraftServer;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.World;
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginDescriptionFile;
@ -31,6 +34,15 @@ public class CraftCrashReport implements CrashReportCallable<Object> {
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());
value.append("\n Force Loaded Chunks: {");
for (World world : Bukkit.getWorlds()) {
value.append(' ').append(world.getName()).append(": {");
for (Map.Entry<Plugin, Collection<Chunk>> entry : world.getPluginChunkTickets().entrySet()) {
value.append(' ').append(entry.getKey().getDescription().getFullName()).append(": ").append(Integer.toString(entry.getValue().size())).append(',');
}
value.append("},");
}
value.append("}");
} catch (Throwable t) {
value.append("\n Failed to handle CraftCrashReport:\n");
PrintWriter writer = new PrintWriter(value);