From 3b6ed4c2975f13d3d59c1b1e267e1c4e6294db87 Mon Sep 17 00:00:00 2001 From: "Blue (Lukas Rieger)" Date: Tue, 15 Sep 2020 16:35:10 +0200 Subject: [PATCH] Make the uuid argument for the /bluemap render cancel command optional So it can be used on the console to cancel render-tasks --- .../common/plugin/commands/Commands.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) 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 f6cac891..fe33c927 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 @@ -176,8 +176,11 @@ public void init() { LiteralCommandNode cancelRenderCommand = literal("cancel") .requires(requirements("bluemap.render")) + .executes(this::cancelLastRenderTaskCommand) + .then(argument("uuid", StringArgumentType.string()) .executes(this::cancelRenderTaskCommand)) + .build(); LiteralCommandNode worldsCommand = @@ -570,6 +573,22 @@ public int prioritizeRenderTaskCommand(CommandContext context) { return 0; } + public int cancelLastRenderTaskCommand(CommandContext context) { + CommandSource source = commandSourceInterface.apply(context.getSource()); + + RenderTask[] tasks = plugin.getRenderManager().getRenderTasks(); + if (tasks.length == 0) { + source.sendMessage(Text.of(TextColor.RED, "There is currently no render task scheduled!")); + return 0; + } + + RenderTask task = tasks[tasks.length - 1]; + + plugin.getRenderManager().removeRenderTask(task); + source.sendMessage(Text.of(TextColor.GREEN, "The render-task '" + task.getName() + "' has been canceled!")); + return 1; + } + public int cancelRenderTaskCommand(CommandContext context) { CommandSource source = commandSourceInterface.apply(context.getSource());