Merge branch 'tim'

This commit is contained in:
taoneill 2011-07-02 22:40:54 -04:00
commit e3918180fc
5 changed files with 70 additions and 23 deletions

View File

@ -233,7 +233,7 @@ public class War extends JavaPlugin {
} else if(command.equals("resetzone")) {
performResetZone(player, arguments);
} else if(command.equals("deletezone")) {
performDeleteZone(player);
performDeleteZone(player, arguments);
} else if(command.equals("setteam")) {
performSetTeam(player, arguments);
} else if(command.equals("setteamflag")) {
@ -565,14 +565,29 @@ public class War extends JavaPlugin {
}
}
public void performDeleteZone(Player player) {
if(!this.inAnyWarzone(player.getLocation()) && !this.inAnyWarzoneLobby(player.getLocation())) {
this.badMsg(player, "Usage: /deletezone. " +
public void performDeleteZone(Player player, String[] arguments) {
if(arguments.length == 0 && !this.inAnyWarzone(player.getLocation()) && !this.inAnyWarzoneLobby(player.getLocation())) {
this.badMsg(player, "Usage: /deletezone [warzone-name]. " +
"Deletes the warzone. " +
"Must be in the warzone (try /zones and /zone). ");
"Must be in the warzone or name must be provided (try /zones and /zone). ");
} else {
Warzone warzone = this.warzone(player.getLocation());
ZoneLobby lobby = this.lobby(player.getLocation());
ZoneLobby lobby = null;
Warzone warzone = null;
if(arguments.length == 1) { // get zone by name
for(Warzone tmp : this.getWarzones()) {
if(tmp.getName().toLowerCase().startsWith(arguments[0].toLowerCase())) {
warzone = tmp;
break;
}
}
if (warzone == null) {
this.badMsg(player, "No such warzone.");
return;
}
} else { // get zone by position
warzone = this.warzone(player.getLocation());
lobby = this.lobby(player.getLocation());
}
if(warzone == null && lobby != null) {
warzone = lobby.getZone();
} else {
@ -1057,6 +1072,8 @@ public class War extends JavaPlugin {
warzone.setSpawnStyle(spawnStyle);
} else if (spawnStyle.equals(TeamSpawnStyles.FLAT)){
warzone.setSpawnStyle(spawnStyle);
} else if (spawnStyle.equals(TeamSpawnStyles.INVISIBLE)){
warzone.setSpawnStyle(spawnStyle);
} else {
warzone.setSpawnStyle(TeamSpawnStyles.BIG);
}

View File

@ -70,12 +70,16 @@ public class WarEntityListener extends EntityListener {
&& attackerWarzone == defenderWarzone) {
// Make sure one of the players isn't in the spawn
if(defenderTeam.getSpawnVolume().contains(d.getLocation())) { // attacking person in spawn
war.badMsg(a, "Can't attack a player that's inside his team's spawn.");
event.setCancelled(true);
if(!defenderWarzone.isFlagThief(d.getName())) { // thiefs can always be attacked
war.badMsg(a, "Can't attack a player that's inside his team's spawn.");
event.setCancelled(true);
}
} else if(attackerTeam.getSpawnVolume().contains(a.getLocation()) && !attackerTeam.getSpawnVolume().contains(d.getLocation())) {
// only let a player inside spawn attack an enemy player if that player enters the spawn
war.badMsg(a, "Can't attack a player from inside your spawn.");
event.setCancelled(true);
if(!attackerWarzone.isFlagThief(a.getName())) { // thiefs can always attack
war.badMsg(a, "Can't attack a player from inside your spawn.");
event.setCancelled(true);
}
}
// Detect death, prevent it and respawn the player

View File

@ -51,7 +51,11 @@ public class Team {
int x = teamSpawn.getBlockX();
int y = teamSpawn.getBlockY();
int z = teamSpawn.getBlockZ();
if(warzone.getSpawnStyle().equals(TeamSpawnStyles.SMALL)) {
if(warzone.getSpawnStyle().equals(TeamSpawnStyles.INVISIBLE)) {
this.spawnVolume.setCornerOne(warzone.getWorld().getBlockAt(x, y-1, z));
this.spawnVolume.setCornerTwo(warzone.getWorld().getBlockAt(x, y+3, z));
} else if(warzone.getSpawnStyle().equals(TeamSpawnStyles.SMALL)) {
this.spawnVolume.setCornerOne(warzone.getWorld().getBlockAt(x-1, y-1, z-1));
this.spawnVolume.setCornerTwo(warzone.getWorld().getBlockAt(x+1, y+3, z+1));
} else {
@ -71,16 +75,22 @@ public class Team {
int y = teamSpawn.getBlockY();
int z = teamSpawn.getBlockZ();
// first ring
setBlock(x+1, y-1, z+1, kind);
setBlock(x+1, y-1, z, kind);
setBlock(x+1, y-1, z-1, kind);
setBlock(x, y-1, z+1, kind);
warzone.getWorld().getBlockAt(x, y-1, z).setType(Material.GLOWSTONE);
setBlock(x, y-1, z-1, kind);
setBlock(x-1, y-1, z+1, kind);
setBlock(x-1, y-1, z, kind);
setBlock(x-1, y-1, z-1, kind);
if(warzone.getSpawnStyle().equals(TeamSpawnStyles.INVISIBLE)) {
// nothing but glowstone
warzone.getWorld().getBlockAt(x, y-1, z).setType(Material.GLOWSTONE);
} else {
// first ring
setBlock(x+1, y-1, z+1, kind);
setBlock(x+1, y-1, z, kind);
setBlock(x+1, y-1, z-1, kind);
setBlock(x, y-1, z+1, kind);
warzone.getWorld().getBlockAt(x, y-1, z).setType(Material.GLOWSTONE);
setBlock(x, y-1, z-1, kind);
setBlock(x-1, y-1, z+1, kind);
setBlock(x-1, y-1, z, kind);
setBlock(x-1, y-1, z-1, kind);
}
// Orientation
int yaw = 0;
@ -92,7 +102,19 @@ public class Team {
Block signBlock = null;
int signData = 0;
if(warzone.getSpawnStyle().equals(TeamSpawnStyles.SMALL)){
if(warzone.getSpawnStyle().equals(TeamSpawnStyles.INVISIBLE)){
// INVISIBLE style
signBlock = warzone.getWorld().getBlockAt(x, y, z);
if(yaw >= 0 && yaw < 90) {
signData = 10;
}else if(yaw >= 90 && yaw <= 180) {
signData = 14;
} else if(yaw >= 180 && yaw < 270) {
signData = 2;
} else if(yaw >= 270 && yaw <= 360) {
signData = 6;
}
} else if(warzone.getSpawnStyle().equals(TeamSpawnStyles.SMALL)){
// SMALL style
if(yaw >= 0 && yaw < 90) {
signData = 10;

View File

@ -114,6 +114,8 @@ public class WarMapper {
war.setDefaultSpawnStyle(spawnStyle);
} else if (spawnStyle.equals(TeamSpawnStyles.FLAT)){
war.setDefaultSpawnStyle(spawnStyle);
} else if (spawnStyle.equals(TeamSpawnStyles.INVISIBLE)){
war.setDefaultSpawnStyle(spawnStyle);
}
// default is already initialized to BIG (see Warzone)
}

View File

@ -173,6 +173,8 @@ public class WarzoneMapper {
warzone.setSpawnStyle(spawnStyle);
} else if (spawnStyle.equals(TeamSpawnStyles.FLAT)){
warzone.setSpawnStyle(spawnStyle);
} else if (spawnStyle.equals(TeamSpawnStyles.INVISIBLE)){
warzone.setSpawnStyle(spawnStyle);
}
// default is already initialized to BIG (see Warzone)
}