From 9f0ea12f0b81988c207cf9641a28efb75d9463bf Mon Sep 17 00:00:00 2001 From: "Blue (Lukas Rieger)" Date: Fri, 13 Nov 2020 15:17:35 +0100 Subject: [PATCH] Fix NPE when using /bluemap version when bluemap is not loaded --- .../bluemap/common/plugin/commands/Commands.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/plugin/commands/Commands.java b/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/plugin/commands/Commands.java index e49250d5..0f9782c0 100644 --- a/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/plugin/commands/Commands.java +++ b/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/plugin/commands/Commands.java @@ -332,10 +332,15 @@ public int statusCommand(CommandContext context) { public int versionCommand(CommandContext context) { CommandSource source = commandSourceInterface.apply(context.getSource()); + int renderThreadCount = 0; + if (plugin.isLoaded()) { + renderThreadCount = plugin.getRenderManager().getRenderThreadCount(); + } + source.sendMessage(Text.of(TextFormat.BOLD, TextColor.BLUE, "Version: ", TextColor.WHITE, BlueMap.VERSION)); source.sendMessage(Text.of(TextColor.GRAY, "Implementation: ", TextColor.WHITE, plugin.getImplementationType())); source.sendMessage(Text.of(TextColor.GRAY, "Minecraft compatibility: ", TextColor.WHITE, plugin.getMinecraftVersion().getVersionString())); - source.sendMessage(Text.of(TextColor.GRAY, "Render-threads: ", TextColor.WHITE, plugin.getRenderManager().getRenderThreadCount())); + source.sendMessage(Text.of(TextColor.GRAY, "Render-threads: ", TextColor.WHITE, renderThreadCount)); source.sendMessage(Text.of(TextColor.GRAY, "Available processors: ", TextColor.WHITE, Runtime.getRuntime().availableProcessors())); source.sendMessage(Text.of(TextColor.GRAY, "Available memory: ", TextColor.WHITE, (Runtime.getRuntime().maxMemory() / 1024L / 1024L) + " MiB")); @@ -344,7 +349,7 @@ public int versionCommand(CommandContext context) { "Version: " + BlueMap.VERSION + "\n" + "Implementation: " + plugin.getImplementationType() + "\n" + "Minecraft compatibility: " + plugin.getMinecraftVersion().getVersionString() + "\n" + - "Render-threads: " + plugin.getRenderManager().getRenderThreadCount() + "\n" + + "Render-threads: " + renderThreadCount + "\n" + "Available processors: " + Runtime.getRuntime().availableProcessors() + "\n" + "Available memory: " + Runtime.getRuntime().maxMemory() / 1024L / 1024L + " MiB"; source.sendMessage(Text.of(TextColor.DARK_GRAY, "[copy to clipboard]")