SPIGOT-2348: EntityTeleportEvent cancellation

This commit is contained in:
md_5 2016-06-12 12:51:53 +10:00
parent 1f507256e7
commit ac58f3840e

View file

@ -580,22 +580,25 @@
if (itemstack != null && itemstack.count == 0) { if (itemstack != null && itemstack.count == 0) {
itemstack = null; itemstack = null;
@@ -2051,7 +2332,17 @@ @@ -2051,10 +2332,18 @@
} }
if (flag1) { if (flag1) {
- this.enderTeleportTo(this.locX, this.locY, this.locZ); - this.enderTeleportTo(this.locX, this.locY, this.locZ);
- if (world.getCubes(this, this.getBoundingBox()).isEmpty() && !world.containsLiquid(this.getBoundingBox())) {
- flag = true;
+ // CraftBukkit start - Teleport event + // CraftBukkit start - Teleport event
+ // this.enderTeleportTo(this.locX, this.locY, this.locZ); + // this.enderTeleportTo(this.locX, this.locY, this.locZ);
+ EntityTeleportEvent teleport = new EntityTeleportEvent(this.getBukkitEntity(), new Location(this.world.getWorld(), d3, d4, d5), new Location(this.world.getWorld(), this.locX, this.locY, this.locZ)); + EntityTeleportEvent teleport = new EntityTeleportEvent(this.getBukkitEntity(), new Location(this.world.getWorld(), d3, d4, d5), new Location(this.world.getWorld(), this.locX, this.locY, this.locZ));
+ this.world.getServer().getPluginManager().callEvent(teleport); + this.world.getServer().getPluginManager().callEvent(teleport);
+ if (teleport.isCancelled()) { + if (!teleport.isCancelled()) {
+ return false; + Location to = teleport.getTo();
+ } + this.enderTeleportTo(to.getX(), to.getY(), to.getZ());
+ + if (world.getCubes(this, this.getBoundingBox()).isEmpty() && !world.containsLiquid(this.getBoundingBox())) {
+ Location to = teleport.getTo(); + flag = true;
+ this.enderTeleportTo(to.getX(), to.getY(), to.getZ()); + }
+ // CraftBukkit end
if (world.getCubes(this, this.getBoundingBox()).isEmpty() && !world.containsLiquid(this.getBoundingBox())) {
flag = true;
} }
+ // CraftBukkit end
}
}