mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-29 22:13:42 +01:00
Add Player to BlockCanBuildEvent
This commit is contained in:
parent
b1d149cfd0
commit
1cac9d4fc1
@ -21,15 +21,16 @@
|
|||||||
itemstack.subtract(1);
|
itemstack.subtract(1);
|
||||||
return EnumInteractionResult.SUCCESS;
|
return EnumInteractionResult.SUCCESS;
|
||||||
}
|
}
|
||||||
@@ -64,7 +69,14 @@
|
@@ -64,7 +69,15 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean b(BlockActionContext blockactioncontext, IBlockData iblockdata) {
|
protected boolean b(BlockActionContext blockactioncontext, IBlockData iblockdata) {
|
||||||
- return iblockdata.canPlace(blockactioncontext.getWorld(), blockactioncontext.getClickPosition()) && blockactioncontext.getWorld().a(iblockdata, blockactioncontext.getClickPosition());
|
- return iblockdata.canPlace(blockactioncontext.getWorld(), blockactioncontext.getClickPosition()) && blockactioncontext.getWorld().a(iblockdata, blockactioncontext.getClickPosition());
|
||||||
+ // CraftBukkit start - store default return
|
+ // CraftBukkit start - store default return
|
||||||
+ boolean defaultReturn = iblockdata.canPlace(blockactioncontext.getWorld(), blockactioncontext.getClickPosition()) && blockactioncontext.getWorld().a(iblockdata, blockactioncontext.getClickPosition());
|
+ boolean defaultReturn = iblockdata.canPlace(blockactioncontext.getWorld(), blockactioncontext.getClickPosition()) && blockactioncontext.getWorld().a(iblockdata, blockactioncontext.getClickPosition());
|
||||||
|
+ org.bukkit.entity.Player player = (blockactioncontext.getEntity() instanceof EntityPlayer) ? (org.bukkit.entity.Player) blockactioncontext.getEntity().getBukkitEntity() : null;
|
||||||
+
|
+
|
||||||
+ BlockCanBuildEvent event = new BlockCanBuildEvent(CraftBlock.at(blockactioncontext.getWorld(), blockactioncontext.getClickPosition()), CraftBlockData.fromData(iblockdata), defaultReturn);
|
+ BlockCanBuildEvent event = new BlockCanBuildEvent(CraftBlock.at(blockactioncontext.getWorld(), blockactioncontext.getClickPosition()), player, CraftBlockData.fromData(iblockdata), defaultReturn);
|
||||||
+ blockactioncontext.getWorld().getServer().getPluginManager().callEvent(event);
|
+ blockactioncontext.getWorld().getServer().getPluginManager().callEvent(event);
|
||||||
+
|
+
|
||||||
+ return event.isBuildable();
|
+ return event.isBuildable();
|
||||||
|
Loading…
Reference in New Issue
Block a user