mirror of
https://github.com/taoneill/war.git
synced 2024-11-23 18:55:28 +01:00
Fixed team spawns
This commit is contained in:
parent
07b3b21077
commit
84f6abb0d5
@ -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();
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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.");
|
||||
}
|
||||
}
|
||||
|
@ -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) {
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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() {
|
||||
|
Loading…
Reference in New Issue
Block a user