From fe393aa73dfa82797e36813ce3b0701e332e357d Mon Sep 17 00:00:00 2001 From: Bukkit/Spigot Date: Fri, 31 Dec 2010 07:53:56 -0500 Subject: [PATCH 1/6] Implemented BLOCK_FLOW By: durron597 --- .../bukkit/event/block/BlockFlowEvent.java | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/paper-api/src/org/bukkit/event/block/BlockFlowEvent.java b/paper-api/src/org/bukkit/event/block/BlockFlowEvent.java index df126fcf3c..c2af4c4bf9 100644 --- a/paper-api/src/org/bukkit/event/block/BlockFlowEvent.java +++ b/paper-api/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 a0acf4546161467f96998bee40b3bb94169ae66f Mon Sep 17 00:00:00 2001 From: Bukkit/Spigot 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 By: durron597 --- .../src/org/bukkit/event/block/BlockFromToEvent.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/paper-api/src/org/bukkit/event/block/BlockFromToEvent.java b/paper-api/src/org/bukkit/event/block/BlockFromToEvent.java index fc029c369e..2fcbcf0c76 100644 --- a/paper-api/src/org/bukkit/event/block/BlockFromToEvent.java +++ b/paper-api/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 7740148f731545dff27ffe185c6c3a77bb7fa448 Mon Sep 17 00:00:00 2001 From: Bukkit/Spigot Date: Fri, 31 Dec 2010 09:07:39 -0500 Subject: [PATCH 3/6] Fixed bug with BlockFlow.equals Added second constructor for collections By: durron597 --- paper-api/src/org/bukkit/event/block/BlockFlowEvent.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/paper-api/src/org/bukkit/event/block/BlockFlowEvent.java b/paper-api/src/org/bukkit/event/block/BlockFlowEvent.java index c2af4c4bf9..a91cedfdcd 100644 --- a/paper-api/src/org/bukkit/event/block/BlockFlowEvent.java +++ b/paper-api/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 66676f3800eb076e2d8dda0ec15a002c5aa3fb01 Mon Sep 17 00:00:00 2001 From: Bukkit/Spigot Date: Fri, 31 Dec 2010 09:09:02 -0500 Subject: [PATCH 4/6] Implemented BlockRightClickedEvent By: durron597 --- .../event/block/BlockRightClickedEvent.java | 43 ++++++++++++++++--- 1 file changed, 37 insertions(+), 6 deletions(-) diff --git a/paper-api/src/org/bukkit/event/block/BlockRightClickedEvent.java b/paper-api/src/org/bukkit/event/block/BlockRightClickedEvent.java index 730d68794e..4f43492c7b 100644 --- a/paper-api/src/org/bukkit/event/block/BlockRightClickedEvent.java +++ b/paper-api/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 eff44b6a9537dd9cc541bd54fe7c84102787c1b4 Mon Sep 17 00:00:00 2001 From: Bukkit/Spigot Date: Fri, 31 Dec 2010 09:09:22 -0500 Subject: [PATCH 5/6] Stated "not implemented yet" By: durron597 --- paper-api/src/org/bukkit/event/block/BlockPlacedEvent.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/paper-api/src/org/bukkit/event/block/BlockPlacedEvent.java b/paper-api/src/org/bukkit/event/block/BlockPlacedEvent.java index 625a1e95c7..e8e15e21cd 100644 --- a/paper-api/src/org/bukkit/event/block/BlockPlacedEvent.java +++ b/paper-api/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 3be4ecd28cb4aa5419b8e26a26b8bf0e92de378a Mon Sep 17 00:00:00 2001 From: Bukkit/Spigot Date: Fri, 31 Dec 2010 09:10:31 -0500 Subject: [PATCH 6/6] Added self face By: durron597 --- paper-api/src/org/bukkit/BlockFace.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/paper-api/src/org/bukkit/BlockFace.java b/paper-api/src/org/bukkit/BlockFace.java index eb7f29c6e4..aba16cbf6f 100644 --- a/paper-api/src/org/bukkit/BlockFace.java +++ b/paper-api/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;