From ed038ac6c8dc2fd9193d994a759ca2d1a92f2c92 Mon Sep 17 00:00:00 2001 From: Bukkit/Spigot Date: Wed, 23 Oct 2024 08:04:12 +1100 Subject: [PATCH] SPIGOT-7919: Add API to access current player input By: md_5 --- paper-api/src/main/java/org/bukkit/Input.java | 59 +++++++++++++++++++ .../main/java/org/bukkit/entity/Player.java | 13 ++++ 2 files changed, 72 insertions(+) create mode 100644 paper-api/src/main/java/org/bukkit/Input.java diff --git a/paper-api/src/main/java/org/bukkit/Input.java b/paper-api/src/main/java/org/bukkit/Input.java new file mode 100644 index 0000000000..7665b18e32 --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/Input.java @@ -0,0 +1,59 @@ +package org.bukkit; + +import org.jetbrains.annotations.ApiStatus; + +/** + * Represents a movement input applied to an entity. + */ +@ApiStatus.Experimental +public interface Input { + + /** + * Gets whether a forward input is applied. + * + * @return forward input + */ + boolean isForward(); + + /** + * Gets whether a backward input is applied. + * + * @return backward input + */ + boolean isBackward(); + + /** + * Gets whether a left input is applied. + * + * @return left input + */ + boolean isLeft(); + + /** + * Gets whether a right input is applied. + * + * @return right input + */ + boolean isRight(); + + /** + * Gets whether a jump input is applied. + * + * @return jump input + */ + boolean isJump(); + + /** + * Gets whether a sneak input is applied. + * + * @return sneak input + */ + boolean isSneak(); + + /** + * Gets whether a sprint input is applied. + * + * @return sprint input + */ + boolean isSprint(); +} diff --git a/paper-api/src/main/java/org/bukkit/entity/Player.java b/paper-api/src/main/java/org/bukkit/entity/Player.java index 18bc9c1c90..3046ffe7b1 100644 --- a/paper-api/src/main/java/org/bukkit/entity/Player.java +++ b/paper-api/src/main/java/org/bukkit/entity/Player.java @@ -13,6 +13,7 @@ import org.bukkit.BanEntry; import org.bukkit.DyeColor; import org.bukkit.Effect; import org.bukkit.GameMode; +import org.bukkit.Input; import org.bukkit.Instrument; import org.bukkit.Location; import org.bukkit.Material; @@ -503,6 +504,18 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM @ApiStatus.Experimental public Collection getEnderPearls(); + /** + * Gets the current movement input, as last provided by the player. + *
+ * Note: that this may not always be consistent with the current movement + * of the player. + * + * @return current input + */ + @NotNull + @ApiStatus.Experimental + public Input getCurrentInput(); + /** * Play a note for the player at a location.
* This will work with cake.