All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.papermc.lib.features.asyncteleport.AsyncTeleportPaper Maven / Gradle / Ivy

The newest version!
package io.papermc.lib.features.asyncteleport;

import io.papermc.lib.PaperLib;
import org.bukkit.Location;
import org.bukkit.entity.Entity;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;

import java.util.concurrent.CompletableFuture;

public class AsyncTeleportPaper implements AsyncTeleport {

    @Override
    public CompletableFuture teleportAsync(Entity entity, Location location, TeleportCause cause) {
        int x = location.getBlockX() >> 4;
        int z = location.getBlockZ() >> 4;
        return PaperLib.getChunkAtAsyncUrgently(location.getWorld(), x, z, true).thenApply(chunk -> entity.teleport(location, cause));
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy