|
1 | 1 | package com.fibermc.essentialcommands.commands; |
2 | 2 |
|
3 | 3 | import java.util.Random; |
| 4 | +import java.util.concurrent.CompletableFuture; |
4 | 5 |
|
5 | 6 | import com.fibermc.essentialcommands.EssentialCommands; |
6 | 7 | import com.fibermc.essentialcommands.ManagerLocator; |
|
19 | 20 | import net.minecraft.block.BlockState; |
20 | 21 | import net.minecraft.block.Material; |
21 | 22 | import net.minecraft.command.CommandException; |
| 23 | +import net.minecraft.server.MinecraftServer; |
22 | 24 | import net.minecraft.server.command.ServerCommandSource; |
23 | 25 | import net.minecraft.server.network.ServerPlayerEntity; |
24 | 26 | import net.minecraft.server.world.ServerWorld; |
@@ -78,15 +80,14 @@ public int run(CommandContext<ServerCommandSource> context) throws CommandSyntax |
78 | 80 | playerData.setTimeUsedRtp(curServerTickTime); |
79 | 81 | } |
80 | 82 |
|
81 | | - new Thread("RTP Location Calculator Thread") { |
82 | | - public void run() { |
83 | | - try { |
84 | | - exec(context.getSource(), world); |
85 | | - } catch (CommandSyntaxException e) { |
86 | | - e.printStackTrace(); |
87 | | - } |
| 83 | + CompletableFuture.runAsync(() -> { |
| 84 | + try { |
| 85 | + exec(context.getSource(), world); |
| 86 | + } catch (CommandSyntaxException e) { |
| 87 | + e.printStackTrace(); |
88 | 88 | } |
89 | | - }.start(); |
| 89 | + }); |
| 90 | + |
90 | 91 | return 1; |
91 | 92 | } |
92 | 93 |
|
@@ -156,11 +157,11 @@ private static int exec(ServerPlayerEntity player, ServerWorld world, MinecraftL |
156 | 157 | } |
157 | 158 |
|
158 | 159 | // Teleport the player |
159 | | - PlayerTeleporter.requestTeleport( |
| 160 | + world.getServer().executeSync(() -> PlayerTeleporter.requestTeleport( |
160 | 161 | player, |
161 | 162 | new MinecraftLocation(world.getRegistryKey(), new_x, new_y, new_z, 0, 0), |
162 | 163 | ecText.getText("cmd.rtp.location_name") |
163 | | - ); |
| 164 | + )); |
164 | 165 |
|
165 | 166 | return 1; |
166 | 167 | } |
|
0 commit comments