Execute Location#getChunk() on global region

This commit is contained in:
Allink 2023-03-31 16:49:36 +01:00
parent 52f1c09070
commit ef47727bd0
No known key found for this signature in database

View file

@ -31,16 +31,19 @@ public final class CommandSpawn implements CommandExecutor {
final World defaultWorld = Bukkit.getWorld("world");
final World world = (defaultWorld == null) ? Bukkit.getWorlds().get(0) : defaultWorld;
final Location spawnLocation = world.getSpawnLocation();
final Chunk chunk = spawnLocation.getChunk();
final Main plugin = JavaPlugin.getPlugin(Main.class);
PlatformScheduler.executeOnChunk(plugin, chunk, () -> {
final Location safeSpawnLocation = world.getHighestBlockAt(spawnLocation)
.getLocation()
.add(0, 20, 0);
player.teleportAsync(safeSpawnLocation);
player.sendMessage(Component
.text("Successfully moved to spawn"));
PlatformScheduler.executeOnGlobalRegion(plugin, () -> {
final Chunk chunk = spawnLocation.getChunk();
PlatformScheduler.executeOnChunk(plugin, chunk, () -> {
final Location safeSpawnLocation = world.getHighestBlockAt(spawnLocation)
.getLocation()
.add(0, 20, 0);
player.teleportAsync(safeSpawnLocation);
player.sendMessage(Component
.text("Successfully moved to spawn"));
});
});
return true;