2019-06-01 11:41:19 +00:00
|
|
|
/*
|
|
|
|
* WorldEdit, a Minecraft world manipulation toolkit
|
|
|
|
* Copyright (C) sk89q <http://www.sk89q.com>
|
|
|
|
* Copyright (C) WorldEdit team and contributors
|
|
|
|
*
|
2020-08-25 01:31:47 +00:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
2019-06-01 11:41:19 +00:00
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
2020-08-25 01:31:47 +00:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
2019-06-01 11:41:19 +00:00
|
|
|
*
|
2020-08-25 01:31:47 +00:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2019-06-01 11:41:19 +00:00
|
|
|
*/
|
|
|
|
|
2019-05-27 22:26:20 +00:00
|
|
|
package com.sk89q.worldedit.command.util;
|
|
|
|
|
|
|
|
import com.sk89q.worldedit.WorldEdit;
|
|
|
|
import com.sk89q.worldedit.extension.platform.Actor;
|
|
|
|
import com.sk89q.worldedit.util.formatting.text.Component;
|
2019-11-01 12:33:31 +00:00
|
|
|
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
2019-05-27 22:26:20 +00:00
|
|
|
|
|
|
|
import java.util.concurrent.Callable;
|
2020-07-14 02:50:59 +00:00
|
|
|
import javax.annotation.Nullable;
|
2019-05-27 22:26:20 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* For internal WorldEdit use only.
|
|
|
|
*/
|
|
|
|
public final class WorldEditAsyncCommandBuilder {
|
|
|
|
private WorldEditAsyncCommandBuilder() {
|
|
|
|
}
|
|
|
|
|
2019-11-01 12:33:31 +00:00
|
|
|
@Deprecated
|
2019-05-27 22:26:20 +00:00
|
|
|
public static void createAndSendMessage(Actor actor, Callable<Component> task, @Nullable String desc) {
|
2019-11-01 12:33:31 +00:00
|
|
|
createAndSendMessage(actor, task, desc != null ? TextComponent.of(desc) : null);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void createAndSendMessage(Actor actor, Callable<Component> task, @Nullable Component desc) {
|
2019-05-27 22:26:20 +00:00
|
|
|
final AsyncCommandBuilder<Component> builder = AsyncCommandBuilder.wrap(task, actor);
|
|
|
|
if (desc != null) {
|
2021-07-23 15:48:51 +00:00
|
|
|
builder.setDelayMessage(desc);
|
2019-05-27 22:26:20 +00:00
|
|
|
}
|
|
|
|
builder
|
2019-11-01 12:33:31 +00:00
|
|
|
.onSuccess((String) null, actor::printInfo)
|
2019-05-27 22:26:20 +00:00
|
|
|
.onFailure((String) null, WorldEdit.getInstance().getPlatformManager().getPlatformCommandManager().getExceptionConverter())
|
|
|
|
.buildAndExec(WorldEdit.getInstance().getExecutorService());
|
|
|
|
}
|
|
|
|
}
|