mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2025-02-03 14:01:56 +01:00
Destroy sapling if some of its blocks could be placed.
Fixes WORLDGUARD-3168.
This commit is contained in:
parent
eb051bc194
commit
c4b3c1d033
@ -210,6 +210,7 @@ public void onBlockBurn(BlockBurnEvent event) {
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onStructureGrowEvent(StructureGrowEvent event) {
|
||||
int originalCount = event.getBlocks().size();
|
||||
List<Block> blockList = Lists.transform(event.getBlocks(), new BlockStateAsBlockFunction());
|
||||
|
||||
Player player = event.getPlayer();
|
||||
@ -218,6 +219,10 @@ public void onStructureGrowEvent(StructureGrowEvent event) {
|
||||
} else {
|
||||
Events.fireBulkEventToCancel(event, new PlaceBlockEvent(event, create(event.getLocation().getBlock()), event.getLocation().getWorld(), blockList, Material.AIR));
|
||||
}
|
||||
|
||||
if (!event.isCancelled() && event.getBlocks().size() != originalCount) {
|
||||
event.getLocation().getBlock().setType(Material.AIR);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Handle EntityCreatePortalEvent?
|
||||
|
Loading…
Reference in New Issue
Block a user