From e2e4d7f4ca1d0a3c5948304343942f11cac340a9 Mon Sep 17 00:00:00 2001 From: EvilSeph Date: Thu, 28 Jul 2011 01:17:31 -0400 Subject: [PATCH] Added PlayerVelocityEvent. Thanks Evenprime! --- .../minecraft/server/EntityTrackerEntry.java | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/minecraft/server/EntityTrackerEntry.java b/src/main/java/net/minecraft/server/EntityTrackerEntry.java index b53db69c12..2019835838 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; } }