diff --git a/war/src/main/java/com/tommytony/war/Monument.java b/war/src/main/java/com/tommytony/war/Monument.java index 19fa89d..819a045 100644 --- a/war/src/main/java/com/tommytony/war/Monument.java +++ b/war/src/main/java/com/tommytony/war/Monument.java @@ -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(); } diff --git a/war/src/main/java/com/tommytony/war/Team.java b/war/src/main/java/com/tommytony/war/Team.java index 7fbd4e3..846e2fd 100644 --- a/war/src/main/java/com/tommytony/war/Team.java +++ b/war/src/main/java/com/tommytony/war/Team.java @@ -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 diff --git a/war/src/main/java/com/tommytony/war/mappers/WarMapper.java b/war/src/main/java/com/tommytony/war/mappers/WarMapper.java index 70a4424..fcbb484 100644 --- a/war/src/main/java/com/tommytony/war/mappers/WarMapper.java +++ b/war/src/main/java/com/tommytony/war/mappers/WarMapper.java @@ -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."); } } diff --git a/war/src/main/java/com/tommytony/war/mappers/WarzoneMapper.java b/war/src/main/java/com/tommytony/war/mappers/WarzoneMapper.java index 77c69a1..86cd3bd 100644 --- a/war/src/main/java/com/tommytony/war/mappers/WarzoneMapper.java +++ b/war/src/main/java/com/tommytony/war/mappers/WarzoneMapper.java @@ -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) { diff --git a/war/src/main/java/com/tommytony/war/volumes/CenteredVolume.java b/war/src/main/java/com/tommytony/war/volumes/CenteredVolume.java index a2ddcf5..aa0a953 100644 --- a/war/src/main/java/com/tommytony/war/volumes/CenteredVolume.java +++ b/war/src/main/java/com/tommytony/war/volumes/CenteredVolume.java @@ -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; + } + } diff --git a/war/src/main/java/com/tommytony/war/volumes/Volume.java b/war/src/main/java/com/tommytony/war/volumes/Volume.java index c7f084f..2704140 100644 --- a/war/src/main/java/com/tommytony/war/volumes/Volume.java +++ b/war/src/main/java/com/tommytony/war/volumes/Volume.java @@ -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() {