summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEvilSeph <evilseph@gmail.com>2011-07-28 01:17:31 -0400
committerEvilSeph <evilseph@gmail.com>2011-07-28 01:17:31 -0400
commite2e4d7f4ca1d0a3c5948304343942f11cac340a9 (patch)
treee7fc73cd4448b6baeff237abc7a55c95935399f0 /src
parent57e0a106fed3877827f8f7b7a7a61108d2645ff8 (diff)
downloadcraftbukkit-e2e4d7f4ca1d0a3c5948304343942f11cac340a9.tar
craftbukkit-e2e4d7f4ca1d0a3c5948304343942f11cac340a9.tar.gz
craftbukkit-e2e4d7f4ca1d0a3c5948304343942f11cac340a9.tar.lz
craftbukkit-e2e4d7f4ca1d0a3c5948304343942f11cac340a9.tar.xz
craftbukkit-e2e4d7f4ca1d0a3c5948304343942f11cac340a9.zip
Added PlayerVelocityEvent. Thanks Evenprime!
Diffstat (limited to 'src')
-rw-r--r--src/main/java/net/minecraft/server/EntityTrackerEntry.java23
1 files changed, 22 insertions, 1 deletions
diff --git a/src/main/java/net/minecraft/server/EntityTrackerEntry.java b/src/main/java/net/minecraft/server/EntityTrackerEntry.java
index b53db69c..20198358 100644
--- a/src/main/java/net/minecraft/server/EntityTrackerEntry.java
+++ b/src/main/java/net/minecraft/server/EntityTrackerEntry.java
@@ -127,7 +127,28 @@ public class EntityTrackerEntry {
}
if (this.tracker.velocityChanged) {
- this.b((Packet) (new Packet28EntityVelocity(this.tracker)));
+ // CraftBukkit start - create PlayerVelocity event
+ boolean cancelled = false;
+
+ if(this.tracker instanceof EntityPlayer) {
+ org.bukkit.entity.Player player = (org.bukkit.entity.Player) this.tracker.getBukkitEntity();
+ org.bukkit.util.Vector velocity = player.getVelocity();
+
+ org.bukkit.event.player.PlayerVelocityEvent event = new org.bukkit.event.player.PlayerVelocityEvent(player, velocity);
+ this.tracker.world.getServer().getPluginManager().callEvent(event);
+
+ if(event.isCancelled()) {
+ cancelled = true;
+ }
+ else if(!velocity.equals(event.getVelocity())) {
+ player.setVelocity(velocity);
+ }
+ }
+
+ if(!cancelled) {
+ this.b((Packet) (new Packet28EntityVelocity(this.tracker)));
+ }
+ // CraftBukkit end
this.tracker.velocityChanged = false;
}
}