geforkt von Mirrors/Paper
Retiring EntityDamageByProjectileEvent in favor of EntityDamageEvent.
By: sunkid <sunkid@iminurnetz.com>
Dieser Commit ist enthalten in:
Ursprung
920854a915
Commit
8054b4db89
@ -16,8 +16,21 @@ public interface Projectile extends Entity {
|
|||||||
/**
|
/**
|
||||||
* Set the shooter of this projectile
|
* Set the shooter of this projectile
|
||||||
*
|
*
|
||||||
* @param shooter
|
* @param shooter the {@link LivingEntity} that shot this projectile
|
||||||
* the {@link LivingEntity} that shot this projectile
|
|
||||||
*/
|
*/
|
||||||
public void setShooter(LivingEntity shooter);
|
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);
|
||||||
}
|
}
|
||||||
|
@ -1,28 +1,25 @@
|
|||||||
package org.bukkit.event.entity;
|
package org.bukkit.event.entity;
|
||||||
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Projectile;
|
import org.bukkit.entity.Projectile;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when an entity is damaged by a 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 {
|
public class EntityDamageByProjectileEvent extends EntityDamageByEntityEvent {
|
||||||
|
|
||||||
private Projectile projectile;
|
private Projectile projectile;
|
||||||
private boolean bounce;
|
|
||||||
|
|
||||||
public EntityDamageByProjectileEvent(Entity damagee, Projectile projectile, DamageCause cause, int damage) {
|
public EntityDamageByProjectileEvent(Entity damagee, Projectile projectile, DamageCause cause, int damage) {
|
||||||
this(projectile.getShooter(), damagee, projectile, cause, damage);
|
this(projectile.getShooter(), damagee, projectile, cause, damage);
|
||||||
}
|
}
|
||||||
|
|
||||||
public EntityDamageByProjectileEvent(Entity damager, Entity damagee, Projectile projectile, DamageCause cause, int 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;
|
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) {
|
public void setBounce(boolean bounce) {
|
||||||
this.bounce = bounce;
|
projectile.setBounce(bounce);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getBounce() {
|
public boolean getBounce() {
|
||||||
return bounce;
|
return projectile.doesBounce();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -77,6 +77,12 @@ public class EntityDamageEvent extends EntityEvent implements Cancellable {
|
|||||||
* Damage: variable
|
* Damage: variable
|
||||||
*/
|
*/
|
||||||
ENTITY_ATTACK,
|
ENTITY_ATTACK,
|
||||||
|
/**
|
||||||
|
* Damage caused when attacked by a projectile.
|
||||||
|
*
|
||||||
|
* Damage: variable
|
||||||
|
*/
|
||||||
|
PROJECTILE,
|
||||||
/**
|
/**
|
||||||
* Damage caused by being put in a block
|
* Damage caused by being put in a block
|
||||||
*
|
*
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren