Fix NPE when using /bluemap version when bluemap is not loaded

This commit is contained in:
Blue (Lukas Rieger) 2020-11-13 15:17:35 +01:00
parent 0c7eb09bd1
commit 9f0ea12f0b
No known key found for this signature in database
GPG Key ID: 904C4995F9E1F800

View File

@ -332,10 +332,15 @@ public int statusCommand(CommandContext<S> context) {
public int versionCommand(CommandContext<S> context) { public int versionCommand(CommandContext<S> context) {
CommandSource source = commandSourceInterface.apply(context.getSource()); 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(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, "Implementation: ", TextColor.WHITE, plugin.getImplementationType()));
source.sendMessage(Text.of(TextColor.GRAY, "Minecraft compatibility: ", TextColor.WHITE, plugin.getMinecraftVersion().getVersionString())); 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 processors: ", TextColor.WHITE, Runtime.getRuntime().availableProcessors()));
source.sendMessage(Text.of(TextColor.GRAY, "Available memory: ", TextColor.WHITE, (Runtime.getRuntime().maxMemory() / 1024L / 1024L) + " MiB")); source.sendMessage(Text.of(TextColor.GRAY, "Available memory: ", TextColor.WHITE, (Runtime.getRuntime().maxMemory() / 1024L / 1024L) + " MiB"));
@ -344,7 +349,7 @@ public int versionCommand(CommandContext<S> context) {
"Version: " + BlueMap.VERSION + "\n" + "Version: " + BlueMap.VERSION + "\n" +
"Implementation: " + plugin.getImplementationType() + "\n" + "Implementation: " + plugin.getImplementationType() + "\n" +
"Minecraft compatibility: " + plugin.getMinecraftVersion().getVersionString() + "\n" + "Minecraft compatibility: " + plugin.getMinecraftVersion().getVersionString() + "\n" +
"Render-threads: " + plugin.getRenderManager().getRenderThreadCount() + "\n" + "Render-threads: " + renderThreadCount + "\n" +
"Available processors: " + Runtime.getRuntime().availableProcessors() + "\n" + "Available processors: " + Runtime.getRuntime().availableProcessors() + "\n" +
"Available memory: " + Runtime.getRuntime().maxMemory() / 1024L / 1024L + " MiB"; "Available memory: " + Runtime.getRuntime().maxMemory() / 1024L / 1024L + " MiB";
source.sendMessage(Text.of(TextColor.DARK_GRAY, "[copy to clipboard]") source.sendMessage(Text.of(TextColor.DARK_GRAY, "[copy to clipboard]")