From f0cb21dc461a4c86f1c68683dd9fac72d5ad106b Mon Sep 17 00:00:00 2001 From: Bukkit/Spigot Date: Wed, 19 Jan 2011 00:07:38 +0800 Subject: [PATCH] Address Feature#105:Implement support for PLAYER_ANIMATION hook/event. Requires corresponding CraftBukkit change. NOTE: The email address of this commit used to be: "Nathan Wolf < " This has been fixed but will cause all commits after to change. By: Nathan Wolf --- .../event/player/PlayerAnimationEvent.java | 35 +++++++++++++++++++ .../event/player/PlayerAnimationType.java | 8 +++++ .../bukkit/event/player/PlayerListener.java | 8 +++++ .../bukkit/plugin/java/JavaPluginLoader.java | 3 ++ 4 files changed, 54 insertions(+) create mode 100644 paper-api/src/main/java/org/bukkit/event/player/PlayerAnimationEvent.java create mode 100644 paper-api/src/main/java/org/bukkit/event/player/PlayerAnimationType.java diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerAnimationEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerAnimationEvent.java new file mode 100644 index 0000000000..1d860d3942 --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerAnimationEvent.java @@ -0,0 +1,35 @@ +package org.bukkit.event.player; + +import org.bukkit.entity.Player; + +/* + * Represents a player animation event + */ +public class PlayerAnimationEvent extends PlayerEvent { + + private PlayerAnimationType animationType; + + /* + * Construct a new event + * + * @param type The event type + * @param player The player instance + */ + public PlayerAnimationEvent(final Type type, final Player player) { + super(type, player); + + // Only supported animation type for now: + animationType = PlayerAnimationType.ARM_SWING; + } + + /* + * Get the type of this animation event + * + * @returns the animation type + */ + public PlayerAnimationType getAnimationType() + { + return animationType; + } + +} diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerAnimationType.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerAnimationType.java new file mode 100644 index 0000000000..5f2d7bcd4d --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerAnimationType.java @@ -0,0 +1,8 @@ +package org.bukkit.event.player; + +/* + * Differet types of player animations + */ +public enum PlayerAnimationType { + ARM_SWING +} diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerListener.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerListener.java index 08a590164d..2739f6fd76 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerListener.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerListener.java @@ -81,4 +81,12 @@ public class PlayerListener implements Listener { */ public void onPlayerEggThrow(PlayerEggThrowEvent event) { } + + /** + * Called when a player plays an animation, such as an arm swing + * + * @param event Relevant event details + */ + public void onPlayerAnimation(PlayerAnimationEvent event) { + } } diff --git a/paper-api/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java b/paper-api/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java index 99102fb950..3886027a2f 100644 --- a/paper-api/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java +++ b/paper-api/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java @@ -152,6 +152,9 @@ public final class JavaPluginLoader implements PluginLoader { case PLAYER_EGG_THROW: trueListener.onPlayerEggThrow((PlayerEggThrowEvent)event); break; + case PLAYER_ANIMATION: + trueListener.onPlayerAnimation((PlayerAnimationEvent)event); + break; } } else if (listener instanceof BlockListener) { BlockListener trueListener = (BlockListener)listener;