summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/org/bukkit/event/block/BlockBrokenEvent.java13
-rw-r--r--src/org/bukkit/event/block/BlockFlowEvent.java72
-rw-r--r--src/org/bukkit/event/block/BlockFromToEvent.java9
-rw-r--r--src/org/bukkit/event/block/BlockListener.java17
-rw-r--r--src/org/bukkit/event/block/BlockRightClickedEvent.java3
5 files changed, 98 insertions, 16 deletions
diff --git a/src/org/bukkit/event/block/BlockBrokenEvent.java b/src/org/bukkit/event/block/BlockBrokenEvent.java
index 68756832..800b84d8 100644
--- a/src/org/bukkit/event/block/BlockBrokenEvent.java
+++ b/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/src/org/bukkit/event/block/BlockFlowEvent.java b/src/org/bukkit/event/block/BlockFlowEvent.java
new file mode 100644
index 00000000..df126fcf
--- /dev/null
+++ b/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<BlockFlow> faceList;
+
+ public BlockFlowEvent(final Event.Type type, final Block block, BlockFace... faces) {
+ super(type, block);
+ this.faceList = new HashSet<BlockFlow>();
+ 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<BlockFlow> 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/src/org/bukkit/event/block/BlockFromToEvent.java b/src/org/bukkit/event/block/BlockFromToEvent.java
index 0b82ee77..fc029c36 100644
--- a/src/org/bukkit/event/block/BlockFromToEvent.java
+++ b/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/src/org/bukkit/event/block/BlockListener.java b/src/org/bukkit/event/block/BlockListener.java
index c54b677c..b9dd9c80 100644
--- a/src/org/bukkit/event/block/BlockListener.java
+++ b/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) {
}
/**
@@ -55,20 +55,21 @@ public class BlockListener implements Listener {
}
/**
- * Called when a player right clicks a block
+ * Called when redstone changes
+ * From: the source of the redstone change
+ * To: The redstone dust that changed
*
* @param event Relevant event details
*/
- public void onBlockRightClicked(BlockRightClickedEvent event) {
+ public void onBlockRedstoneChange(BlockFromToEvent event) {
}
-
+
/**
- * Called when redstone changes
- * From: the source of the redstone change
- * To: The redstone dust that changed
+ * Called when a player right clicks a block
*
* @param event Relevant event details
*/
- public void onRedstoneChange(BlockFromToEvent event) {
+ public void onBlockRightClicked(BlockRightClickedEvent event) {
}
+
}
diff --git a/src/org/bukkit/event/block/BlockRightClickedEvent.java b/src/org/bukkit/event/block/BlockRightClickedEvent.java
index 3f8c8397..730d6879 100644
--- a/src/org/bukkit/event/block/BlockRightClickedEvent.java
+++ b/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 {