Extend EntityCombustEvent to allow setting combustion duration.

Also extend with two new events that track the entity or block that caused
the combustion.

By: Andrew Ardill <andrew.ardill@gmail.com>
This commit is contained in:
Bukkit/Spigot 2011-11-29 20:50:38 +11:00
parent 3055f33fca
commit ae4cd083ac
5 changed files with 70 additions and 4 deletions

View File

@ -25,6 +25,8 @@ public interface Projectile extends Entity {
/**
* Determine if this projectile should bounce or not when it hits.
*
* If a small fireball does not bounce it will set the target on fire.
*
* @return true if it should bounce.
*/
public boolean doesBounce();

View File

@ -0,0 +1,24 @@
package org.bukkit.event.entity;
import org.bukkit.block.Block;
import org.bukkit.entity.Entity;
public class EntityCombustByBlockEvent extends EntityCombustEvent {
private Block combuster;
public EntityCombustByBlockEvent(Block combuster, Entity combustee, int duration) {
super(combustee, duration);
this.combuster = combuster;
}
/**
* The combuster can be lava or a block that is on fire.
*
* WARNING: block may be null.
* @return the Block that set the combustee alight.
*/
public Block getCombuster() {
return combuster;
}
}

View File

@ -0,0 +1,21 @@
package org.bukkit.event.entity;
import org.bukkit.entity.Entity;
public class EntityCombustByEntityEvent extends EntityCombustEvent {
private Entity combuster;
public EntityCombustByEntityEvent(Entity combuster, Entity combustee, int duration) {
super(combustee, duration);
this.combuster = combuster;
}
/**
* The combuster can be a WeatherStorm a Blaze, or an Entity holding a FIRE_ASPECT enchanted item.
* @return the Entity that set the combustee alight.
*/
public Entity getCombuster() {
return combuster;
}
}

View File

@ -4,15 +4,17 @@ import org.bukkit.entity.Entity;
import org.bukkit.event.Cancellable;
/**
* Called when an entity combusts due to the sun.
* Called when an entity combusts.
*<p />
* If an Entity Combust event is cancelled, the entity will not combust.
*/
public class EntityCombustEvent extends EntityEvent implements Cancellable {
private int duration;
private boolean cancel;
public EntityCombustEvent(Entity what) {
super(Type.ENTITY_COMBUST, what);
public EntityCombustEvent(Entity combustee, int duration) {
super(Type.ENTITY_COMBUST, combustee);
this.duration = duration;
this.cancel = false;
}
@ -23,4 +25,21 @@ public class EntityCombustEvent extends EntityEvent implements Cancellable {
public void setCancelled(boolean cancel) {
this.cancel = cancel;
}
/**
* @return the amount of time (in seconds) the combustee should be alight for
*/
public int getDuration() {
return duration;
}
/**
* The number of seconds the combustee should be alight for.
*
* This value will only ever increase the combustion time, not decrease existing combustion times.
* @param duration the time in seconds to be alight for.
*/
public void setDuration(int duration) {
this.duration = duration;
}
}

View File

@ -27,7 +27,7 @@ public class EntityListener implements Listener {
public void onItemSpawn(ItemSpawnEvent event) {}
/**
* Called when an entity combusts due to the sun.
* Called when an entity combusts.
*<p />
* If an Entity Combust event is cancelled, the entity will not combust.
*