summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormd_5 <git@md-5.net>2018-11-18 09:28:03 +1100
committermd_5 <git@md-5.net>2018-11-18 09:28:03 +1100
commit01ffd1c78c0e400445faacef46989f474aaa2330 (patch)
tree3c4ecd455cda21a951d6c8c2907ddd03ac271b55
parent7631ed33d4c4144127be13dc6796b420cea2c636 (diff)
downloadbukkit-01ffd1c78c0e400445faacef46989f474aaa2330.tar
bukkit-01ffd1c78c0e400445faacef46989f474aaa2330.tar.gz
bukkit-01ffd1c78c0e400445faacef46989f474aaa2330.tar.lz
bukkit-01ffd1c78c0e400445faacef46989f474aaa2330.tar.xz
bukkit-01ffd1c78c0e400445faacef46989f474aaa2330.zip
Add Player to BlockCanBuildEvent
-rw-r--r--src/main/java/org/bukkit/event/block/BlockCanBuildEvent.java28
1 files changed, 24 insertions, 4 deletions
diff --git a/src/main/java/org/bukkit/event/block/BlockCanBuildEvent.java b/src/main/java/org/bukkit/event/block/BlockCanBuildEvent.java
index 3aa54d39..58f4cceb 100644
--- a/src/main/java/org/bukkit/event/block/BlockCanBuildEvent.java
+++ b/src/main/java/org/bukkit/event/block/BlockCanBuildEvent.java
@@ -3,6 +3,7 @@ package org.bukkit.event.block;
import org.bukkit.block.Block;
import org.bukkit.Material;
import org.bukkit.block.data.BlockData;
+import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
/**
@@ -21,17 +22,25 @@ public class BlockCanBuildEvent extends BlockEvent {
protected boolean buildable;
protected BlockData blockData;
+ private final Player player;
+
+ @Deprecated
+ public BlockCanBuildEvent(final Block block, final BlockData type, final boolean canBuild) {
+ this(block, null, type, canBuild);
+ }
/**
*
* @param block the block involved in this event
+ * @param player the player placing the block
* @param type the id of the block to place
- * @param canBuild whether we can build
+ * @param canBuild whether we can build
*/
- public BlockCanBuildEvent(final Block block, final BlockData type, final boolean canBuild) {
+ public BlockCanBuildEvent(final Block block, final Player player, final BlockData type, final boolean canBuild) {
super(block);
- buildable = canBuild;
- blockData = type;
+ this.player = player;
+ this.buildable = canBuild;
+ this.blockData = type;
}
/**
@@ -74,6 +83,17 @@ public class BlockCanBuildEvent extends BlockEvent {
return blockData;
}
+ /**
+ * Gets the player who placed the block involved in this event.
+ * <br>
+ * May be null for legacy calls of the event.
+ *
+ * @return The Player who placed the block involved in this event
+ */
+ public Player getPlayer() {
+ return player;
+ }
+
@Override
public HandlerList getHandlers() {
return handlers;