diff --git a/paper-api/src/main/java/org/bukkit/entity/Projectile.java b/paper-api/src/main/java/org/bukkit/entity/Projectile.java index 95666eace9..15950621ac 100644 --- a/paper-api/src/main/java/org/bukkit/entity/Projectile.java +++ b/paper-api/src/main/java/org/bukkit/entity/Projectile.java @@ -16,8 +16,21 @@ public interface Projectile extends Entity { /** * Set the shooter of this projectile * - * @param shooter - * the {@link LivingEntity} that shot this projectile + * @param shooter the {@link LivingEntity} that shot this projectile */ public void setShooter(LivingEntity shooter); + + /** + * Determine if this projectile should bounce or not when it hits. + * + * @return true if it should bounce. + */ + public boolean doesBounce(); + + /** + * Set whether or not this projectile should bounce or not when it hits something. + * + * @param doesBounce whether or not it should bounce. + */ + public void setBounce(boolean doesBounce); } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityDamageByProjectileEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityDamageByProjectileEvent.java index 760f40558e..5419b019cd 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityDamageByProjectileEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityDamageByProjectileEvent.java @@ -1,28 +1,25 @@ package org.bukkit.event.entity; -import java.util.Random; - import org.bukkit.entity.Entity; import org.bukkit.entity.Projectile; /** * Called when an entity is damaged by a projectile + * + * @deprecated use {@link EntityDamageByEntityEvent} instead, where {@link EntityDamageByEntityEvent#getDamager()} will return the {@link Projectile} */ +@Deprecated public class EntityDamageByProjectileEvent extends EntityDamageByEntityEvent { private Projectile projectile; - private boolean bounce; public EntityDamageByProjectileEvent(Entity damagee, Projectile projectile, DamageCause cause, int damage) { this(projectile.getShooter(), damagee, projectile, cause, damage); } public EntityDamageByProjectileEvent(Entity damager, Entity damagee, Projectile projectile, DamageCause cause, int damage) { - super(damager, damagee, cause, damage); + super(damager, projectile, DamageCause.PROJECTILE, damage); this.projectile = projectile; - Random random = new Random(); - - this.bounce = random.nextBoolean(); } /** @@ -35,10 +32,10 @@ public class EntityDamageByProjectileEvent extends EntityDamageByEntityEvent { } public void setBounce(boolean bounce) { - this.bounce = bounce; + projectile.setBounce(bounce); } public boolean getBounce() { - return bounce; + return projectile.doesBounce(); } } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityDamageEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityDamageEvent.java index 308fee4664..369e7abd47 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityDamageEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityDamageEvent.java @@ -77,6 +77,12 @@ public class EntityDamageEvent extends EntityEvent implements Cancellable { * Damage: variable */ ENTITY_ATTACK, + /** + * Damage caused when attacked by a projectile. + * + * Damage: variable + */ + PROJECTILE, /** * Damage caused by being put in a block *