Optimized tpbiome command by using ExecutorService (#1504)
This commit is contained in:
parent
7c4f41c6db
commit
1a37569034
1 changed files with 12 additions and 4 deletions
|
@ -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;
|
||||||
}));
|
}));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue