Not using the CenteredVolume anymore. Monuments reset properly. Lit up the lobby. Adding a team resets the lobby correctly, but not deleting. Hmm.

This commit is contained in:
taoneill 2011-01-16 02:41:57 -05:00
parent 05d5a8d8be
commit f099539e39
6 changed files with 67 additions and 44 deletions

View File

@ -116,9 +116,9 @@ public class WarPlayerListener extends PlayerListener {
// /teams
else if(command.equals("teams")){
if(!war.inAnyWarzone(player.getLocation())) {
if(!war.inAnyWarzone(player.getLocation()) && !war.inAnyWarzoneLobby(player.getLocation())) {
player.sendMessage(war.str("Usage: /teams. " +
"Must be in a warzone (try /warzones and /warzone)."));
"Must be in a warzone or zone lobby (try /war, /zones and /zone)."));
} else {
player.sendMessage(war.str("" + getAllTeamsMsg(player)));
}
@ -498,6 +498,11 @@ public class WarPlayerListener extends PlayerListener {
newTeam.setRemainingTickets(warzone.getLifePool());
warzone.getTeams().add(newTeam);
newTeam.setTeamSpawn(player.getLocation());
if(warzone.getLobby() != null) {
warzone.getLobby().getVolume().resetBlocks();
warzone.getVolume().resetWallBlocks(warzone.getLobby().getWall());
warzone.getLobby().initialize();
}
player.sendMessage(war.str("Team " + name + " created with spawn here."));
}
@ -513,7 +518,7 @@ public class WarPlayerListener extends PlayerListener {
" Deletes the team and its spawn. " +
"Must be in a warzone (try /zones and /zone). "));
} else {
String name = TeamMaterials.teamMaterialToString(TeamMaterials.teamMaterialFromString(arguments[1]));
String name = TeamMaterials.teamMaterialToString(TeamMaterials.teamMaterialFromString(arguments[0]));
Warzone warzone = war.warzone(player.getLocation());
List<Team> teams = warzone.getTeams();
Team team = null;
@ -526,6 +531,11 @@ public class WarPlayerListener extends PlayerListener {
team.getVolume().resetBlocks();
warzone.getTeams().remove(team);
WarzoneMapper.save(war, warzone, false);
if(warzone.getLobby() != null) {
warzone.getLobby().getVolume().resetBlocks();
warzone.getVolume().resetWallBlocks(warzone.getLobby().getWall());
warzone.getLobby().initialize();
}
player.sendMessage(war.str("Team " + name + " removed."));
} else {
player.sendMessage(war.str("No such team."));
@ -534,7 +544,7 @@ public class WarPlayerListener extends PlayerListener {
event.setCancelled(true);
}
// /monument
// /setmonument
else if(command.equals("setmonument")) {
if(!war.inAnyWarzone(player.getLocation())) {
player.sendMessage(war.str("Usage: /setmonument <name>. Creates or moves a monument. Must be in warzone."));
@ -644,7 +654,6 @@ public class WarPlayerListener extends PlayerListener {
synchronized(player) {
if(!roundOver && !war.inAnyWarzone(player.getLocation())) { // only respawn him if he isnt back at zone yet
playerWarzone.respawnPlayer(event, team, player);
player.sendMessage(war.str("You died!"));
team.resetSign();
war.getLogger().log(Level.INFO, player.getName() + " died and was tp'd back to team " + team.getName() + "'s spawn");
} else {

View File

@ -2,6 +2,8 @@ package com.tommytony.war;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import bukkit.tommytony.war.War;
@ -15,7 +17,7 @@ import com.tommytony.war.volumes.Volume;
*/
public class Monument {
private Location location;
private CenteredVolume volume;
private Volume volume;
private Team ownerTeam = null;
private final String name;
@ -25,13 +27,9 @@ public class Monument {
this.name = name;
this.location = location;
this.warzone = warzone;
volume = new CenteredVolume(name,
warzone.getWorld().getBlockAt(location.getBlockX(),
location.getBlockY() + 2,
location.getBlockZ()),
7, war, warzone.getWorld());
volume.calculateCorners();
volume.saveBlocks();
volume = new Volume(name, war, warzone.getWorld());
this.setLocation(location);
this.addMonumentBlocks();
}
@ -145,16 +143,19 @@ public class Monument {
}
public void setLocation(Location location) {
volume.changeCenter(location);
this.addMonumentBlocks();
Block locationBlock = warzone.getWorld().getBlockAt(location.getBlockX(), location.getBlockY(), location.getBlockZ());
volume.setCornerOne(locationBlock.getFace(BlockFace.DOWN).getFace(BlockFace.EAST, 2).getFace(BlockFace.SOUTH, 2));
volume.setCornerTwo(locationBlock.getFace(BlockFace.UP, 2).getFace(BlockFace.WEST, 2).getFace(BlockFace.NORTH, 2));
volume.saveBlocks();
this.location = location;
this.addMonumentBlocks();
}
public CenteredVolume getVolume() {
public Volume getVolume() {
return volume;
}
public void setVolume(CenteredVolume newVolume) {
public void setVolume(Volume newVolume) {
this.volume = newVolume;
}

View File

@ -72,8 +72,8 @@ public class Warzone {
}
public boolean tooBig() {
if((getSoutheast().getBlockX() - getNorthwest().getBlockX() > 1000)
|| (getNorthwest().getBlockZ() - getSoutheast().getBlockZ() > 1000)) return true;
if((getSoutheast().getBlockX() - getNorthwest().getBlockX() > 500)
|| (getNorthwest().getBlockZ() - getSoutheast().getBlockZ() > 500)) return true;
return false;
}

View File

@ -160,6 +160,19 @@ public class ZoneLobby {
// set zone tp
zoneTeleportBlock = lobbyMiddleWallBlock.getFace(wall, 6);
warzone.setTeleport(new Location(warzone.getWorld(), zoneTeleportBlock.getX(), zoneTeleportBlock.getY(), zoneTeleportBlock.getZ()));
// lets get some light in here
if(wall == BlockFace.NORTH || wall == BlockFace.SOUTH) {
lobbyMiddleWallBlock.getFace(BlockFace.DOWN).getFace(BlockFace.WEST, lobbyHalfSide - 1).getFace(wall, 3).setType(Material.GLOWSTONE);
lobbyMiddleWallBlock.getFace(BlockFace.DOWN).getFace(BlockFace.WEST, lobbyHalfSide - 1).getFace(wall, 7).setType(Material.GLOWSTONE);
lobbyMiddleWallBlock.getFace(BlockFace.DOWN).getFace(BlockFace.EAST, lobbyHalfSide - 1).getFace(wall, 3).setType(Material.GLOWSTONE);
lobbyMiddleWallBlock.getFace(BlockFace.DOWN).getFace(BlockFace.EAST, lobbyHalfSide - 1).getFace(wall, 7).setType(Material.GLOWSTONE);
} else {
lobbyMiddleWallBlock.getFace(BlockFace.DOWN).getFace(BlockFace.NORTH, lobbyHalfSide - 1).getFace(wall, 3).setType(Material.GLOWSTONE);
lobbyMiddleWallBlock.getFace(BlockFace.DOWN).getFace(BlockFace.NORTH, lobbyHalfSide - 1).getFace(wall, 7).setType(Material.GLOWSTONE);
lobbyMiddleWallBlock.getFace(BlockFace.DOWN).getFace(BlockFace.SOUTH, lobbyHalfSide - 1).getFace(wall, 3).setType(Material.GLOWSTONE);
lobbyMiddleWallBlock.getFace(BlockFace.DOWN).getFace(BlockFace.SOUTH, lobbyHalfSide - 1).getFace(wall, 7).setType(Material.GLOWSTONE);
}
} else {
war.getLogger().warning("Failed to initalize zone " + warzone.getName());
}

View File

@ -38,12 +38,12 @@ public class VolumeMapper {
return volume;
}
public static CenteredVolume loadCenteredVolume(String volumeName, String zoneName, int sideSize,
War war, World world) {
CenteredVolume volume = new CenteredVolume(volumeName, null, sideSize, war, world);
load(volume, zoneName, war, world);
return volume;
}
// public static CenteredVolume loadCenteredVolume(String volumeName, String zoneName, int sideSize,
// War war, World world) {
// CenteredVolume volume = new CenteredVolume(volumeName, null, sideSize, war, world);
// load(volume, zoneName, war, world);
// return volume;
// }
public static void load(Volume volume, String zoneName, War war, World world) {
BufferedReader in = null;
@ -60,13 +60,13 @@ public class VolumeMapper {
int y2 = Integer.parseInt(in.readLine());
int z2 = Integer.parseInt(in.readLine());
if(volume instanceof CenteredVolume) {
((CenteredVolume)volume).setCenter(world.getBlockAt(x1, y1, z1));
((CenteredVolume)volume).calculateCorners();
} else {
// if(volume instanceof CenteredVolume) {
// ((CenteredVolume)volume).setCenter(world.getBlockAt(x1, y1, z1));
// ((CenteredVolume)volume).calculateCorners();
// } else {
volume.setCornerOne(world.getBlockAt(x1, y1, z1));
volume.setCornerTwo(world.getBlockAt(x2, y2, z2));
}
// }
volume.setBlockInfos(new BlockInfo[volume.getSizeX()][volume.getSizeY()][volume.getSizeZ()]);
for(int i = 0; i < volume.getSizeX(); i++){
@ -121,16 +121,16 @@ public class VolumeMapper {
try {
if(zoneName.equals("")) out = new BufferedWriter(new FileWriter(new File("War/volume-" + volume.getName() + ".dat")));
else out = new BufferedWriter(new FileWriter(new File("War/warzone-" + zoneName + "/volume-" + volume.getName() + ".dat")));
if(volume instanceof CenteredVolume) {
out.write("center"); out.newLine();
out.write(Integer.toString(volume.getCornerOne().getX())); out.newLine();
out.write(Integer.toString(volume.getCornerOne().getY())); out.newLine();
out.write(Integer.toString(volume.getCornerOne().getZ())); out.newLine();
out.write("nothing"); out.newLine();
out.write(Integer.toString(0)); out.newLine();
out.write(Integer.toString(0)); out.newLine();
out.write(Integer.toString(0)); out.newLine();
} else {
// if(volume instanceof CenteredVolume) {
// out.write("center"); out.newLine();
// out.write(Integer.toString(volume.getCornerOne().getX())); out.newLine();
// out.write(Integer.toString(volume.getCornerOne().getY())); out.newLine();
// out.write(Integer.toString(volume.getCornerOne().getZ())); out.newLine();
// out.write("nothing"); out.newLine();
// out.write(Integer.toString(0)); out.newLine();
// out.write(Integer.toString(0)); out.newLine();
// out.write(Integer.toString(0)); out.newLine();
// } else {
out.write("corner1"); out.newLine();
out.write(Integer.toString(volume.getCornerOne().getX())); out.newLine();
out.write(Integer.toString(volume.getCornerOne().getY())); out.newLine();
@ -139,7 +139,7 @@ public class VolumeMapper {
out.write(Integer.toString(volume.getCornerTwo().getX())); out.newLine();
out.write(Integer.toString(volume.getCornerTwo().getY())); out.newLine();
out.write(Integer.toString(volume.getCornerTwo().getZ())); out.newLine();
}
// }
for(int i = 0; i < volume.getSizeX(); i++){
for(int j = 0; j < volume.getSizeY(); j++) {

View File

@ -164,7 +164,7 @@ public class WarzoneMapper {
// monument blocks
for(Monument monument: warzone.getMonuments()) {
monument.setVolume(VolumeMapper.loadCenteredVolume(monument.getName(),warzone.getName(), 7, war, world));
monument.setVolume(VolumeMapper.loadVolume(monument.getName(),warzone.getName(), war, world));
}
// team spawn blocks