From 71d3a3c774a2b53458456c49cf6dd2796934ef2d Mon Sep 17 00:00:00 2001 From: md_5 Date: Fri, 2 Dec 2016 09:38:47 +1100 Subject: SPIGOT-911: Add hitBlock to PorjectileHitEvent --- .../bukkit/event/entity/ProjectileHitEvent.java | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/bukkit/event/entity/ProjectileHitEvent.java b/src/main/java/org/bukkit/event/entity/ProjectileHitEvent.java index 5bcc2941..35f4148b 100644 --- a/src/main/java/org/bukkit/event/entity/ProjectileHitEvent.java +++ b/src/main/java/org/bukkit/event/entity/ProjectileHitEvent.java @@ -1,5 +1,6 @@ package org.bukkit.event.entity; +import org.bukkit.block.Block; import org.bukkit.entity.Entity; import org.bukkit.entity.Projectile; import org.bukkit.event.HandlerList; @@ -10,14 +11,24 @@ import org.bukkit.event.HandlerList; public class ProjectileHitEvent extends EntityEvent { private static final HandlerList handlers = new HandlerList(); private final Entity hitEntity; + private final Block hitBlock; public ProjectileHitEvent(final Projectile projectile) { - this(projectile, null); + this(projectile, null, null); } public ProjectileHitEvent(final Projectile projectile, Entity hitEntity) { + this(projectile, hitEntity, null); + } + + public ProjectileHitEvent(final Projectile projectile, Block hitBlock) { + this(projectile, null, hitBlock); + } + + public ProjectileHitEvent(final Projectile projectile, Entity hitEntity, Block hitBlock) { super(projectile); this.hitEntity = hitEntity; + this.hitBlock = hitBlock; } @Override @@ -25,6 +36,15 @@ public class ProjectileHitEvent extends EntityEvent { return (Projectile) entity; } + /** + * Gets the block that was hit, if it was a block that was hit. + * + * @return hit block or else null + */ + public Block getHitBlock() { + return hitBlock; + } + /** * Gets the entity that was hit, if it was an entity that was hit. * -- cgit v1.2.3