Skip to content

Commit

Permalink
@kugge: Fixed Folia teleportation in unloaded chunks (#368)
Browse files Browse the repository at this point in the history
  • Loading branch information
Intelli committed Jul 14, 2023
1 parent d7b7613 commit 355eea1
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/main/java/net/coreprotect/command/TeleportCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
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;
Expand Down Expand Up @@ -99,12 +101,14 @@ else if (y == null) {

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() });
}
Expand Down

0 comments on commit 355eea1

Please sign in to comment.