From 2f476ce8f27da6f29688e712db09c2c85ef20e8f Mon Sep 17 00:00:00 2001 From: Marc Baloup Date: Mon, 14 Aug 2023 00:38:05 +0200 Subject: [PATCH] Relative teleport API in PaperOnlinePlayer --- .../lib/paper/players/PaperOnlinePlayer.java | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/players/PaperOnlinePlayer.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/players/PaperOnlinePlayer.java index 12ed444..d321473 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/players/PaperOnlinePlayer.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/players/PaperOnlinePlayer.java @@ -7,6 +7,7 @@ import fr.pandacube.lib.paper.players.PlayerNonPersistentConfig.Expiration; import fr.pandacube.lib.paper.reflect.wrapper.craftbukkit.CraftPlayer; import fr.pandacube.lib.players.standalone.AbstractOnlinePlayer; import fr.pandacube.lib.reflect.wrapper.ReflectWrapper; +import io.papermc.paper.entity.TeleportFlag.Relative; import net.kyori.adventure.text.Component; import net.kyori.adventure.title.Title; import net.kyori.adventure.title.Title.Times; @@ -294,6 +295,35 @@ public interface PaperOnlinePlayer extends PaperOffPlayer, AbstractOnlinePlayer + /* + * Relative teleport + */ + + /** + * Teleports this player to the specified relative location, using the {@link Relative} flags. + * @param relX the relative x coordinate. + * @param relY the relative y coordinate. + * @param relZ the relative z coordinate. + */ + @SuppressWarnings("UnstableApiUsage") + default void teleportRelatively(float relX, float relY, float relZ) { + getBukkitPlayer().teleport(getBukkitPlayer().getLocation().add(relX, relY, relZ), Relative.X, Relative.Y, Relative.Z, Relative.YAW, Relative.PITCH); + } + + /** + * Teleports this player to the specified location, using the {@link Relative} flags. + * @param destination the destination. + */ + @SuppressWarnings("UnstableApiUsage") + default void teleportRelatively(Location destination) { + getBukkitPlayer().teleport(destination, Relative.X, Relative.Y, Relative.Z, Relative.YAW, Relative.PITCH); + } + + + + + + /* * Player config