Make the uuid argument for the /bluemap render cancel command optional

So it can be used on the console to cancel render-tasks
This commit is contained in:
Blue (Lukas Rieger) 2020-09-15 16:35:10 +02:00
parent 2d14e83787
commit 3b6ed4c297

View File

@ -176,8 +176,11 @@ public void init() {
LiteralCommandNode<S> cancelRenderCommand =
literal("cancel")
.requires(requirements("bluemap.render"))
.executes(this::cancelLastRenderTaskCommand)
.then(argument("uuid", StringArgumentType.string())
.executes(this::cancelRenderTaskCommand))
.build();
LiteralCommandNode<S> worldsCommand =
@ -570,6 +573,22 @@ public int prioritizeRenderTaskCommand(CommandContext<S> context) {
return 0;
}
public int cancelLastRenderTaskCommand(CommandContext<S> 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<S> context) {
CommandSource source = commandSourceInterface.apply(context.getSource());