Players can't be trapped in spawn anymore

Closes gh-472. The periphery of opponents' spawns can't be built on. In
other words, all teams have a "no other team can build right next to my
spawn" protection 1 block wide all around their spawn. This should let
people exit the spawn with their loadout select, then use their items to
dig themselves out of any now-harmless trap.
This commit is contained in:
taoneill 2012-06-18 01:28:49 -04:00
parent c6b04faa55
commit 4dfead7ec8
2 changed files with 20 additions and 1 deletions

View File

@ -42,6 +42,8 @@ import com.tommytony.war.structure.ZoneWallGuard;
import com.tommytony.war.utility.LoadoutSelection;
import com.tommytony.war.utility.PlayerState;
import com.tommytony.war.utility.PotionEffectHelper;
import com.tommytony.war.volume.BlockInfo;
import com.tommytony.war.volume.Volume;
import com.tommytony.war.volume.ZoneVolume;
/**
@ -1407,4 +1409,19 @@ public class Warzone {
public void setLobbyMaterials(HubLobbyMaterials lobbyMaterials) {
this.lobbyMaterials = lobbyMaterials;
}
public boolean isOpponentSpawnPeripheryBlock(Team team, Block block) {
for (Team maybeOpponent : this.getTeams()) {
if (maybeOpponent != team) {
Volume periphery = new Volume("periphery", this.getWorld());
periphery.setCornerOne(new BlockInfo(maybeOpponent.getSpawnVolume().getMinX()-1 , maybeOpponent.getSpawnVolume().getMinY()-1, maybeOpponent.getSpawnVolume().getMinZ()-1, 0, (byte)0));
periphery.setCornerTwo(new BlockInfo(maybeOpponent.getSpawnVolume().getMaxX()+1, maybeOpponent.getSpawnVolume().getMaxY()+1, maybeOpponent.getSpawnVolume().getMaxZ()+1, 0, (byte)0));
if (periphery.contains(block)) {
return true;
}
}
}
return false;
}
}

View File

@ -88,7 +88,9 @@ public class WarBlockListener implements Listener {
boolean isZoneMaker = War.war.isZoneMaker(player);
// prevent build in important parts
if (zone != null && zone.isImportantBlock(block) && (!isZoneMaker || (isZoneMaker && team != null))) {
if (zone != null
&& (zone.isImportantBlock(block) || zone.isOpponentSpawnPeripheryBlock(team, block))
&& (!isZoneMaker || (isZoneMaker && team != null))) {
War.war.badMsg(player, "Can't build here.");
cancelAndKeepItem(event);
return;