summaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
authorNate Mortensen <nate.richard.mortensen@gmail.com>2014-04-21 17:23:36 -0600
committerNate Mortensen <nate.richard.mortensen@gmail.com>2014-04-21 20:28:59 -0600
commitf94692bbe3d43fd4736996d63a8d3e4d67961f67 (patch)
tree1b941237aa85f45b0bb486d4867a96b233b9356e /src/main
parented67385edf1085469119be982ef30dd60ffd1b27 (diff)
downloadbukkit-f94692bbe3d43fd4736996d63a8d3e4d67961f67.tar
bukkit-f94692bbe3d43fd4736996d63a8d3e4d67961f67.tar.gz
bukkit-f94692bbe3d43fd4736996d63a8d3e4d67961f67.tar.lz
bukkit-f94692bbe3d43fd4736996d63a8d3e4d67961f67.tar.xz
bukkit-f94692bbe3d43fd4736996d63a8d3e4d67961f67.zip
Add BlockMultiPlaceEvent. Adds BUKKIT-5558
Some blocks, such as beds, doors, or flowers, are actually composed of multiple blocks when they are placed. Currently, to detect how many blocks are actually modified a plugin has to perform various calculations to determine the directions of relative blocks, many of which are difficult to perform and can easily return false positives. This commit adds in a BlockMultiPlaceEvent, which adds in easy support for accessing all blocks modified by the placement of a block.
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/org/bukkit/event/block/BlockMultiPlaceEvent.java36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/main/java/org/bukkit/event/block/BlockMultiPlaceEvent.java b/src/main/java/org/bukkit/event/block/BlockMultiPlaceEvent.java
new file mode 100644
index 00000000..d16e4be7
--- /dev/null
+++ b/src/main/java/org/bukkit/event/block/BlockMultiPlaceEvent.java
@@ -0,0 +1,36 @@
+package org.bukkit.event.block;
+
+import com.google.common.collect.ImmutableList;
+import org.bukkit.block.Block;
+import org.bukkit.block.BlockState;
+import org.bukkit.entity.Player;
+import org.bukkit.inventory.ItemStack;
+
+import java.util.List;
+
+/**
+ * Fired when a single block placement action of a player triggers the
+ * creation of multiple blocks(e.g. placing a bed block). The block returned
+ * by {@link #getBlockPlaced()} and its related methods is the block where
+ * the placed block would exist if the placement only affected a single
+ * block.
+ */
+public class BlockMultiPlaceEvent extends BlockPlaceEvent {
+ private final List<BlockState> states;
+
+ public BlockMultiPlaceEvent(List<BlockState> states, Block clicked, ItemStack itemInHand, Player thePlayer, boolean canBuild) {
+ super(states.get(0).getBlock(), states.get(0), clicked, itemInHand, thePlayer, canBuild);
+ this.states = ImmutableList.copyOf(states);
+ }
+
+ /**
+ * Gets a list of blockstates for all blocks which were replaced by the
+ * placement of the new blocks. Most of these blocks will just have a
+ * Material type of AIR.
+ *
+ * @return immutable list of replaced BlockStates
+ */
+ public List<BlockState> getReplacedBlockStates() {
+ return states;
+ }
+}