diff options
Diffstat (limited to 'src/main/java/org/bukkit/event')
5 files changed, 97 insertions, 9 deletions
diff --git a/src/main/java/org/bukkit/event/entity/EntityDamageByBlockEvent.java b/src/main/java/org/bukkit/event/entity/EntityDamageByBlockEvent.java index a8a3eebb..c9ebdfb7 100644 --- a/src/main/java/org/bukkit/event/entity/EntityDamageByBlockEvent.java +++ b/src/main/java/org/bukkit/event/entity/EntityDamageByBlockEvent.java @@ -9,7 +9,12 @@ import org.bukkit.entity.Entity; public class EntityDamageByBlockEvent extends EntityDamageEvent { private final Block damager; + @Deprecated public EntityDamageByBlockEvent(final Block damager, final Entity damagee, final DamageCause cause, final int damage) { + this(damager, damagee, cause, (double) damage); + } + + public EntityDamageByBlockEvent(final Block damager, final Entity damagee, final DamageCause cause, final double damage) { super(damagee, cause, damage); this.damager = damager; } diff --git a/src/main/java/org/bukkit/event/entity/EntityDamageByEntityEvent.java b/src/main/java/org/bukkit/event/entity/EntityDamageByEntityEvent.java index 53d1e38d..9eb9f274 100644 --- a/src/main/java/org/bukkit/event/entity/EntityDamageByEntityEvent.java +++ b/src/main/java/org/bukkit/event/entity/EntityDamageByEntityEvent.java @@ -8,7 +8,12 @@ import org.bukkit.entity.Entity; public class EntityDamageByEntityEvent extends EntityDamageEvent { private final Entity damager; + @Deprecated public EntityDamageByEntityEvent(final Entity damager, final Entity damagee, final DamageCause cause, final int damage) { + this(damager, damagee, cause, (double) damage); + } + + public EntityDamageByEntityEvent(final Entity damager, final Entity damagee, final DamageCause cause, final double damage) { super(damagee, cause, damage); this.damager = damager; } diff --git a/src/main/java/org/bukkit/event/entity/EntityDamageEvent.java b/src/main/java/org/bukkit/event/entity/EntityDamageEvent.java index bd3d7c6d..799390bc 100644 --- a/src/main/java/org/bukkit/event/entity/EntityDamageEvent.java +++ b/src/main/java/org/bukkit/event/entity/EntityDamageEvent.java @@ -3,17 +3,23 @@ package org.bukkit.event.entity; import org.bukkit.entity.Entity; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.bukkit.util.NumberConversions; /** * Stores data for damage events */ public class EntityDamageEvent extends EntityEvent implements Cancellable { private static final HandlerList handlers = new HandlerList(); - private int damage; + private double damage; private boolean cancelled; private final DamageCause cause; + @Deprecated public EntityDamageEvent(final Entity damagee, final DamageCause cause, final int damage) { + this(damagee, cause, (double) damage); + } + + public EntityDamageEvent(final Entity damagee, final DamageCause cause, final double damage) { super(damagee); this.cause = cause; this.damage = damage; @@ -32,20 +38,40 @@ public class EntityDamageEvent extends EntityEvent implements Cancellable { * * @return The amount of damage caused by the event */ - public int getDamage() { + public double getDamage() { return damage; } /** + * This method exists for legacy reasons to provide backwards + * compatibility. It will not exist at runtime and should not be used + * under any circumstances. + */ + @Deprecated + public int _INVALID_getDamage() { + return NumberConversions.ceil(getDamage()); + } + + /** * Sets the amount of damage caused by the event * * @param damage The amount of damage caused by the event */ - public void setDamage(int damage) { + public void setDamage(double damage) { this.damage = damage; } /** + * This method exists for legacy reasons to provide backwards + * compatibility. It will not exist at runtime and should not be used + * under any circumstances. + */ + @Deprecated + public void _INVALID_setDamage(int damage) { + setDamage(damage); + } + + /** * Gets the cause of the damage. * * @return A DamageCause value detailing the cause of the damage. diff --git a/src/main/java/org/bukkit/event/entity/EntityRegainHealthEvent.java b/src/main/java/org/bukkit/event/entity/EntityRegainHealthEvent.java index 2d4c927b..d635a016 100644 --- a/src/main/java/org/bukkit/event/entity/EntityRegainHealthEvent.java +++ b/src/main/java/org/bukkit/event/entity/EntityRegainHealthEvent.java @@ -3,6 +3,7 @@ package org.bukkit.event.entity; import org.bukkit.entity.Entity; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.bukkit.util.NumberConversions; /** * Stores data for health-regain events @@ -10,10 +11,15 @@ import org.bukkit.event.HandlerList; public class EntityRegainHealthEvent extends EntityEvent implements Cancellable { private static final HandlerList handlers = new HandlerList(); private boolean cancelled; - private int amount; + private double amount; private final RegainReason regainReason; + @Deprecated public EntityRegainHealthEvent(final Entity entity, final int amount, final RegainReason regainReason) { + this(entity, (double) amount, regainReason); + } + + public EntityRegainHealthEvent(final Entity entity, final double amount, final RegainReason regainReason) { super(entity); this.amount = amount; this.regainReason = regainReason; @@ -24,19 +30,39 @@ public class EntityRegainHealthEvent extends EntityEvent implements Cancellable * * @return The amount of health regained */ - public int getAmount() { + public double getAmount() { return amount; } /** + * This method exists for legacy reasons to provide backwards + * compatibility. It will not exist at runtime and should not be used + * under any circumstances. + */ + @Deprecated + public int _INVALID_getAmount() { + return NumberConversions.ceil(getAmount()); + } + + /** * Sets the amount of regained health * * @param amount the amount of health the entity will regain */ - public void setAmount(int amount) { + public void setAmount(double amount) { this.amount = amount; } + /** + * This method exists for legacy reasons to provide backwards + * compatibility. It will not exist at runtime and should not be used + * under any circumstances. + */ + @Deprecated + public void _INVALID_setAmount(int amount) { + setAmount(amount); + } + public boolean isCancelled() { return cancelled; } diff --git a/src/main/java/org/bukkit/event/vehicle/VehicleDamageEvent.java b/src/main/java/org/bukkit/event/vehicle/VehicleDamageEvent.java index 40ffb111..304ee2cb 100644 --- a/src/main/java/org/bukkit/event/vehicle/VehicleDamageEvent.java +++ b/src/main/java/org/bukkit/event/vehicle/VehicleDamageEvent.java @@ -4,6 +4,7 @@ import org.bukkit.entity.Entity; import org.bukkit.entity.Vehicle; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.bukkit.util.NumberConversions; /** * Raised when a vehicle receives damage. @@ -11,10 +12,15 @@ import org.bukkit.event.HandlerList; public class VehicleDamageEvent extends VehicleEvent implements Cancellable { private static final HandlerList handlers = new HandlerList(); private final Entity attacker; - private int damage; + private double damage; private boolean cancelled; + @Deprecated public VehicleDamageEvent(final Vehicle vehicle, final Entity attacker, final int damage) { + this(vehicle, attacker, (double) damage); + } + + public VehicleDamageEvent(final Vehicle vehicle, final Entity attacker, final double damage) { super(vehicle); this.attacker = attacker; this.damage = damage; @@ -34,19 +40,39 @@ public class VehicleDamageEvent extends VehicleEvent implements Cancellable { * * @return the damage done to the vehicle */ - public int getDamage() { + public double getDamage() { return damage; } /** + * This method exists for legacy reasons to provide backwards + * compatibility. It will not exist at runtime and should not be used + * under any circumstances. + */ + @Deprecated + public int _INVALID_getDamage() { + return NumberConversions.ceil(getDamage()); + } + + /** * Sets the damage done to the vehicle * * @param damage The damage */ - public void setDamage(int damage) { + public void setDamage(double damage) { this.damage = damage; } + /** + * This method exists for legacy reasons to provide backwards + * compatibility. It will not exist at runtime and should not be used + * under any circumstances. + */ + @Deprecated + public void _INVALID_setDamage(int damage) { + setDamage(damage); + } + public boolean isCancelled() { return cancelled; } |