From 087a2cf4db07dccb82182b2eea7f59063600e9ff Mon Sep 17 00:00:00 2001 From: md_5 Date: Mon, 8 Jul 2019 12:34:15 +1000 Subject: [PATCH] Print number of force loaded chunks per plugin in crash reports --- .../org/bukkit/craftbukkit/CraftCrashReport.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main/java/org/bukkit/craftbukkit/CraftCrashReport.java b/src/main/java/org/bukkit/craftbukkit/CraftCrashReport.java index 21c21e102b..7511e38130 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftCrashReport.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftCrashReport.java @@ -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 { 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> 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);