Fixed team spawns

This commit is contained in:
taoneill 2011-01-09 20:39:59 -05:00
parent 07b3b21077
commit 84f6abb0d5
6 changed files with 49 additions and 36 deletions

View File

@ -137,7 +137,7 @@ public class Monument {
int y = location.getBlockY();
int z = location.getBlockZ();
((CenteredVolume)volume).setCenter(warzone.getWorld().getBlockAt(x, y, z)); // resets the volume blocks
volume.changeCenter(location);
this.addMonumentBlocks();
}

View File

@ -35,8 +35,7 @@ public class Team {
this.teamSpawn = teamSpawn;
// this resets the block to old state
volume.setCenter(warzone.getWorld().getBlockAt(teamSpawn.getBlockX(), teamSpawn.getBlockY(), teamSpawn.getBlockZ()));
volume.setSideSize(5);
volume.changeCenter(teamSpawn);
volume.saveBlocks();
// Set the spawn

View File

@ -9,7 +9,7 @@ import com.tommytony.war.Warzone;
public class WarMapper {
public static void load(War war) {
war.getLogger().info("Loading war config...");
//war.getLogger().info("Loading war config...");
(new File(war.getName())).mkdir();
PropertiesFile warConfig = new PropertiesFile(war.getName() + "/war.txt");
try {
@ -69,7 +69,7 @@ public class WarMapper {
}
public static void save(War war) {
war.getLogger().info("Saving war config...");
//war.getLogger().info("Saving war config...");
PropertiesFile warConfig = new PropertiesFile(war.getName() + "/war.txt");
String warzonesStr = "";
@ -95,6 +95,6 @@ public class WarMapper {
warConfig.save();
warConfig.close();
war.getLogger().info("Saved war config.");
//war.getLogger().info("Saved war config.");
}
}

View File

@ -18,7 +18,7 @@ import java.util.List;
public class WarzoneMapper {
public static Warzone load(War war, String name, boolean loadBlocks) {
war.getLogger().info("Loading warzone " + name + " config and blocks...");
//war.getLogger().info("Loading warzone " + name + " config and blocks...");
PropertiesFile warzoneConfig = new PropertiesFile(war.getName() + "/warzone-" + name + ".txt");
try {
warzoneConfig.load();
@ -38,7 +38,7 @@ public class WarzoneMapper {
try {
warzoneConfig.load();
} catch (IOException e) {
war.getLogger().info("Failed to reload warzone-" + name + ".txt file after creating it.");
//war.getLogger().info("Failed to reload warzone-" + name + ".txt file after creating it.");
e.printStackTrace();
}
}
@ -154,9 +154,9 @@ public class WarzoneMapper {
}
warzoneBlocksFile.close();
war.getLogger().info("Loaded warzone " + name + " config and blocks.");
//war.getLogger().info("Loaded warzone " + name + " config and blocks.");
} else {
war.getLogger().info("Loaded warzone " + name + " config.");
//war.getLogger().info("Loaded warzone " + name + " config.");
}
return warzone;
@ -165,7 +165,7 @@ public class WarzoneMapper {
public static void save(War war, Warzone warzone, boolean saveBlocks) {
PropertiesFile warzoneConfig = new PropertiesFile(war.getName() + "/warzone-" + warzone.getName() + ".txt");
war.getLogger().info("Saving warzone " + warzone.getName() + "...");
//war.getLogger().info("Saving warzone " + warzone.getName() + "...");
// name
warzoneConfig.setString("name", warzone.getName());
@ -253,11 +253,11 @@ public class WarzoneMapper {
warzoneBlocksFile.close();
}
if(saveBlocks) {
war.getLogger().info("Saved warzone " + warzone.getName() + " config and blocks.");
} else {
war.getLogger().info("Saved warzone " + warzone.getName() + " config.");
}
// if(saveBlocks) {
// war.getLogger().info("Saved warzone " + warzone.getName() + " config and blocks.");
// } else {
// war.getLogger().info("Saved warzone " + warzone.getName() + " config.");
// }
}
public static void delete(War war, String name) {

View File

@ -17,12 +17,22 @@ public class CenteredVolume extends Volume {
setSideSize(sideSize);
}
public void setCenter(Block block) {
public void changeCenter(Location newCenter) {
changeCenter(getWarzone().getWorld().getBlockAt(newCenter.getBlockX(),
newCenter.getBlockY(),
newCenter.getBlockZ()),
this.sideSize);
}
public void changeCenter(Block newCenter, int sideSize) {
this.resetBlocks();
this.center = newCenter;
this.sideSize = sideSize;
this.calculateCorners();
}
private void setCenter(Block block) {
this.center = block;
if(sideSize != -1) {
calculateCorners();
}
}
private void calculateCorners() {
@ -34,20 +44,24 @@ public class CenteredVolume extends Volume {
Block cornerOne = getWarzone().getWorld().getBlockAt(x, y, z);
setCornerOne(cornerOne);
int bottomHalfOfSide = sideSize - topHalfOfSide;
x = center.getX() - bottomHalfOfSide;
y = center.getY() - bottomHalfOfSide;
z = center.getZ() - bottomHalfOfSide;
Block cornerTwo = getWarzone().getWorld().getBlockAt(x, y, z);
setCornerTwo(cornerTwo);
}
public void setSideSize(int sideSize) {
this.resetBlocks();
this.sideSize = sideSize;
if(center != null) {
calculateCorners();
if(sideSize % 2 == 0) { // not a real center, bottom half is larger by 1
int bottomHalfOfSide = sideSize - topHalfOfSide;
x = center.getX() - bottomHalfOfSide;
y = center.getY() - bottomHalfOfSide;
z = center.getZ() - bottomHalfOfSide;
Block cornerTwo = getWarzone().getWorld().getBlockAt(x, y, z);
setCornerTwo(cornerTwo);
} else {
x = center.getX() - topHalfOfSide;
y = center.getY() - topHalfOfSide;
z = center.getZ() - topHalfOfSide;
Block cornerTwo = getWarzone().getWorld().getBlockAt(x, y, z);
setCornerTwo(cornerTwo);
}
}
private void setSideSize(int sideSize) {
this.sideSize = sideSize;
}
}

View File

@ -169,15 +169,15 @@ public class Volume {
}
public int getSizeX() {
return getMaxX() - getMinX();
return getMaxX() - getMinX() + 1;
}
public int getSizeY() {
return getMaxY() - getMinY();
return getMaxY() - getMinY() + 1;
}
public int getSizeZ() {
return getMaxZ() - getMinZ();
return getMaxZ() - getMinZ() + 1;
}
public boolean isSaved() {