[Bleeding] Changed event system into a new, much faster design. Huge thanks to @zml2008 & @lahwran.

By: Nathan Adams <dinnerbone@dinnerbone.com>
This commit is contained in:
Bukkit/Spigot
2012-01-16 18:25:17 +00:00
parent 94bc6ec0e6
commit e0c7fc6bf5
132 changed files with 1691 additions and 225 deletions

View File

@@ -3,6 +3,7 @@ package org.bukkit.event.block;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
/**
* Called when a block is broken by a player.
@@ -16,6 +17,7 @@ import org.bukkit.event.Cancellable;
@SuppressWarnings("serial")
public class BlockBreakEvent extends BlockEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private Player player;
private boolean cancel;
@@ -41,4 +43,13 @@ public class BlockBreakEvent extends BlockEvent implements Cancellable {
public void setCancelled(boolean cancel) {
this.cancel = cancel;
}
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
}

View File

@@ -2,6 +2,7 @@ package org.bukkit.event.block;
import org.bukkit.block.Block;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
/**
* Called when a block is destroyed as a result of being burnt by fire.
@@ -10,6 +11,7 @@ import org.bukkit.event.Cancellable;
*/
@SuppressWarnings("serial")
public class BlockBurnEvent extends BlockEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private boolean cancelled;
public BlockBurnEvent(Block block) {
@@ -24,4 +26,13 @@ public class BlockBurnEvent extends BlockEvent implements Cancellable {
public void setCancelled(boolean cancel) {
this.cancelled = cancel;
}
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
}

View File

@@ -2,6 +2,7 @@ package org.bukkit.event.block;
import org.bukkit.block.Block;
import org.bukkit.Material;
import org.bukkit.event.HandlerList;
/**
* Called when we try to place a block, to see if we can build it here or not.
@@ -14,6 +15,7 @@ import org.bukkit.Material;
*/
@SuppressWarnings("serial")
public class BlockCanBuildEvent extends BlockEvent {
private static final HandlerList handlers = new HandlerList();
protected boolean buildable;
protected int material;
@@ -59,4 +61,13 @@ public class BlockCanBuildEvent extends BlockEvent {
public int getMaterialId() {
return material;
}
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
}

View File

@@ -3,6 +3,7 @@ package org.bukkit.event.block;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.bukkit.inventory.ItemStack;
/**
@@ -12,6 +13,7 @@ import org.bukkit.inventory.ItemStack;
*/
@SuppressWarnings("serial")
public class BlockDamageEvent extends BlockEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private Player player;
private boolean instaBreak;
private boolean cancel;
@@ -68,4 +70,13 @@ public class BlockDamageEvent extends BlockEvent implements Cancellable {
public void setCancelled(boolean cancel) {
this.cancel = cancel;
}
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
}

View File

@@ -2,6 +2,7 @@ package org.bukkit.event.block;
import org.bukkit.block.Block;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector;
@@ -12,6 +13,7 @@ import org.bukkit.util.Vector;
*/
@SuppressWarnings("serial")
public class BlockDispenseEvent extends BlockEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private boolean cancelled = false;
private ItemStack item;
@@ -69,4 +71,13 @@ public class BlockDispenseEvent extends BlockEvent implements Cancellable {
public void setCancelled(boolean cancel) {
cancelled = cancel;
}
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
}

View File

@@ -7,7 +7,7 @@ import org.bukkit.event.Event;
* Represents a block related event.
*/
@SuppressWarnings("serial")
public class BlockEvent extends Event {
public abstract class BlockEvent extends Event {
protected Block block;
public BlockEvent(final Event.Type type, final Block theBlock) {

View File

@@ -3,6 +3,7 @@ package org.bukkit.event.block;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
/**
* Called when a block fades, melts or disappears based on world conditions
@@ -17,6 +18,7 @@ import org.bukkit.event.Cancellable;
*/
@SuppressWarnings("serial")
public class BlockFadeEvent extends BlockEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private boolean cancelled;
private BlockState newState;
@@ -42,4 +44,13 @@ public class BlockFadeEvent extends BlockEvent implements Cancellable {
public void setCancelled(boolean cancel) {
this.cancelled = cancel;
}
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
}

View File

@@ -3,6 +3,7 @@ package org.bukkit.event.block;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
/**
* Called when a block is formed or spreads based on world conditions.
@@ -20,6 +21,7 @@ import org.bukkit.event.Cancellable;
*/
@SuppressWarnings("serial")
public class BlockFormEvent extends BlockEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private boolean cancelled;
private BlockState newState;
@@ -53,4 +55,13 @@ public class BlockFormEvent extends BlockEvent implements Cancellable {
public void setCancelled(boolean cancel) {
this.cancelled = cancel;
}
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
}

View File

@@ -3,6 +3,7 @@ package org.bukkit.event.block;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
/**
* Represents events with a source block and a destination block, currently only applies to liquid (lava and water).
@@ -11,6 +12,7 @@ import org.bukkit.event.Cancellable;
*/
@SuppressWarnings("serial")
public class BlockFromToEvent extends BlockEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
protected Block to;
protected BlockFace face;
protected boolean cancel;
@@ -49,4 +51,13 @@ public class BlockFromToEvent extends BlockEvent implements Cancellable {
public void setCancelled(boolean cancel) {
this.cancel = cancel;
}
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
}

View File

@@ -4,6 +4,7 @@ import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
/**
* Called when a block is ignited. If you want to catch when a Player places fire, you need to use {@link BlockPlaceEvent}.
@@ -12,6 +13,7 @@ import org.bukkit.event.Event;
*/
@SuppressWarnings("serial")
public class BlockIgniteEvent extends BlockEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private IgniteCause cause;
private boolean cancel;
private Player thePlayer;
@@ -71,4 +73,13 @@ public class BlockIgniteEvent extends BlockEvent implements Cancellable {
*/
LIGHTNING,
}
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
}

View File

@@ -5,6 +5,7 @@ import org.bukkit.event.Listener;
/**
* Handles all events thrown in relation to Blocks
*/
@Deprecated
public class BlockListener implements Listener {
/**

View File

@@ -3,12 +3,14 @@ package org.bukkit.event.block;
import org.bukkit.block.Block;
import org.bukkit.Material;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
/**
* Thrown when a block physics check is called
*/
@SuppressWarnings("serial")
public class BlockPhysicsEvent extends BlockEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private final int changed;
private boolean cancel = false;
@@ -42,4 +44,13 @@ public class BlockPhysicsEvent extends BlockEvent implements Cancellable {
public void setCancelled(boolean cancel) {
this.cancel = cancel;
}
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
}

View File

@@ -6,9 +6,11 @@ import java.util.List;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.event.HandlerList;
@SuppressWarnings("serial")
public class BlockPistonExtendEvent extends BlockPistonEvent {
private static final HandlerList handlers = new HandlerList();
private int length;
private List<Block> blocks;
@@ -42,4 +44,13 @@ public class BlockPistonExtendEvent extends BlockPistonEvent {
}
return blocks;
}
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
}

View File

@@ -3,9 +3,11 @@ package org.bukkit.event.block;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.event.HandlerList;
@SuppressWarnings("serial")
public class BlockPistonRetractEvent extends BlockPistonEvent {
private static final HandlerList handlers = new HandlerList();
public BlockPistonRetractEvent(Block block, BlockFace direction) {
super(Type.BLOCK_PISTON_RETRACT, block, direction);
}
@@ -19,4 +21,13 @@ public class BlockPistonRetractEvent extends BlockPistonEvent {
public Location getRetractLocation() {
return getBlock().getRelative(getDirection(), 2).getLocation();
}
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
}

View File

@@ -4,6 +4,7 @@ import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.bukkit.inventory.ItemStack;
/**
@@ -13,6 +14,7 @@ import org.bukkit.inventory.ItemStack;
*/
@SuppressWarnings("serial")
public class BlockPlaceEvent extends BlockEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
protected boolean cancel;
protected boolean canBuild;
protected Block placedAgainst;
@@ -106,4 +108,13 @@ public class BlockPlaceEvent extends BlockEvent implements Cancellable {
public void setBuild(boolean canBuild) {
this.canBuild = canBuild;
}
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
}

View File

@@ -1,12 +1,14 @@
package org.bukkit.event.block;
import org.bukkit.block.Block;
import org.bukkit.event.HandlerList;
/**
* Called when a redstone current changes
*/
@SuppressWarnings("serial")
public class BlockRedstoneEvent extends BlockEvent {
private static final HandlerList handlers = new HandlerList();
private int oldCurrent;
private int newCurrent;
@@ -42,4 +44,13 @@ public class BlockRedstoneEvent extends BlockEvent {
public void setNewCurrent(int newCurrent) {
this.newCurrent = newCurrent;
}
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
}

View File

@@ -2,6 +2,7 @@ package org.bukkit.event.block;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.event.HandlerList;
/**
* Called when a block spreads based on world conditions.
@@ -19,6 +20,7 @@ import org.bukkit.block.BlockState;
*/
@SuppressWarnings("serial")
public class BlockSpreadEvent extends BlockFormEvent {
private static final HandlerList handlers = new HandlerList();
private Block source;
public BlockSpreadEvent(Block block, Block source, BlockState newState) {
@@ -34,4 +36,13 @@ public class BlockSpreadEvent extends BlockFormEvent {
public Block getSource() {
return source;
}
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
}

View File

@@ -2,6 +2,7 @@ package org.bukkit.event.block;
import org.bukkit.block.Block;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
/**
* Called when leaves are decaying naturally.
@@ -10,6 +11,7 @@ import org.bukkit.event.Cancellable;
*/
@SuppressWarnings("serial")
public class LeavesDecayEvent extends BlockEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private boolean cancel = false;
public LeavesDecayEvent(final Block block) {
@@ -23,4 +25,13 @@ public class LeavesDecayEvent extends BlockEvent implements Cancellable {
public void setCancelled(boolean cancel) {
this.cancel = cancel;
}
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
}

View File

@@ -3,6 +3,7 @@ package org.bukkit.event.block;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
/**
* Called when a sign is changed by a player.
@@ -11,6 +12,7 @@ import org.bukkit.event.Cancellable;
*/
@SuppressWarnings("serial")
public class SignChangeEvent extends BlockEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private boolean cancel = false;
private Player player;
private String[] lines;
@@ -68,4 +70,13 @@ public class SignChangeEvent extends BlockEvent implements Cancellable {
public void setCancelled(boolean cancel) {
this.cancel = cancel;
}
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
}