13
0
geforkt von Mirrors/Paper

Add block or entity causes to BlockIgniteEvent. Addresses BUKKIT-3609, BUKKIT-3656, BUKKIT-3657

By: Yariv Livay <yarivlivay@gmail.com>
Dieser Commit ist enthalten in:
Bukkit/Spigot 2013-03-17 22:27:52 +02:00
Ursprung 3f028f3d35
Commit 97b686dc3b

Datei anzeigen

@ -1,6 +1,7 @@
package org.bukkit.event.block; package org.bukkit.event.block;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable; import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
@ -13,13 +14,31 @@ import org.bukkit.event.HandlerList;
public class BlockIgniteEvent extends BlockEvent implements Cancellable { public class BlockIgniteEvent extends BlockEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList(); private static final HandlerList handlers = new HandlerList();
private final IgniteCause cause; private final IgniteCause cause;
private final Entity ignitingEntity;
private final Block ignitingBlock;
private boolean cancel; private boolean cancel;
private final Player thePlayer;
/**
* Deprecated. Use {@link BlockIgniteEvent#BlockIgniteEvent(Block, IgniteCause, Entity)} instead.
*/
@Deprecated
public BlockIgniteEvent(final Block theBlock, final IgniteCause cause, final Player thePlayer) { public BlockIgniteEvent(final Block theBlock, final IgniteCause cause, final Player thePlayer) {
this(theBlock, cause, (Entity) thePlayer);
}
public BlockIgniteEvent(final Block theBlock, final IgniteCause cause, final Entity ignitingEntity) {
this(theBlock, cause, ignitingEntity, null);
}
public BlockIgniteEvent(final Block theBlock, final IgniteCause cause, final Block ignitingBlock) {
this(theBlock, cause, null, ignitingBlock);
}
public BlockIgniteEvent(final Block theBlock, final IgniteCause cause, final Entity ignitingEntity, final Block ignitingBlock) {
super(theBlock); super(theBlock);
this.cause = cause; this.cause = cause;
this.thePlayer = thePlayer; this.ignitingEntity = ignitingEntity;
this.ignitingBlock = ignitingBlock;
this.cancel = false; this.cancel = false;
} }
@ -43,10 +62,32 @@ public class BlockIgniteEvent extends BlockEvent implements Cancellable {
/** /**
* Gets the player who ignited this block * Gets the player who ignited this block
* *
* @return The Player who placed the fire block, if not ignited by a player returns null * @return The Player that placed/ignited the fire block, or null if not ignited by a Player.
*/ */
public Player getPlayer() { public Player getPlayer() {
return thePlayer; if (ignitingEntity instanceof Player) {
return (Player) ignitingEntity;
}
return null;
}
/**
* Gets the entity who ignited this block
*
* @return The Entity that placed/ignited the fire block, or null if not ignited by a Entity.
*/
public Entity getIgnitingEntity() {
return ignitingEntity;
}
/**
* Gets the block who ignited this block
*
* @return The Block that placed/ignited the fire block, or null if not ignited by a Block.
*/
public Block getIgnitingBlock() {
return ignitingBlock;
} }
/** /**
@ -59,7 +100,7 @@ public class BlockIgniteEvent extends BlockEvent implements Cancellable {
*/ */
LAVA, LAVA,
/** /**
* Block ignition caused by a player using flint-and-steel. * Block ignition caused by a player or dispenser using flint-and-steel.
*/ */
FLINT_AND_STEEL, FLINT_AND_STEEL,
/** /**
@ -74,6 +115,14 @@ public class BlockIgniteEvent extends BlockEvent implements Cancellable {
* Block ignition caused by an entity using a fireball. * Block ignition caused by an entity using a fireball.
*/ */
FIREBALL, FIREBALL,
/**
* Block ignition caused by an Ender Crystal.
*/
ENDER_CRYSTAL,
/**
* Block ignition caused by explosion.
*/
EXPLOSION,
} }
@Override @Override