Optimized tpbiome command by using ExecutorService (#1504)

This commit is contained in:
thedarkcolour 2019-12-13 23:40:58 -08:00 committed by Adubbz
parent 7c4f41c6db
commit 1a37569034

View file

@ -21,15 +21,23 @@ import net.minecraft.world.World;
import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.Biome;
import net.minecraft.world.chunk.IChunk; import net.minecraft.world.chunk.IChunk;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
public class CommandTpBiome public class CommandTpBiome
{ {
private static final ExecutorService TP_BIOME_THREAD = Executors.newFixedThreadPool(1);
static ArgumentBuilder<CommandSource, ?> register() static ArgumentBuilder<CommandSource, ?> register()
{ {
return Commands.literal("tpbiome") return Commands.literal("tpbiome")
.then(Commands.argument("biome", BiomeArgument.createArgument()) .then(Commands.argument("biome", BiomeArgument.createArgument())
.executes(ctx -> { .executes(ctx -> {
ServerPlayerEntity player = ctx.getSource().asPlayer(); ServerPlayerEntity player = ctx.getSource().asPlayer();
return findTeleportBiome(ctx.getSource(), player, BiomeArgument.getValue(ctx, "biome")); TP_BIOME_THREAD.execute(() -> {
findTeleportBiome(ctx.getSource(), player, BiomeArgument.getValue(ctx, "biome"));
});
return 1;
})); }));
} }