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")) { } else if(command.equals("resetzone")) {
performResetZone(player, arguments); performResetZone(player, arguments);
} else if(command.equals("deletezone")) { } else if(command.equals("deletezone")) {
performDeleteZone(player); performDeleteZone(player, arguments);
} else if(command.equals("setteam")) { } else if(command.equals("setteam")) {
performSetTeam(player, arguments); performSetTeam(player, arguments);
} else if(command.equals("setteamflag")) { } else if(command.equals("setteamflag")) {
@ -565,14 +565,29 @@ public class War extends JavaPlugin {
} }
} }
public void performDeleteZone(Player player) { public void performDeleteZone(Player player, String[] arguments) {
if(!this.inAnyWarzone(player.getLocation()) && !this.inAnyWarzoneLobby(player.getLocation())) { if(arguments.length == 0 && !this.inAnyWarzone(player.getLocation()) && !this.inAnyWarzoneLobby(player.getLocation())) {
this.badMsg(player, "Usage: /deletezone. " + this.badMsg(player, "Usage: /deletezone [warzone-name]. " +
"Deletes the warzone. " + "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 { } else {
Warzone warzone = this.warzone(player.getLocation()); ZoneLobby lobby = null;
ZoneLobby lobby = this.lobby(player.getLocation()); 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) { if(warzone == null && lobby != null) {
warzone = lobby.getZone(); warzone = lobby.getZone();
} else { } else {
@ -1057,6 +1072,8 @@ public class War extends JavaPlugin {
warzone.setSpawnStyle(spawnStyle); warzone.setSpawnStyle(spawnStyle);
} else if (spawnStyle.equals(TeamSpawnStyles.FLAT)){ } else if (spawnStyle.equals(TeamSpawnStyles.FLAT)){
warzone.setSpawnStyle(spawnStyle); warzone.setSpawnStyle(spawnStyle);
} else if (spawnStyle.equals(TeamSpawnStyles.INVISIBLE)){
warzone.setSpawnStyle(spawnStyle);
} else { } else {
warzone.setSpawnStyle(TeamSpawnStyles.BIG); warzone.setSpawnStyle(TeamSpawnStyles.BIG);
} }

View File

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

View File

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

View File

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

View File

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