mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-16 14:33:09 +01:00
Add ProjectileCollideEvent
Deprecated now and replaced with ProjectileHitEvent
This commit is contained in:
parent
087a701e69
commit
68a47b98c6
1 changed files with 17 additions and 0 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue