summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordurron597 <martin.jared@gmail.com>2010-12-31 21:17:16 -0500
committerdurron597 <martin.jared@gmail.com>2010-12-31 21:17:16 -0500
commita44979c88b8f234b0d8776c146cd49a4bb436b85 (patch)
treeb30760e06add10afd7167ec0e3537e32c936b949
parent2e3f21bcf2af4eb06466c8ef62610ce6910f7e87 (diff)
downloadbukkit-a44979c88b8f234b0d8776c146cd49a4bb436b85.tar
bukkit-a44979c88b8f234b0d8776c146cd49a4bb436b85.tar.gz
bukkit-a44979c88b8f234b0d8776c146cd49a4bb436b85.tar.lz
bukkit-a44979c88b8f234b0d8776c146cd49a4bb436b85.tar.xz
bukkit-a44979c88b8f234b0d8776c146cd49a4bb436b85.zip
Reimplemented BlockFlow to use multiple BlockFromToEvents
-rw-r--r--src/org/bukkit/event/block/BlockFlowEvent.java85
-rw-r--r--src/org/bukkit/event/block/BlockFromToEvent.java15
-rw-r--r--src/org/bukkit/event/block/BlockListener.java2
3 files changed, 15 insertions, 87 deletions
diff --git a/src/org/bukkit/event/block/BlockFlowEvent.java b/src/org/bukkit/event/block/BlockFlowEvent.java
deleted file mode 100644
index a91cedfd..00000000
--- a/src/org/bukkit/event/block/BlockFlowEvent.java
+++ /dev/null
@@ -1,85 +0,0 @@
-package org.bukkit.event.block;
-
-import java.util.HashSet;
-import java.util.List;
-
-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 final 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));
- }
- }
- }
-
- public BlockFlowEvent(final Event.Type type, final Block block, List<BlockFace> faces) {
- super(type, block);
- this.faceList = new HashSet<BlockFlow>();
- if (faces != null && faces.size() > 0) {
- for (BlockFace theFace : faces) {
- faceList.add(new BlockFlow(theFace));
- }
- }
- }
-
- /**
- * We don't want plugins changing the eligible flowing faces
- * therefore give them a new HashSet instance
- *
- * @return Block the block is event originated from
- */
- public HashSet<BlockFlow> getFaces() {
- return new HashSet<BlockFlow>(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 flowDirection.equals(flow.flowDirection);
- }
-
- @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 2fcbcf0c..cc0a30fa 100644
--- a/src/org/bukkit/event/block/BlockFromToEvent.java
+++ b/src/org/bukkit/event/block/BlockFromToEvent.java
@@ -2,12 +2,13 @@ package org.bukkit.event.block;
import org.bukkit.Block;
import org.bukkit.BlockFace;
+import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
/**
* Holds information for events with a source block and a destination block
*/
-public class BlockFromToEvent extends BlockEvent {
+public class BlockFromToEvent extends BlockEvent implements Cancellable {
protected Block from;
protected BlockFace face;
@@ -34,4 +35,16 @@ public class BlockFromToEvent extends BlockEvent {
public Block getFromBlock() {
return from;
}
+
+ @Override
+ public boolean isCancelled() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public void setCancelled(boolean cancel) {
+ // TODO Auto-generated method stub
+
+ }
}
diff --git a/src/org/bukkit/event/block/BlockListener.java b/src/org/bukkit/event/block/BlockListener.java
index b9dd9c80..2165d4aa 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(BlockFlowEvent event) {
+ public void onBlockFlow(BlockFromToEvent event) {
}
/**