From 8e7ef46f6fe990405e570a1aa19da378cab44f43 Mon Sep 17 00:00:00 2001 From: Bukkit/Spigot Date: Tue, 14 Jun 2011 10:55:47 -0700 Subject: [PATCH] Added the concept of an Explosive. By: sunkid --- .../java/org/bukkit/entity/Explosive.java | 30 +++++++++++++++++++ .../main/java/org/bukkit/entity/Fireball.java | 4 +-- .../java/org/bukkit/entity/TNTPrimed.java | 20 ++++++++----- .../event/entity/ExplosionPrimeEvent.java | 5 ++++ 4 files changed, 49 insertions(+), 10 deletions(-) create mode 100644 paper-api/src/main/java/org/bukkit/entity/Explosive.java diff --git a/paper-api/src/main/java/org/bukkit/entity/Explosive.java b/paper-api/src/main/java/org/bukkit/entity/Explosive.java new file mode 100644 index 0000000000..f140f31684 --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/entity/Explosive.java @@ -0,0 +1,30 @@ +package org.bukkit.entity; + +/** + * A representation of an explosive entity + */ +public interface Explosive extends Entity { + /** + * Set the radius affected by this explosive's explosion + * @param yield + */ + public void setYield(float yield); + + /** + * Return the radius or yield of this explosive's explosion + * @return the radius of blocks affected + */ + public float getYield(); + + /** + * Set whether or not this explosive's explosion causes fire + * @param isIncendiary + */ + public void setIsIncendiary(boolean isIncendiary); + + /** + * Return whether or not this explosive creates a fire when exploding + * @return true if the explosive creates fire, false otherwise + */ + public boolean isIncendiary(); +} diff --git a/paper-api/src/main/java/org/bukkit/entity/Fireball.java b/paper-api/src/main/java/org/bukkit/entity/Fireball.java index a149fb856a..20e68fc882 100644 --- a/paper-api/src/main/java/org/bukkit/entity/Fireball.java +++ b/paper-api/src/main/java/org/bukkit/entity/Fireball.java @@ -2,7 +2,5 @@ package org.bukkit.entity; /** * Represents a Fireball. - * - * @author Cogito */ -public interface Fireball extends Entity {} +public interface Fireball extends Explosive {} diff --git a/paper-api/src/main/java/org/bukkit/entity/TNTPrimed.java b/paper-api/src/main/java/org/bukkit/entity/TNTPrimed.java index 989c4e5710..e1a7bae67c 100644 --- a/paper-api/src/main/java/org/bukkit/entity/TNTPrimed.java +++ b/paper-api/src/main/java/org/bukkit/entity/TNTPrimed.java @@ -1,12 +1,18 @@ -/** - * - */ package org.bukkit.entity; /** * Represents a Primed TNT. - * - * @author Cogito - * */ -public interface TNTPrimed extends Entity {} +public interface TNTPrimed extends Explosive { + /** + * Set the number of ticks until the TNT blows up after being primed. + * @param fuseTicks + */ + public void setFuseTicks(int fuseTicks); + + /** + * Retrieve the number of ticks until the explosion of this TNTPrimed entity + * @return the number of ticks until this TNTPrimed explodes + */ + public int getFuseTicks(); +} diff --git a/paper-api/src/main/java/org/bukkit/event/entity/ExplosionPrimeEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/ExplosionPrimeEvent.java index 630623b6e9..55c9f64cda 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/ExplosionPrimeEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/ExplosionPrimeEvent.java @@ -1,6 +1,7 @@ package org.bukkit.event.entity; import org.bukkit.entity.Entity; +import org.bukkit.entity.Explosive; import org.bukkit.event.Cancellable; public class ExplosionPrimeEvent extends EntityEvent implements Cancellable { @@ -15,6 +16,10 @@ public class ExplosionPrimeEvent extends EntityEvent implements Cancellable { this.fire = fire; } + public ExplosionPrimeEvent(Explosive explosive) { + this(explosive, explosive.getYield(), explosive.isIncendiary()); + } + public boolean isCancelled() { return cancel; }