return false;
}
public void onBlockPlace(BlockPlaceEvent event) {
Block b = event.getBlock();
// If the event didn't happen in the region, or if in edit mode, ignore
if (!arena.getRegion().contains(b.getLocation()) || arena.inEditMode()) {
return;
}
// If the arena isn't running, or if the player isn't in the arena, cancel.
if (!arena.isRunning() || !arena.inArena(event.getPlayer())) {
// But only if we're protecting the region
if (protect) {
event.setCancelled(true);
}
return;
}
// If the block is TNT, set its planter
if (b.getType() == Material.TNT) {
// If auto-igniting, set the planter of the primed TNT instead
if (autoIgniteTNT) {
event.setCancelled(true);
event.getPlayer().getInventory().removeItem(new ItemStack(Material.TNT, 1));
TNTPrimed tnt = b.getWorld().spawn(b.getRelative(BlockFace.UP).getLocation(), TNTPrimed.class);
setPlanter(tnt, event.getPlayer());
return;
}
setPlanter(b, event.getPlayer());
}
// Any other block we don't care about if we're not protecting
if (!protect) {
return;
}
// Otherwise, block was placed during a session.
arena.addBlock(b);
if (b.getType() == Material.WOODEN_DOOR || b.getType() == Material.IRON_DOOR_BLOCK) {
// For doors, add the block just above (so we get both halves)
arena.addBlock(b.getRelative(0, 1, 0));
}
}