mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-02 04:56:50 +01:00
4e994669d3
Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: 6b3c598b PR-814: Add a method to send multiple equipment changes 181a984b Update Maven shade version to align with CraftBukkit a5a36e32 Revert "Update Maven shade version to align with CraftBukkit" 7a8f4a42 Update Maven shade version to align with CraftBukkit 58327201 Add support for Java 20 CraftBukkit Changes: b56426c7a PR-1142: Calculate explosion damage separately for each affected EntityComplexPart fbe3410af PR-1140: Add a method to send multiple equipment changes 8434e3633 Add support for Java 20 c998a1d23 Increase outdated build delay 4a929b5d6 SPIGOT-7267: Fix EntityType#getTranslationKey() and add unit test 086d8dc8a SPIGOT-7268: CraftMetaPotion reads ShowParticles and ShowIcon properties incorrectly 8ba5e399e SPIGOT-7262: Improve visibility API Spigot Changes: a2190e30 Rebuild patches
288 lines
11 KiB
Diff
288 lines
11 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Owen1212055 <23108066+Owen1212055@users.noreply.github.com>
|
|
Date: Sun, 5 Sep 2021 00:36:05 -0400
|
|
Subject: [PATCH] More Teleport API
|
|
|
|
|
|
diff --git a/src/main/java/io/papermc/paper/entity/LookAnchor.java b/src/main/java/io/papermc/paper/entity/LookAnchor.java
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..7713a5b7e06da185685f18e79eae2c972e588696
|
|
--- /dev/null
|
|
+++ b/src/main/java/io/papermc/paper/entity/LookAnchor.java
|
|
@@ -0,0 +1,25 @@
|
|
+package io.papermc.paper.entity;
|
|
+
|
|
+import org.bukkit.Location;
|
|
+import org.bukkit.entity.Entity;
|
|
+import org.bukkit.entity.LivingEntity;
|
|
+
|
|
+/**
|
|
+ * Represents what part of the entity should be used when determining where to face a location/entity.
|
|
+ *
|
|
+ * @see org.bukkit.entity.Player#lookAt(Location, LookAnchor)
|
|
+ * @see org.bukkit.entity.Player#lookAt(Entity, LookAnchor, LookAnchor)
|
|
+ */
|
|
+@org.jetbrains.annotations.ApiStatus.Experimental
|
|
+public enum LookAnchor {
|
|
+ /**
|
|
+ * Represents the entity's feet.
|
|
+ * @see LivingEntity#getLocation()
|
|
+ */
|
|
+ FEET,
|
|
+ /**
|
|
+ * Represents the entity's eyes.
|
|
+ * @see LivingEntity#getEyeLocation()
|
|
+ */
|
|
+ EYES;
|
|
+}
|
|
diff --git a/src/main/java/io/papermc/paper/entity/TeleportFlag.java b/src/main/java/io/papermc/paper/entity/TeleportFlag.java
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..dbacefc919fd6ed6a0f5cdaa0f695a12eda9cc3f
|
|
--- /dev/null
|
|
+++ b/src/main/java/io/papermc/paper/entity/TeleportFlag.java
|
|
@@ -0,0 +1,83 @@
|
|
+package io.papermc.paper.entity;
|
|
+
|
|
+import org.bukkit.Location;
|
|
+import org.bukkit.event.player.PlayerTeleportEvent;
|
|
+import org.jetbrains.annotations.ApiStatus;
|
|
+
|
|
+/**
|
|
+ * Represents a flag that can be set on teleportation that may
|
|
+ * slightly modify the behavior.
|
|
+ *
|
|
+ * @see EntityState
|
|
+ * @see Relative
|
|
+ */
|
|
+@ApiStatus.Experimental
|
|
+public sealed interface TeleportFlag permits TeleportFlag.EntityState, TeleportFlag.Relative {
|
|
+
|
|
+ /**
|
|
+ * Note: These flags only work on {@link org.bukkit.entity.Player} entities.
|
|
+ * <p>
|
|
+ * Represents coordinates in a teleportation that should be handled relatively.
|
|
+ * <p>
|
|
+ * Coordinates of the location that the client should handle as relative teleportation
|
|
+ * Relative teleportation flags are only used client side, and cause the player to not lose velocity in that
|
|
+ * specific coordinate. The location of the teleportation will not change.
|
|
+ *
|
|
+ * @see org.bukkit.entity.Player#teleport(Location, PlayerTeleportEvent.TeleportCause, TeleportFlag...)
|
|
+ */
|
|
+ @ApiStatus.Experimental
|
|
+ enum Relative implements TeleportFlag {
|
|
+ /**
|
|
+ * Represents the player's X coordinate
|
|
+ */
|
|
+ X,
|
|
+ /**
|
|
+ * Represents the player's Y coordinate
|
|
+ */
|
|
+ Y,
|
|
+ /**
|
|
+ * Represents the player's Z coordinate
|
|
+ */
|
|
+ Z,
|
|
+ /**
|
|
+ * Represents the player's yaw
|
|
+ */
|
|
+ YAW,
|
|
+ /**
|
|
+ * Represents the player's pitch
|
|
+ */
|
|
+ PITCH;
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * Represents flags that effect the entity's state on
|
|
+ * teleportation.
|
|
+ */
|
|
+ @ApiStatus.Experimental
|
|
+ enum EntityState implements TeleportFlag {
|
|
+ /**
|
|
+ * If all passengers should not be required to be removed prior to teleportation.
|
|
+ * <p>
|
|
+ * Note:
|
|
+ * Teleporting to a different world with this flag present while the entity has entities riding it
|
|
+ * will cause this teleportation to return false and not occur.
|
|
+ */
|
|
+ RETAIN_PASSENGERS,
|
|
+ /**
|
|
+ * If the entity should not be dismounted if they are riding another entity.
|
|
+ * <p>
|
|
+ * Note:
|
|
+ * Teleporting to a different world with this flag present while this entity is riding another entity will
|
|
+ * cause this teleportation to return false and not occur.
|
|
+ */
|
|
+ RETAIN_VEHICLE,
|
|
+ /**
|
|
+ * Indicates that a player should not have their current open inventory closed when teleporting.
|
|
+ * <p>
|
|
+ * Note:
|
|
+ * This option will be ignored when teleported to a different world.
|
|
+ */
|
|
+ RETAIN_OPEN_INVENTORY;
|
|
+ }
|
|
+
|
|
+}
|
|
diff --git a/src/main/java/org/bukkit/entity/Entity.java b/src/main/java/org/bukkit/entity/Entity.java
|
|
index b878509ff536f2d728c800a0ae6cd36802570b31..ec2adecad37c321b7852c34020dc1c61bef5dd8d 100644
|
|
--- a/src/main/java/org/bukkit/entity/Entity.java
|
|
+++ b/src/main/java/org/bukkit/entity/Entity.java
|
|
@@ -122,10 +122,34 @@ public interface Entity extends Metadatable, CommandSender, Nameable, Persistent
|
|
*
|
|
* @param yaw the yaw
|
|
* @param pitch the pitch
|
|
- * @throws UnsupportedOperationException if used for players
|
|
*/
|
|
public void setRotation(float yaw, float pitch);
|
|
|
|
+ // Paper start - Teleport API
|
|
+ /**
|
|
+ * Teleports this entity to the given location.
|
|
+ *
|
|
+ * @param location New location to teleport this entity to
|
|
+ * @param teleportFlags Flags to be used in this teleportation
|
|
+ * @return <code>true</code> if the teleport was successful
|
|
+ */
|
|
+ @org.jetbrains.annotations.ApiStatus.Experimental
|
|
+ default boolean teleport(@NotNull Location location, @NotNull io.papermc.paper.entity.TeleportFlag @NotNull... teleportFlags) {
|
|
+ return this.teleport(location, TeleportCause.PLUGIN, teleportFlags);
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * Teleports this entity to the given location.
|
|
+ *
|
|
+ * @param location New location to teleport this entity to
|
|
+ * @param cause The cause of this teleportation
|
|
+ * @param teleportFlags Flags to be used in this teleportation
|
|
+ * @return <code>true</code> if the teleport was successful
|
|
+ */
|
|
+ @org.jetbrains.annotations.ApiStatus.Experimental
|
|
+ boolean teleport(@NotNull Location location, @NotNull TeleportCause cause, @NotNull io.papermc.paper.entity.TeleportFlag @NotNull... teleportFlags);
|
|
+ // Paper end - Teleport API
|
|
+
|
|
/**
|
|
* Teleports this entity to the given location. If this entity is riding a
|
|
* vehicle, it will be dismounted prior to teleportation.
|
|
diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java
|
|
index 596af6bb00429bad7d36ea9b06573ec0aacc4cff..7b239b001288e773920195f3602b3f7103f80884 100644
|
|
--- a/src/main/java/org/bukkit/entity/Player.java
|
|
+++ b/src/main/java/org/bukkit/entity/Player.java
|
|
@@ -2762,6 +2762,49 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
|
|
String getClientBrandName();
|
|
// Paper end
|
|
|
|
+ // Paper start - Teleport API
|
|
+ /**
|
|
+ * Sets the player's rotation.
|
|
+ *
|
|
+ * @param yaw the yaw
|
|
+ * @param pitch the pitch
|
|
+ */
|
|
+ @org.jetbrains.annotations.ApiStatus.Experimental
|
|
+ void setRotation(float yaw, float pitch);
|
|
+
|
|
+ /**
|
|
+ * Causes the player to look towards the given position.
|
|
+ *
|
|
+ * @param x x coordinate
|
|
+ * @param y y coordinate
|
|
+ * @param z z coordinate
|
|
+ * @param playerAnchor What part of the player should face the given position
|
|
+ */
|
|
+ @org.jetbrains.annotations.ApiStatus.Experimental
|
|
+ void lookAt(double x, double y, double z, @NotNull io.papermc.paper.entity.LookAnchor playerAnchor);
|
|
+
|
|
+ /**
|
|
+ * Causes the player to look towards the given location.
|
|
+ *
|
|
+ * @param position Position to look at in the player's current world
|
|
+ * @param playerAnchor What part of player should face the location
|
|
+ */
|
|
+ @org.jetbrains.annotations.ApiStatus.Experimental
|
|
+ default void lookAt(@NotNull io.papermc.paper.math.Position position, @NotNull io.papermc.paper.entity.LookAnchor playerAnchor) {
|
|
+ this.lookAt(position.x(), position.y(), position.z(), playerAnchor);
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * Causes the player to look towards the given entity.
|
|
+ *
|
|
+ * @param entity Entity to look at
|
|
+ * @param playerAnchor What part of the player should face the entity
|
|
+ * @param entityAnchor What part of the entity the player should face
|
|
+ */
|
|
+ @org.jetbrains.annotations.ApiStatus.Experimental
|
|
+ void lookAt(@NotNull org.bukkit.entity.Entity entity, @NotNull io.papermc.paper.entity.LookAnchor playerAnchor, @NotNull io.papermc.paper.entity.LookAnchor entityAnchor);
|
|
+ // Paper end - Teleport API
|
|
+
|
|
@NotNull
|
|
@Override
|
|
Spigot spigot();
|
|
diff --git a/src/main/java/org/bukkit/event/player/PlayerTeleportEvent.java b/src/main/java/org/bukkit/event/player/PlayerTeleportEvent.java
|
|
index 113e620ce38bb8ff97cf24e309af59b717774b36..cc75d2e84e68a1f63ec91a909c37407a46ddb16a 100644
|
|
--- a/src/main/java/org/bukkit/event/player/PlayerTeleportEvent.java
|
|
+++ b/src/main/java/org/bukkit/event/player/PlayerTeleportEvent.java
|
|
@@ -13,8 +13,14 @@ public class PlayerTeleportEvent extends PlayerMoveEvent {
|
|
private static final HandlerList handlers = new HandlerList();
|
|
private TeleportCause cause = TeleportCause.UNKNOWN;
|
|
|
|
+ // Paper start - Teleport API
|
|
+ private boolean dismounted = true;
|
|
+ private final java.util.Set<io.papermc.paper.entity.TeleportFlag.Relative> teleportFlagSet;
|
|
+ // Paper end
|
|
+
|
|
public PlayerTeleportEvent(@NotNull final Player player, @NotNull final Location from, @Nullable final Location to) {
|
|
super(player, from, to);
|
|
+ teleportFlagSet = java.util.Collections.emptySet(); // Paper - Teleport API
|
|
}
|
|
|
|
public PlayerTeleportEvent(@NotNull final Player player, @NotNull final Location from, @Nullable final Location to, @NotNull final TeleportCause cause) {
|
|
@@ -23,6 +29,17 @@ public class PlayerTeleportEvent extends PlayerMoveEvent {
|
|
this.cause = cause;
|
|
}
|
|
|
|
+ // Paper start - Teleport API
|
|
+ @org.jetbrains.annotations.ApiStatus.Experimental
|
|
+ public PlayerTeleportEvent(@NotNull final Player player, @NotNull final Location from, @Nullable final Location to, @NotNull final TeleportCause cause, boolean dismounted, @NotNull java.util.Set<io.papermc.paper.entity.TeleportFlag.@NotNull Relative> teleportFlagSet) {
|
|
+ super(player, from, to);
|
|
+
|
|
+ this.dismounted = dismounted;
|
|
+ this.teleportFlagSet = teleportFlagSet;
|
|
+ this.cause = cause;
|
|
+ }
|
|
+ // Paper end
|
|
+
|
|
/**
|
|
* Gets the cause of this teleportation event
|
|
*
|
|
@@ -84,6 +101,30 @@ public class PlayerTeleportEvent extends PlayerMoveEvent {
|
|
UNKNOWN;
|
|
}
|
|
|
|
+ // Paper start - Teleport API
|
|
+ /**
|
|
+ * Gets if the player will be dismounted in this teleportation.
|
|
+ *
|
|
+ * @return dismounted or not
|
|
+ */
|
|
+ @org.jetbrains.annotations.ApiStatus.Experimental
|
|
+ public boolean willDismountPlayer() {
|
|
+ return this.dismounted;
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * Returns the relative teleportation flags used in this teleportation.
|
|
+ * This determines which axis the player will not lose their velocity in.
|
|
+ *
|
|
+ * @return an immutable set of relative teleportation flags
|
|
+ */
|
|
+ @org.jetbrains.annotations.ApiStatus.Experimental
|
|
+ @NotNull
|
|
+ public java.util.Set<io.papermc.paper.entity.TeleportFlag.@NotNull Relative> getRelativeTeleportationFlags() {
|
|
+ return this.teleportFlagSet;
|
|
+ }
|
|
+ // Paper end
|
|
+
|
|
@NotNull
|
|
@Override
|
|
public HandlerList getHandlers() {
|