if (!War.war.isLoaded()) {
return;
}
Player player = event.getPlayer();
Block block = event.getBlock();
if (player == null || block == null) {
return;
}
Team team = Team.getTeamByPlayerName(player.getName());
Warzone zone = Warzone.getZoneByLocation(player);
// Monument capturing
if (team != null && block != null && zone != null
&& zone.isMonumentCenterBlock(block)
&& team.getKind().isTeamBlock(block.getState())) {
Monument monument = zone.getMonumentFromCenterBlock(block);
if (monument != null && !monument.hasOwner()) {
monument.capture(team);
if (War.war.isSpoutServer()) {
for (Player p : team.getPlayers()) {
SpoutPlayer sp = SpoutManager.getPlayer(p);
if (sp.isSpoutCraftEnabled()) {
sp.sendNotification(
SpoutDisplayer.cleanForNotification("Monument " + ChatColor.WHITE + monument.getName()),
SpoutDisplayer.cleanForNotification(ChatColor.YELLOW + "capped by " + team.getKind().getColor() + player.getName() + ChatColor.YELLOW + "!"),
team.getKind().getMaterial(),
team.getKind().getData(),
10000);
}
}
}
zone.broadcast("zone.monument.capture", monument.getName(), team.getName());
event.setCancelled(false);
return; // important otherwise cancelled down a few line by isImportantblock
} else {
War.war.badMsg(player, "zone.monument.badblock");
cancelAndKeepItem(event);
return;
}
}
boolean isZoneMaker = War.war.isZoneMaker(player);
// prevent build in important parts
if (zone != null
&& (zone.isImportantBlock(block) || zone.isOpponentSpawnPeripheryBlock(team, block))
&& (!isZoneMaker || (isZoneMaker && team != null))) {
War.war.badMsg(player, "build.denied.location");
cancelAndKeepItem(event);
return;
}
// protect warzone lobbies
for (Warzone wz : War.war.getWarzones()) {
if (wz.getLobby() != null && wz.getLobby().getVolume() != null && wz.getLobby().getVolume().contains(block)) {
War.war.badMsg(player, "build.denied.location");
cancelAndKeepItem(event);
return;
}
}
// protect the hub
if (War.war.getWarHub() != null && War.war.getWarHub().getVolume().contains(block)) {
War.war.badMsg(player, "build.denied.location");
cancelAndKeepItem(event);
return;
}
// buildInZonesOnly
if (zone == null && War.war.getWarConfig().getBoolean(WarConfig.BUILDINZONESONLY) && !War.war.canBuildOutsideZone(player)) {
if (!War.war.getWarConfig().getBoolean(WarConfig.DISABLEBUILDMESSAGE)) {
War.war.badMsg(player, "build.denied.outside");
}
cancelAndKeepItem(event);
return;
}
// can't place a block of your team's color
if (team != null && block.getType() == team.getKind().getMaterial() && block.getState().getData() == team.getKind().getBlockData()) {
War.war.badMsg(player, "build.denied.teamblock");
cancelAndKeepItem(event);
return;
}
// a flag thief can't drop his flag
if (team != null && zone != null && zone.isFlagThief(player.getName())) {
War.war.badMsg(player, "drop.flag.disabled");
cancelAndKeepItem(event);
return;
}
// a bomb thief can't drop his bomb
if (team != null && zone != null && zone.isBombThief(player.getName())) {
War.war.badMsg(player, "drop.bomb.disabled");
cancelAndKeepItem(event);
return;
}
// a cake thief can't drop his cake
if (team != null && zone != null && zone.isCakeThief(player.getName())) {
War.war.badMsg(player, "drop.cake.disabled");
cancelAndKeepItem(event);
return;
}
// unbreakableZoneBlocks
if (zone != null && (zone.getWarzoneConfig().getBoolean(WarzoneConfig.UNBREAKABLE)
|| (team != null && !team.getTeamConfig().resolveBoolean(TeamConfig.PLACEBLOCK)))
&& (!isZoneMaker || (isZoneMaker && team != null))) {
// if the zone is unbreakable, no one but zone makers can break blocks (even then, zone makers in a team can't break blocks)
War.war.badMsg(player, "build.denied.zone.place");
cancelAndKeepItem(event);
return;
}
if (team != null && !team.canModify(block.getType())) {
War.war.badMsg(player, "build.denied.zone.type");
cancelAndKeepItem(event);
return;
}
}