geforkt von Mirrors/Paper
Prevent VehicleEnterEvent being sent when player exits vehicle.
Fix for BUKKIT-223. Issue BUKKIT-223: When a player exits a minecart or boat, both a VehicleExitEvent and a VehicleEnterEvent are fired. Only the VehicleExitEvent should fire. Reason for bug: This occurs because the VehicleEnterEvent is fired in EntityBoat.b and EntityMinecart.b *any* time a player right-clicks on a vehicle, whether the right-click is to enter the vehicle or exit it. Fix: By moving the creation of VehicleEnterEvents from EntityBoat.b and EntityMinecart.b to Entity.setPassengerOf, we can create either a VehicleEnterEvent or a VehicleExitEvent, depending on whether the player is entering or exiting a vehicle.
Dieser Commit ist enthalten in:
Ursprung
2c72f9f5af
Commit
a7744ac751
@ -14,6 +14,7 @@ import org.bukkit.event.entity.EntityCombustByBlockEvent;
|
|||||||
import org.bukkit.event.entity.EntityCombustByEntityEvent;
|
import org.bukkit.event.entity.EntityCombustByEntityEvent;
|
||||||
import org.bukkit.event.painting.PaintingBreakByEntityEvent;
|
import org.bukkit.event.painting.PaintingBreakByEntityEvent;
|
||||||
import org.bukkit.event.vehicle.VehicleBlockCollisionEvent;
|
import org.bukkit.event.vehicle.VehicleBlockCollisionEvent;
|
||||||
|
import org.bukkit.event.vehicle.VehicleEnterEvent;
|
||||||
import org.bukkit.event.vehicle.VehicleExitEvent;
|
import org.bukkit.event.vehicle.VehicleExitEvent;
|
||||||
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
||||||
import org.bukkit.event.entity.EntityCombustEvent;
|
import org.bukkit.event.entity.EntityCombustEvent;
|
||||||
@ -1228,6 +1229,17 @@ public abstract class Entity {
|
|||||||
this.vehicle = null;
|
this.vehicle = null;
|
||||||
this.setPositionRotation(entity.locX, entity.boundingBox.b + (double) entity.length, entity.locZ, this.yaw, this.pitch);
|
this.setPositionRotation(entity.locX, entity.boundingBox.b + (double) entity.length, entity.locZ, this.yaw, this.pitch);
|
||||||
} else {
|
} else {
|
||||||
|
// CraftBukkit start
|
||||||
|
if ((this.getBukkitEntity() instanceof LivingEntity) && (entity != null) && (entity.getBukkitEntity() instanceof Vehicle)) {
|
||||||
|
VehicleEnterEvent event = new VehicleEnterEvent((Vehicle) entity.getBukkitEntity(), (LivingEntity) this.getBukkitEntity());
|
||||||
|
this.world.getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
|
if (event.isCancelled()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// CraftBukkit end
|
||||||
|
|
||||||
if (this.vehicle != null) {
|
if (this.vehicle != null) {
|
||||||
this.vehicle.passenger = null;
|
this.vehicle.passenger = null;
|
||||||
}
|
}
|
||||||
|
@ -420,15 +420,6 @@ public class EntityBoat extends Entity {
|
|||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
if (!this.world.isStatic) {
|
if (!this.world.isStatic) {
|
||||||
// CraftBukkit start
|
|
||||||
VehicleEnterEvent event = new VehicleEnterEvent((Vehicle) this.getBukkitEntity(), entityhuman.getBukkitEntity());
|
|
||||||
this.world.getServer().getPluginManager().callEvent(event);
|
|
||||||
|
|
||||||
if (event.isCancelled()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
// CraftBukkit end
|
|
||||||
|
|
||||||
entityhuman.mount(this);
|
entityhuman.mount(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -725,15 +725,8 @@ public class EntityMinecart extends Entity implements IInventory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (entity instanceof EntityLiving && !(entity instanceof EntityHuman) && this.type == 0 && this.motX * this.motX + this.motZ * this.motZ > 0.01D && this.passenger == null && entity.vehicle == null) {
|
if (entity instanceof EntityLiving && !(entity instanceof EntityHuman) && this.type == 0 && this.motX * this.motX + this.motZ * this.motZ > 0.01D && this.passenger == null && entity.vehicle == null) {
|
||||||
if (!collisionEvent.isPickupCancelled()) {
|
|
||||||
VehicleEnterEvent enterEvent = new VehicleEnterEvent(vehicle, hitEntity);
|
|
||||||
this.world.getServer().getPluginManager().callEvent(enterEvent);
|
|
||||||
|
|
||||||
if (!enterEvent.isCancelled()) {
|
|
||||||
entity.mount(this);
|
entity.mount(this);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
// CraftBukkit end
|
// CraftBukkit end
|
||||||
|
|
||||||
double d0 = entity.locX - this.locX;
|
double d0 = entity.locX - this.locX;
|
||||||
@ -857,17 +850,6 @@ public class EntityMinecart extends Entity implements IInventory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!this.world.isStatic) {
|
if (!this.world.isStatic) {
|
||||||
// CraftBukkit start
|
|
||||||
org.bukkit.entity.Entity player = (entityhuman == null) ? null : entityhuman.getBukkitEntity();
|
|
||||||
|
|
||||||
VehicleEnterEvent event = new VehicleEnterEvent((Vehicle) this.getBukkitEntity(), player);
|
|
||||||
this.world.getServer().getPluginManager().callEvent(event);
|
|
||||||
|
|
||||||
if (event.isCancelled()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
// CraftBukkit end
|
|
||||||
|
|
||||||
entityhuman.mount(this);
|
entityhuman.mount(this);
|
||||||
}
|
}
|
||||||
} else if (this.type == 1) {
|
} else if (this.type == 1) {
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren