001 package org.bukkit.event.entity; 002 003 import org.bukkit.Location; 004 import org.bukkit.block.Block; 005 import org.bukkit.entity.Entity; 006 import org.bukkit.event.Cancellable; 007 import org.bukkit.event.HandlerList; 008 009 import java.util.List; 010 011 /** 012 * Called when an entity explodes 013 */ 014 public class EntityExplodeEvent extends EntityEvent implements Cancellable { 015 private static final HandlerList handlers = new HandlerList(); 016 private boolean cancel; 017 private final Location location; 018 private final List<Block> blocks; 019 private float yield; 020 021 public EntityExplodeEvent(final Entity what, final Location location, final List<Block> blocks, final float yield) { 022 super(what); 023 this.location = location; 024 this.blocks = blocks; 025 this.yield = yield; 026 this.cancel = false; 027 } 028 029 public boolean isCancelled() { 030 return cancel; 031 } 032 033 public void setCancelled(boolean cancel) { 034 this.cancel = cancel; 035 } 036 037 /** 038 * Returns the list of blocks that would have been removed or were removed 039 * from the explosion event. 040 * 041 * @return All blown-up blocks 042 */ 043 public List<Block> blockList() { 044 return blocks; 045 } 046 047 /** 048 * Returns the location where the explosion happened. 049 * <p> 050 * It is not possible to get this value from the Entity as the Entity no 051 * longer exists in the world. 052 * 053 * @return The location of the explosion 054 */ 055 public Location getLocation() { 056 return location; 057 } 058 059 /** 060 * Returns the percentage of blocks to drop from this explosion 061 * 062 * @return The yield. 063 */ 064 public float getYield() { 065 return yield; 066 } 067 068 /** 069 * Sets the percentage of blocks to drop from this explosion 070 * 071 * @param yield The new yield percentage 072 */ 073 public void setYield(float yield) { 074 this.yield = yield; 075 } 076 077 @Override 078 public HandlerList getHandlers() { 079 return handlers; 080 } 081 082 public static HandlerList getHandlerList() { 083 return handlers; 084 } 085 }