BlockMultiPlace has an immutable state list.

Fixes WORLDGUARD-4143.
This commit is contained in:
wizjany 2019-09-22 15:15:59 -04:00
parent fc0f7acab5
commit 1c3cf02ebd

View File

@ -177,8 +177,14 @@ public void onBlockBreak(BlockBreakEvent event) {
@EventHandler(ignoreCancelled = true)
public void onBlockMultiPlace(BlockMultiPlaceEvent event) {
Events.fireToCancel(event, new PlaceBlockEvent(event, create(event.getPlayer()),
event.getBlock().getWorld(), event.getReplacedBlockStates()));
List<Block> placed = event.getReplacedBlockStates().stream().map(BlockState::getBlock).collect(Collectors.toList());
int origAmt = placed.size();
PlaceBlockEvent delegateEvent = new PlaceBlockEvent(event, create(event.getPlayer()), event.getBlock().getWorld(),
placed, event.getBlockPlaced().getType());
Events.fireToCancel(event, delegateEvent);
if (origAmt != placed.size()) {
event.setCancelled(true);
}
}
@EventHandler(ignoreCancelled = true)