From 1a37569034705c0271f4644892740bbc6d5f7d61 Mon Sep 17 00:00:00 2001 From: thedarkcolour <30441001+thedarkcolour@users.noreply.github.com> Date: Fri, 13 Dec 2019 23:40:58 -0800 Subject: [PATCH] Optimized tpbiome command by using ExecutorService (#1504) --- .../common/command/CommandTpBiome.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/main/java/biomesoplenty/common/command/CommandTpBiome.java b/src/main/java/biomesoplenty/common/command/CommandTpBiome.java index 096aaa15e..3c3073681 100644 --- a/src/main/java/biomesoplenty/common/command/CommandTpBiome.java +++ b/src/main/java/biomesoplenty/common/command/CommandTpBiome.java @@ -21,16 +21,24 @@ import net.minecraft.world.World; import net.minecraft.world.biome.Biome; import net.minecraft.world.chunk.IChunk; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + public class CommandTpBiome { + private static final ExecutorService TP_BIOME_THREAD = Executors.newFixedThreadPool(1); + static ArgumentBuilder register() { return Commands.literal("tpbiome") .then(Commands.argument("biome", BiomeArgument.createArgument()) - .executes(ctx -> { - ServerPlayerEntity player = ctx.getSource().asPlayer(); - return findTeleportBiome(ctx.getSource(), player, BiomeArgument.getValue(ctx, "biome")); - })); + .executes(ctx -> { + ServerPlayerEntity player = ctx.getSource().asPlayer(); + TP_BIOME_THREAD.execute(() -> { + findTeleportBiome(ctx.getSource(), player, BiomeArgument.getValue(ctx, "biome")); + }); + return 1; + })); }