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

View File

@ -2,6 +2,8 @@ package com.tommytony.war;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import bukkit.tommytony.war.War; import bukkit.tommytony.war.War;
@ -15,7 +17,7 @@ import com.tommytony.war.volumes.Volume;
*/ */
public class Monument { public class Monument {
private Location location; private Location location;
private CenteredVolume volume; private Volume volume;
private Team ownerTeam = null; private Team ownerTeam = null;
private final String name; private final String name;
@ -25,13 +27,9 @@ public class Monument {
this.name = name; this.name = name;
this.location = location; this.location = location;
this.warzone = warzone; this.warzone = warzone;
volume = new CenteredVolume(name, volume = new Volume(name, war, warzone.getWorld());
warzone.getWorld().getBlockAt(location.getBlockX(), this.setLocation(location);
location.getBlockY() + 2,
location.getBlockZ()),
7, war, warzone.getWorld());
volume.calculateCorners();
volume.saveBlocks();
this.addMonumentBlocks(); this.addMonumentBlocks();
} }
@ -144,17 +142,20 @@ public class Monument {
return name; return name;
} }
public void setLocation(Location location) { public void setLocation(Location location) {
volume.changeCenter(location); Block locationBlock = warzone.getWorld().getBlockAt(location.getBlockX(), location.getBlockY(), location.getBlockZ());
this.addMonumentBlocks(); 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.location = location;
this.addMonumentBlocks();
} }
public CenteredVolume getVolume() { public Volume getVolume() {
return volume; return volume;
} }
public void setVolume(CenteredVolume newVolume) { public void setVolume(Volume newVolume) {
this.volume = newVolume; this.volume = newVolume;
} }

View File

@ -72,8 +72,8 @@ public class Warzone {
} }
public boolean tooBig() { public boolean tooBig() {
if((getSoutheast().getBlockX() - getNorthwest().getBlockX() > 1000) if((getSoutheast().getBlockX() - getNorthwest().getBlockX() > 500)
|| (getNorthwest().getBlockZ() - getSoutheast().getBlockZ() > 1000)) return true; || (getNorthwest().getBlockZ() - getSoutheast().getBlockZ() > 500)) return true;
return false; return false;
} }
@ -675,7 +675,7 @@ public class Warzone {
// because player can go around corner // because player can go around corner
lobby.initialize(); lobby.initialize();
} }
war.getLogger().info("Reset " + reset + " blocks in " + guard.getWall() + "wall of warzone " + name); war.getLogger().info("Reset " + reset + " blocks in " + guard.getWall() + " wall of warzone " + name);
} }
} }
// now remove those zone guards // now remove those zone guards

View File

@ -160,6 +160,19 @@ public class ZoneLobby {
// set zone tp // set zone tp
zoneTeleportBlock = lobbyMiddleWallBlock.getFace(wall, 6); zoneTeleportBlock = lobbyMiddleWallBlock.getFace(wall, 6);
warzone.setTeleport(new Location(warzone.getWorld(), zoneTeleportBlock.getX(), zoneTeleportBlock.getY(), zoneTeleportBlock.getZ())); 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 { } else {
war.getLogger().warning("Failed to initalize zone " + warzone.getName()); war.getLogger().warning("Failed to initalize zone " + warzone.getName());
} }

View File

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

View File

@ -164,7 +164,7 @@ public class WarzoneMapper {
// monument blocks // monument blocks
for(Monument monument: warzone.getMonuments()) { 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 // team spawn blocks