Clean up the impl a bit
This commit is contained in:
parent
7b267ecadc
commit
729efa2452
1 changed files with 5 additions and 5 deletions
|
@ -72,9 +72,7 @@ public class PocketCommand {
|
||||||
private static int load(ServerCommandSource source, PocketTemplate template) throws CommandSyntaxException {
|
private static int load(ServerCommandSource source, PocketTemplate template) throws CommandSyntaxException {
|
||||||
ServerPlayerEntity player = source.getPlayer();
|
ServerPlayerEntity player = source.getPlayer();
|
||||||
boolean async = DimensionalDoorsInitializer.getConfig().getPocketsConfig().asyncWorldEditPocketLoading;
|
boolean async = DimensionalDoorsInitializer.getConfig().getPocketsConfig().asyncWorldEditPocketLoading;
|
||||||
Consumer<Text> messageSender = async ? t -> source.getMinecraftServer().execute(() -> {
|
Consumer<Runnable> taskAcceptor = async ? r -> source.getMinecraftServer().execute(r) : Runnable::run;
|
||||||
source.sendFeedback(t, true);
|
|
||||||
}) : t -> source.sendFeedback(t, true);
|
|
||||||
Runnable task = () -> {
|
Runnable task = () -> {
|
||||||
CompoundTag tag = Schematic.toTag(template.getSchematic());
|
CompoundTag tag = Schematic.toTag(template.getSchematic());
|
||||||
ByteArrayOutputStream stream = new ByteArrayOutputStream();
|
ByteArrayOutputStream stream = new ByteArrayOutputStream();
|
||||||
|
@ -89,8 +87,10 @@ public class PocketCommand {
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException(e); // Can't happen, the stream is a ByteArrayInputStream
|
throw new RuntimeException(e); // Can't happen, the stream is a ByteArrayInputStream
|
||||||
}
|
}
|
||||||
WorldEdit.getInstance().getSessionManager().get(FabricAdapter.adaptPlayer(player)).setClipboard(new ClipboardHolder(clipboard));
|
taskAcceptor.accept(() -> {
|
||||||
messageSender.accept(new TranslatableText("commands.pocket.loadedSchem", template.getId()));
|
WorldEdit.getInstance().getSessionManager().get(FabricAdapter.adaptPlayer(player)).setClipboard(new ClipboardHolder(clipboard));
|
||||||
|
source.sendFeedback(new TranslatableText("commands.pocket.loadedSchem", template.getId()), true);
|
||||||
|
});
|
||||||
};
|
};
|
||||||
if (async) {
|
if (async) {
|
||||||
CompletableFuture.runAsync(task);
|
CompletableFuture.runAsync(task);
|
||||||
|
|
Loading…
Reference in a new issue