diff --git a/paper-api/src/org/bukkit/event/block/BlockBrokenEvent.java b/paper-api/src/org/bukkit/event/block/BlockBrokenEvent.java index 6875683215..800b84d8ab 100644 --- a/paper-api/src/org/bukkit/event/block/BlockBrokenEvent.java +++ b/paper-api/src/org/bukkit/event/block/BlockBrokenEvent.java @@ -1,12 +1,13 @@ package org.bukkit.event.block; -import org.bukkit.event.Event; +import org.bukkit.Block; -public class BlockBrokenEvent extends Event { +/** + * Not implemented yet + */ +public class BlockBrokenEvent extends BlockEvent { - public BlockBrokenEvent(Type type) { - super(type); - // TODO Auto-generated constructor stub + public BlockBrokenEvent(Type type, Block block ) { + super(type, block); } - } diff --git a/paper-api/src/org/bukkit/event/block/BlockFlowEvent.java b/paper-api/src/org/bukkit/event/block/BlockFlowEvent.java new file mode 100644 index 0000000000..df126fcf3c --- /dev/null +++ b/paper-api/src/org/bukkit/event/block/BlockFlowEvent.java @@ -0,0 +1,72 @@ +package org.bukkit.event.block; + +import java.util.HashSet; +import org.bukkit.Block; +import org.bukkit.BlockFace; +import org.bukkit.event.Event; + +/** + * Holds information for events with a source block and a destination block + */ +public class BlockFlowEvent extends BlockEvent { + protected HashSet faceList; + + public BlockFlowEvent(final Event.Type type, final Block block, BlockFace... faces) { + super(type, block); + this.faceList = new HashSet(); + if (faces != null && faces.length > 0) { + for (BlockFace theFace : faces) { + faceList.add(new BlockFlow(theFace)); + } + } + } + + /** + * Gets the location this player moved to + * + * @return Block the block is event originated from + */ + public HashSet getFaces() { + return faceList; + } + + /** + * Class that represents a flow direction and whether it's cancelled + */ + public class BlockFlow { + private final BlockFace flowDirection; + private boolean cancelled; + + public BlockFlow(BlockFace flowDirection) { + this.flowDirection = flowDirection; + cancelled = false; + } + + public BlockFace getFlowDirection() { + return flowDirection; + } + + public boolean isCancelled() { + return cancelled; + } + + public void setCancelled(boolean cancel) { + cancelled = cancel; + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof BlockFlow)) return false; + return equals((BlockFlow) o); + } + + public boolean equals(BlockFlow flow) { + return flow.flowDirection.equals(flow); + } + + @Override + public int hashCode() { + return flowDirection.hashCode(); + } + } +} diff --git a/paper-api/src/org/bukkit/event/block/BlockFromToEvent.java b/paper-api/src/org/bukkit/event/block/BlockFromToEvent.java index 0b82ee776b..fc029c369e 100644 --- a/paper-api/src/org/bukkit/event/block/BlockFromToEvent.java +++ b/paper-api/src/org/bukkit/event/block/BlockFromToEvent.java @@ -23,4 +23,13 @@ public class BlockFromToEvent extends BlockEvent { public BlockFace getFace() { return face; } + + /** + * Convenience method for getting the faced block + * + * @return Block the faced block + */ + public Block getFacedBlock() { + return block.getRelative(face.getModX(), face.getModY(), face.getModZ()); + } } diff --git a/paper-api/src/org/bukkit/event/block/BlockListener.java b/paper-api/src/org/bukkit/event/block/BlockListener.java index c54b677cd1..b9dd9c8041 100644 --- a/paper-api/src/org/bukkit/event/block/BlockListener.java +++ b/paper-api/src/org/bukkit/event/block/BlockListener.java @@ -27,7 +27,7 @@ public class BlockListener implements Listener { * * @param event Relevant event details */ - public void onBlockFlow(BlockFromToEvent event) { + public void onBlockFlow(BlockFlowEvent event) { } /** @@ -54,6 +54,16 @@ public class BlockListener implements Listener { public void onBlockPlaced(BlockPlacedEvent event) { } + /** + * Called when redstone changes + * From: the source of the redstone change + * To: The redstone dust that changed + * + * @param event Relevant event details + */ + public void onBlockRedstoneChange(BlockFromToEvent event) { + } + /** * Called when a player right clicks a block * @@ -62,13 +72,4 @@ public class BlockListener implements Listener { public void onBlockRightClicked(BlockRightClickedEvent event) { } - /** - * Called when redstone changes - * From: the source of the redstone change - * To: The redstone dust that changed - * - * @param event Relevant event details - */ - public void onRedstoneChange(BlockFromToEvent event) { - } } diff --git a/paper-api/src/org/bukkit/event/block/BlockRightClickedEvent.java b/paper-api/src/org/bukkit/event/block/BlockRightClickedEvent.java index 3f8c83975e..730d68794e 100644 --- a/paper-api/src/org/bukkit/event/block/BlockRightClickedEvent.java +++ b/paper-api/src/org/bukkit/event/block/BlockRightClickedEvent.java @@ -6,8 +6,7 @@ package org.bukkit.event.block; import org.bukkit.Block; /** - * @author jmartin - * + * Not implemented yet */ public class BlockRightClickedEvent extends BlockEvent {