From 1ec5689002ceb8e6a94240502dd2a59b53953f04 Mon Sep 17 00:00:00 2001 From: Bukkit/Spigot Date: Fri, 31 Dec 2010 21:17:16 -0500 Subject: [PATCH] Reimplemented BlockFlow to use multiple BlockFromToEvents By: durron597 --- .../bukkit/event/block/BlockFlowEvent.java | 85 ------------------- .../bukkit/event/block/BlockFromToEvent.java | 15 +++- .../org/bukkit/event/block/BlockListener.java | 2 +- 3 files changed, 15 insertions(+), 87 deletions(-) delete mode 100644 paper-api/src/org/bukkit/event/block/BlockFlowEvent.java diff --git a/paper-api/src/org/bukkit/event/block/BlockFlowEvent.java b/paper-api/src/org/bukkit/event/block/BlockFlowEvent.java deleted file mode 100644 index a91cedfdcd..0000000000 --- a/paper-api/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 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)); - } - } - } - - public BlockFlowEvent(final Event.Type type, final Block block, List faces) { - super(type, block); - this.faceList = new HashSet(); - 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 getFaces() { - return new HashSet(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/paper-api/src/org/bukkit/event/block/BlockFromToEvent.java b/paper-api/src/org/bukkit/event/block/BlockFromToEvent.java index 2fcbcf0c76..cc0a30fa3c 100644 --- a/paper-api/src/org/bukkit/event/block/BlockFromToEvent.java +++ b/paper-api/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/paper-api/src/org/bukkit/event/block/BlockListener.java b/paper-api/src/org/bukkit/event/block/BlockListener.java index b9dd9c8041..2165d4aab8 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(BlockFlowEvent event) { + public void onBlockFlow(BlockFromToEvent event) { } /**