Add ProjectileCollideEvent

Deprecated now and replaced with ProjectileHitEvent
This commit is contained in:
Techcable 2016-12-16 21:25:39 -06:00
parent 087a701e69
commit 68a47b98c6

View file

@ -1321,6 +1321,16 @@ public class CraftEventFactory {
Bukkit.getPluginManager().callEvent(crafterCraftEvent);
return crafterCraftEvent;
}
// Paper start
@Deprecated
public static com.destroystokyo.paper.event.entity.ProjectileCollideEvent callProjectileCollideEvent(Entity entity, EntityHitResult position) {
Projectile projectile = (Projectile) entity.getBukkitEntity();
org.bukkit.entity.Entity collided = position.getEntity().getBukkitEntity();
com.destroystokyo.paper.event.entity.ProjectileCollideEvent event = new com.destroystokyo.paper.event.entity.ProjectileCollideEvent(projectile, collided);
Bukkit.getPluginManager().callEvent(event);
return event;
}
// Paper end
public static ProjectileLaunchEvent callProjectileLaunchEvent(Entity entity) {
Projectile bukkitEntity = (Projectile) entity.getBukkitEntity();
@ -1346,8 +1356,15 @@ public class CraftEventFactory {
if (position.getType() == HitResult.Type.ENTITY) {
hitEntity = ((EntityHitResult) position).getEntity().getBukkitEntity();
}
// Paper start - legacy event
boolean cancelled = false;
if (hitEntity != null && position instanceof EntityHitResult entityHitResult) {
cancelled = callProjectileCollideEvent(entity, entityHitResult).isCancelled();
}
// Paper end
ProjectileHitEvent event = new ProjectileHitEvent((Projectile) entity.getBukkitEntity(), hitEntity, hitBlock, hitFace);
event.setCancelled(cancelled); // Paper - propagate legacy event cancellation to modern event
entity.level().getCraftServer().getPluginManager().callEvent(event);
return event;
}