diff options
author | EvilSeph <evilseph@gmail.com> | 2011-07-28 01:17:07 -0400 |
---|---|---|
committer | EvilSeph <evilseph@gmail.com> | 2011-07-28 01:17:07 -0400 |
commit | ce36ff1cf9e37ab31d9f872692fc08525f3179d6 (patch) | |
tree | 87ca4f43c3f4054943009d5e15d01eaac2048b39 /src/main/java | |
parent | bf3af40b2d0a0f6eebb25e98f3246870b486d1c2 (diff) | |
download | bukkit-ce36ff1cf9e37ab31d9f872692fc08525f3179d6.tar bukkit-ce36ff1cf9e37ab31d9f872692fc08525f3179d6.tar.gz bukkit-ce36ff1cf9e37ab31d9f872692fc08525f3179d6.tar.lz bukkit-ce36ff1cf9e37ab31d9f872692fc08525f3179d6.tar.xz bukkit-ce36ff1cf9e37ab31d9f872692fc08525f3179d6.zip |
Added PlayerVelocityEvent. Thanks Evenprime!
Diffstat (limited to 'src/main/java')
4 files changed, 85 insertions, 0 deletions
diff --git a/src/main/java/org/bukkit/event/Event.java b/src/main/java/org/bukkit/event/Event.java index 5aa765f0..233d8214 100644 --- a/src/main/java/org/bukkit/event/Event.java +++ b/src/main/java/org/bukkit/event/Event.java @@ -198,6 +198,13 @@ public abstract class Event implements Serializable { */ PLAYER_MOVE (Category.PLAYER), /** + * Called before a player gets a velocity vector sent, which will instruct him to + * get "pushed" into a specific direction, e.g. after an explosion + * + * @see org.bukkit.event.player.PlayerVelocityEvent + */ + PLAYER_VELOCITY (Category.PLAYER), + /** * Called when a player undergoes an animation (Arm Swing is the only animation currently supported) * * @see org.bukkit.event.player.PlayerAnimationEvent diff --git a/src/main/java/org/bukkit/event/player/PlayerListener.java b/src/main/java/org/bukkit/event/player/PlayerListener.java index 54e5f042..6a5137df 100644 --- a/src/main/java/org/bukkit/event/player/PlayerListener.java +++ b/src/main/java/org/bukkit/event/player/PlayerListener.java @@ -52,6 +52,14 @@ public class PlayerListener implements Listener { public void onPlayerMove(PlayerMoveEvent event) {} /** + * Called before a player gets a velocity vector sent, which will "push" + * the player in a certain direction + * + * @param event Relevant event details + */ + public void onPlayerVelocity(PlayerVelocityEvent event) {} + + /** * Called when a player attempts to teleport to a new location in a world * * @param event Relevant event details diff --git a/src/main/java/org/bukkit/event/player/PlayerVelocityEvent.java b/src/main/java/org/bukkit/event/player/PlayerVelocityEvent.java new file mode 100644 index 00000000..f658ec05 --- /dev/null +++ b/src/main/java/org/bukkit/event/player/PlayerVelocityEvent.java @@ -0,0 +1,63 @@ +package org.bukkit.event.player;
+
+import org.bukkit.entity.Player;
+import org.bukkit.event.Cancellable;
+import org.bukkit.event.Event;
+import org.bukkit.util.Vector;
+
+public class PlayerVelocityEvent extends PlayerEvent implements Cancellable {
+
+ /**
+ * Holds information for player velocity events
+ */
+ private boolean cancel = false;
+ private Vector velocity;
+
+ public PlayerVelocityEvent(final Player player, final Vector velocity) {
+ super(Type.PLAYER_VELOCITY, player);
+ this.velocity = velocity;
+ }
+
+ PlayerVelocityEvent(final Event.Type type, final Player player, final Vector velocity) {
+ super(type, player);
+ this.velocity = velocity;
+ }
+
+ /**
+ * Gets the cancellation state of this event. A cancelled event will not
+ * be executed in the server, but will still pass to other plugins
+ *
+ * @return true if this event is cancelled
+ */
+ public boolean isCancelled() {
+ return cancel;
+ }
+
+ /**
+ * Sets the cancellation state of this event. A cancelled event will not
+ * be executed in the server, but will still pass to other plugins
+ *
+ * @param cancel true if you wish to cancel this event
+ */
+ public void setCancelled(boolean cancel) {
+ this.cancel = cancel;
+ }
+
+ /**
+ * Gets the velocity vector that will be sent to the player
+ *
+ * @return Vector the player will get
+ */
+ public Vector getVelocity() {
+ return velocity;
+ }
+
+ /**
+ * Sets the velocity vector that will be sent to the player
+ *
+ * @param velocity The velocity vector that will be sent to the player
+ */
+ public void setVelocity(Vector velocity) {
+ this.velocity = velocity;
+ }
+}
diff --git a/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java b/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java index 1bc795dd..846aeb89 100644 --- a/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java +++ b/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java @@ -287,6 +287,13 @@ public final class JavaPluginLoader implements PluginLoader { } }; + case PLAYER_VELOCITY: + return new EventExecutor() { + public void execute(Listener listener, Event event) { + ((PlayerListener) listener).onPlayerVelocity((PlayerVelocityEvent) event); + } + }; + case PLAYER_TELEPORT: return new EventExecutor() { public void execute(Listener listener, Event event) { |