@kugge: Fixed Folia teleportation in unloaded chunks (#368)

This commit is contained in:
Intelli 2023-07-13 18:35:49 -06:00
parent d7b76135c8
commit 355eea1cf9
1 changed files with 9 additions and 5 deletions

View File

@ -6,8 +6,10 @@ import org.bukkit.World;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import net.coreprotect.CoreProtect;
import net.coreprotect.config.ConfigHandler;
import net.coreprotect.language.Phrase;
import net.coreprotect.thread.Scheduler;
import net.coreprotect.utility.Chat;
import net.coreprotect.utility.ChatMessage;
import net.coreprotect.utility.Color;
@ -99,12 +101,14 @@ public class TeleportCommand {
int chunkX = location.getBlockX() >> 4;
int chunkZ = location.getBlockZ() >> 4;
if (location.getWorld().isChunkLoaded(chunkX, chunkZ) == false) {
location.getWorld().getChunkAt(location);
}
Scheduler.runTask(CoreProtect.getInstance(), () -> {
if (!location.getWorld().isChunkLoaded(chunkX, chunkZ)) {
location.getWorld().getChunkAt(location);
}
// Teleport the player to a safe location
Teleport.performSafeTeleport(((Player) player), location, true);
// Teleport the player to a safe location
Teleport.performSafeTeleport(((Player) player), location, true);
}, location);
ConfigHandler.teleportThrottle.put(player.getName(), new Object[] { false, System.currentTimeMillis() });
}