13
0
geforkt von Mirrors/Paper

Check for world change in MoveEvent API methods

Dieser Commit ist enthalten in:
Nassim Jahnke 2021-04-30 15:05:45 +02:00
Ursprung 306c8c7be4
Commit bad7e5b236

Datei anzeigen

@ -14,31 +14,49 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ // Paper start - PlayerMoveEvent improvements
+ /**
+ * Check if the player has changed position in the event
+ *
+ * Check if the player has changed position (even within the same block) in the event
+ *
+ * @return whether the player has changed position or not
+ */
+ public boolean hasChangedPosition() {
+ return hasExplicitlyChangedPosition() || !from.getWorld().equals(to.getWorld());
+ }
+
+ /**
+ * Check if the player has changed position (even within the same block) in the event, disregarding a possible world change
+ *
+ * @return whether the player has changed position or not
+ */
+ public boolean hasExplicitlyChangedPosition() {
+ return from.getX() != to.getX() || from.getY() != to.getY() || from.getZ() != to.getZ();
+ }
+
+ /**
+ * Check if the player has moved to a new block in the event
+ *
+ * @return whether the player has moved to a new block or not
+ */
+ public boolean hasChangedBlock() {
+ return hasExplicitlyChangedBlock() || !from.getWorld().equals(to.getWorld());
+ }
+
+ /**
+ * Check if the player has moved to a new block in the event, disregarding a possible world change
+ *
+ * @return whether the player has moved to a new block or not
+ */
+ public boolean hasExplicitlyChangedBlock() {
+ return from.getBlockX() != to.getBlockX() || from.getBlockY() != to.getBlockY() || from.getBlockZ() != to.getBlockZ();
+ }
+
+ /**
+ * Check if the player has changed orientation in the event
+ *
+ *
+ * @return whether the player has changed orientation or not
+ */
+ public boolean hasChangedOrientation() {
+ return from.getPitch() != to.getPitch() || from.getYaw() != to.getYaw();
+ }
+
+ /**
+ * Check if the player has changed to a new block in the event
+ *
+ * @return whether the player has changed block or not
+ */
+ public boolean hasChangedBlock() {
+ return from.getBlockX() != to.getBlockX() || from.getBlockY() != to.getBlockY() || from.getBlockZ() != to.getBlockZ();
+ }
+ // Paper end
+
private void validateLocation(@NotNull Location loc) {