From 94921bc3e573b51497cf02dc58f9317fb0927502 Mon Sep 17 00:00:00 2001 From: durron597 Date: Fri, 31 Dec 2010 07:53:56 -0500 Subject: [PATCH 1/6] Implemented BLOCK_FLOW --- .../bukkit/event/block/BlockFlowEvent.java | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/org/bukkit/event/block/BlockFlowEvent.java b/src/org/bukkit/event/block/BlockFlowEvent.java index df126fcf..c2af4c4b 100644 --- a/src/org/bukkit/event/block/BlockFlowEvent.java +++ b/src/org/bukkit/event/block/BlockFlowEvent.java @@ -1,6 +1,8 @@ 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; @@ -9,7 +11,7 @@ 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; + protected final HashSet faceList; public BlockFlowEvent(final Event.Type type, final Block block, BlockFace... faces) { super(type, block); @@ -20,14 +22,25 @@ public class BlockFlowEvent extends BlockEvent { } } } + + 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)); + } + } + } /** - * Gets the location this player moved to + * 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 faceList; + return new HashSet(faceList); } /** From 0520b39adf54332a50765e6b52cc761f4327a573 Mon Sep 17 00:00:00 2001 From: durron597 Date: Fri, 31 Dec 2010 09:07:12 -0500 Subject: [PATCH 2/6] Changed it so we store both the block and the face for speed --- src/org/bukkit/event/block/BlockFromToEvent.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/org/bukkit/event/block/BlockFromToEvent.java b/src/org/bukkit/event/block/BlockFromToEvent.java index fc029c36..2fcbcf0c 100644 --- a/src/org/bukkit/event/block/BlockFromToEvent.java +++ b/src/org/bukkit/event/block/BlockFromToEvent.java @@ -8,11 +8,13 @@ import org.bukkit.event.Event; * Holds information for events with a source block and a destination block */ public class BlockFromToEvent extends BlockEvent { - protected BlockFace face; + protected Block from; + protected BlockFace face; public BlockFromToEvent(final Event.Type type, final Block block, final BlockFace face) { super(type, block); this.face = face; + this.from = block.getRelative(face.getModX(), face.getModY(), face.getModZ()); } /** @@ -29,7 +31,7 @@ public class BlockFromToEvent extends BlockEvent { * * @return Block the faced block */ - public Block getFacedBlock() { - return block.getRelative(face.getModX(), face.getModY(), face.getModZ()); + public Block getFromBlock() { + return from; } } From a8b7a63a8e342a0165f43d550ef8cf870fc6e41d Mon Sep 17 00:00:00 2001 From: durron597 Date: Fri, 31 Dec 2010 09:07:39 -0500 Subject: [PATCH 3/6] Fixed bug with BlockFlow.equals Added second constructor for collections --- src/org/bukkit/event/block/BlockFlowEvent.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/org/bukkit/event/block/BlockFlowEvent.java b/src/org/bukkit/event/block/BlockFlowEvent.java index c2af4c4b..a91cedfd 100644 --- a/src/org/bukkit/event/block/BlockFlowEvent.java +++ b/src/org/bukkit/event/block/BlockFlowEvent.java @@ -74,7 +74,7 @@ public class BlockFlowEvent extends BlockEvent { } public boolean equals(BlockFlow flow) { - return flow.flowDirection.equals(flow); + return flowDirection.equals(flow.flowDirection); } @Override From 055c64106dd29a4da04e5f86e69fc452217d9c95 Mon Sep 17 00:00:00 2001 From: durron597 Date: Fri, 31 Dec 2010 09:09:02 -0500 Subject: [PATCH 4/6] Implemented BlockRightClickedEvent --- .../event/block/BlockRightClickedEvent.java | 43 ++++++++++++++++--- 1 file changed, 37 insertions(+), 6 deletions(-) diff --git a/src/org/bukkit/event/block/BlockRightClickedEvent.java b/src/org/bukkit/event/block/BlockRightClickedEvent.java index 730d6879..4f43492c 100644 --- a/src/org/bukkit/event/block/BlockRightClickedEvent.java +++ b/src/org/bukkit/event/block/BlockRightClickedEvent.java @@ -4,19 +4,50 @@ package org.bukkit.event.block; import org.bukkit.Block; +import org.bukkit.BlockFace; +import org.bukkit.ItemStack; +import org.bukkit.Player; /** - * Not implemented yet + * @author durron597 */ public class BlockRightClickedEvent extends BlockEvent { - + protected Player clicker; + protected BlockFace direction; + protected ItemStack clickedWith; + /** - * @param type - * @param theBlock + * @param type The type of event this is + * @param theBlock The clicked block + * @param direction The face we clicked from + * @param clicker The player who clicked a block + * @param clickedWith Item in player's hand */ - public BlockRightClickedEvent(Type type, Block theBlock) { + public BlockRightClickedEvent(Type type, Block theBlock, BlockFace direction, Player clicker, ItemStack clickedWith) { super(type, theBlock); - // TODO Auto-generated constructor stub + this.direction = direction; + this.clicker = clicker; + this.clickedWith = clickedWith; } + /** + * @return the clicker + */ + public Player getClicker() { + return clicker; + } + + /** + * @return the direction + */ + public BlockFace getDirection() { + return direction; + } + + /** + * @return the clickedWith + */ + public ItemStack getClickedWith() { + return clickedWith; + } } From 8a6569f229fec0d223a8ca35e13a61456c90a4f9 Mon Sep 17 00:00:00 2001 From: durron597 Date: Fri, 31 Dec 2010 09:09:22 -0500 Subject: [PATCH 5/6] Stated "not implemented yet" --- src/org/bukkit/event/block/BlockPlacedEvent.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/org/bukkit/event/block/BlockPlacedEvent.java b/src/org/bukkit/event/block/BlockPlacedEvent.java index 625a1e95..e8e15e21 100644 --- a/src/org/bukkit/event/block/BlockPlacedEvent.java +++ b/src/org/bukkit/event/block/BlockPlacedEvent.java @@ -1,13 +1,9 @@ -/** - * - */ package org.bukkit.event.block; import org.bukkit.Block; /** - * @author jmartin - * + * Not implemented yet */ public class BlockPlacedEvent extends BlockEvent { From 0a2b312ecdc06b98768a08529e50327c053cd6a5 Mon Sep 17 00:00:00 2001 From: durron597 Date: Fri, 31 Dec 2010 09:10:31 -0500 Subject: [PATCH 6/6] Added self face --- src/org/bukkit/BlockFace.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/org/bukkit/BlockFace.java b/src/org/bukkit/BlockFace.java index eb7f29c6..aba16cbf 100644 --- a/src/org/bukkit/BlockFace.java +++ b/src/org/bukkit/BlockFace.java @@ -9,7 +9,8 @@ public enum BlockFace { South(1, 0, 0), West(0, 0, 1), Up(0, 1, 0), - Down(0, -1, 0); + Down(0, -1, 0), + Self(0, 0, 0); private final int modX; private final int modY;