Remove deprecated BlockInfo in favor of Location/BlockState

BlockInfo kept making me cringe every time I had to look at the code. More importantly it only had support for storing item IDs and no data. It was way obsolete versus new API.
This commit is contained in:
cmastudios 2013-10-05 02:04:28 -05:00
parent 6e9efc7a8a
commit 1722c86a71
18 changed files with 452 additions and 1050 deletions

View File

@ -39,6 +39,9 @@
<url>http://ci.tommytony.com</url>
</ciManagement>
<scm>
<connection>scm:git:git://github.com/taoneill/war.git</connection>
<developerConnection>scm:git:git@github.com:taoneill/war.git</developerConnection>
<tag>HEAD</tag>
<url>https://github.com/taoneill/war</url>
</scm>
<build>

View File

@ -36,7 +36,6 @@ import com.tommytony.war.config.TeamSpawnStyle;
import com.tommytony.war.structure.Bomb;
import com.tommytony.war.structure.Cake;
import com.tommytony.war.utility.Direction;
import com.tommytony.war.volume.BlockInfo;
import com.tommytony.war.volume.Volume;
/**
@ -580,19 +579,13 @@ public class Team {
public void initializeTeamFlag() {
// make air (old two-high above floor)
Volume airGap = new Volume("airgap", this.warzone.getWorld());
airGap.setCornerOne(new BlockInfo(
this.flagVolume.getCornerOne().getX(),
this.flagVolume.getCornerOne().getY() + 1,
this.flagVolume.getCornerOne().getZ(),
0,
(byte)0));
airGap.setCornerTwo(new BlockInfo(
this.flagVolume.getCornerTwo().getX(),
this.flagVolume.getCornerOne().getY() + 2,
this.flagVolume.getCornerTwo().getZ(),
0,
(byte)0));
Volume airGap = new Volume(new Location(this.flagVolume.getWorld(),
this.flagVolume.getCornerOne().getX(), this.flagVolume
.getCornerOne().getY() + 1, this.flagVolume
.getCornerOne().getZ()), new Location(
this.flagVolume.getWorld(), this.flagVolume.getCornerTwo()
.getX(), this.flagVolume.getCornerOne().getY() + 2,
this.flagVolume.getCornerTwo().getZ()));
airGap.setToMaterial(Material.AIR);
// Set the flag blocks

View File

@ -61,7 +61,6 @@ import com.tommytony.war.utility.Loadout;
import com.tommytony.war.utility.LoadoutSelection;
import com.tommytony.war.utility.PlayerState;
import com.tommytony.war.utility.PotionEffectHelper;
import com.tommytony.war.volume.BlockInfo;
import com.tommytony.war.volume.Volume;
import com.tommytony.war.volume.ZoneVolume;
@ -252,11 +251,11 @@ public class Warzone {
}
}
int saved = this.volume.saveBlocks();
this.volume.saveBlocks();
if (clearArtifacts) {
this.initializeZone(); // bring back stuff
}
return saved;
return this.volume.size();
}
return 0;
}
@ -1552,10 +1551,15 @@ public class Warzone {
for (Team maybeOpponent : this.getTeams()) {
if (maybeOpponent != team) {
for (Volume teamSpawnVolume : maybeOpponent.getSpawnVolumes().values()) {
Volume periphery = new Volume("periphery", this.getWorld());
periphery.setCornerOne(new BlockInfo(teamSpawnVolume.getMinX()-1 , teamSpawnVolume.getMinY()-1, teamSpawnVolume.getMinZ()-1, 0, (byte)0));
periphery.setCornerTwo(new BlockInfo(teamSpawnVolume.getMaxX()+1, teamSpawnVolume.getMaxY()+1, teamSpawnVolume.getMaxZ()+1, 0, (byte)0));
Volume periphery = new Volume(new Location(
teamSpawnVolume.getWorld(),
teamSpawnVolume.getMinX() - 1,
teamSpawnVolume.getMinY() - 1,
teamSpawnVolume.getMinZ() - 1), new Location(
teamSpawnVolume.getWorld(),
teamSpawnVolume.getMaxX() + 1,
teamSpawnVolume.getMaxY() + 1,
teamSpawnVolume.getMaxZ() + 1));
if (periphery.contains(block)) {
return true;
}

View File

@ -41,7 +41,7 @@ public class ZoneSetter {
warzone = new Warzone(this.player.getLocation().getWorld(), this.zoneName);
warzone.addAuthor(player.getName());
War.war.getIncompleteZones().add(warzone);
warzone.getVolume().setNorthwest(northwestBlock);
warzone.getVolume().setNorthwest(northwestBlock.getLocation());
War.war.msg(this.player, "Warzone " + warzone.getName() + " created. Northwesternmost point set to x:" + warzone.getVolume().getNorthwestX() + " z:" + warzone.getVolume().getNorthwestZ() + ". ");
War.war.log(player.getName() + " created warzone " + zoneName + " by setting its nw corner", Level.INFO);
} else if (!this.isPlayerAuthorOfZoneOrAdmin(warzone)) {
@ -49,7 +49,7 @@ public class ZoneSetter {
} else {
// change existing warzone
this.resetWarzone(warzone, msgString);
warzone.getVolume().setNorthwest(northwestBlock);
warzone.getVolume().setNorthwest(northwestBlock.getLocation());
msgString.append("Warzone " + warzone.getName() + " modified. Northwesternmost point set to x:" + warzone.getVolume().getNorthwestX() + " z:" + warzone.getVolume().getNorthwestZ() + ". ");
War.war.log(player.getName() + " updated warzone " + zoneName + " by setting its nw corner", Level.INFO);
}
@ -86,7 +86,7 @@ public class ZoneSetter {
warzone = new Warzone(this.player.getLocation().getWorld(), this.zoneName);
warzone.addAuthor(player.getName());
War.war.getIncompleteZones().add(warzone);
warzone.getVolume().setSoutheast(southeastBlock);
warzone.getVolume().setSoutheast(southeastBlock.getLocation());
War.war.msg(this.player, "Warzone " + warzone.getName() + " created. Southeasternmost point set to x:" + warzone.getVolume().getSoutheastX() + " z:" + warzone.getVolume().getSoutheastZ() + ". ");
War.war.log(player.getName() + " created warzone " + zoneName + " by setting its se corner", Level.INFO);
} else if (!this.isPlayerAuthorOfZoneOrAdmin(warzone)) {
@ -94,7 +94,7 @@ public class ZoneSetter {
} else {
// change existing warzone
this.resetWarzone(warzone, msgString);
warzone.getVolume().setSoutheast(southeastBlock);
warzone.getVolume().setSoutheast(southeastBlock.getLocation());
msgString.append("Warzone " + warzone.getName() + " modified. Southeasternmost point set to x:" + warzone.getVolume().getSoutheastX() + " z:" + warzone.getVolume().getSoutheastZ() + ". ");
War.war.log(player.getName() + " updated warzone " + zoneName + " by setting its se corner", Level.INFO);
}
@ -220,8 +220,8 @@ public class ZoneSetter {
if (warzone.getLobby() != null && warzone.getLobby().getVolume() != null) {
warzone.getLobby().getVolume().resetBlocks();
}
int reset = warzone.getVolume().resetBlocks();
msgString.append(reset + " blocks reset. ");
warzone.getVolume().resetBlocks();
msgString.append(warzone.getVolume().size() + " blocks reset. ");
}
}

View File

@ -7,27 +7,9 @@ import org.bukkit.inventory.ItemStack;
import com.tommytony.war.War;
@SuppressWarnings("deprecation")
public class LoadoutTxtMapper {
public static String fromLoadoutToString(HashMap<Integer, ItemStack> loadout) {
String loadoutString = "";
for (Integer slot : loadout.keySet()) {
ItemStack item = loadout.get(slot);
if (item != null) {
loadoutString += item.getTypeId() + "," + item.getAmount() + "," + slot + "," + item.getDurability() + "," + item.getData().getData();
if (item.getEnchantments().keySet().size() > 0) {
String enchantmentsStr = "";
for (Enchantment enchantment : item.getEnchantments().keySet()) {
enchantmentsStr += enchantment.getId() + ":" + item.getEnchantments().get(enchantment) + "::";
}
loadoutString += "," + enchantmentsStr;
}
}
loadoutString += ";";
}
return loadoutString;
}
public static void fromStringToLoadout(String loadoutString, HashMap<Integer, ItemStack> destinationLoadout) {
String[] rewardStrSplit = loadoutString.split(";");
destinationLoadout.clear();

View File

@ -298,19 +298,19 @@ public class PreDeGaulleZoneVolumeMapper {
out.write("corner1");
out.newLine();
out.write(Integer.toString(volume.getCornerOne().getX()));
out.write(Integer.toString(volume.getCornerOne().getBlockX()));
out.newLine();
out.write(Integer.toString(volume.getCornerOne().getY()));
out.write(Integer.toString(volume.getCornerOne().getBlockY()));
out.newLine();
out.write(Integer.toString(volume.getCornerOne().getZ()));
out.write(Integer.toString(volume.getCornerOne().getBlockZ()));
out.newLine();
out.write("corner2");
out.newLine();
out.write(Integer.toString(volume.getCornerTwo().getX()));
out.write(Integer.toString(volume.getCornerTwo().getBlockX()));
out.newLine();
out.write(Integer.toString(volume.getCornerTwo().getY()));
out.write(Integer.toString(volume.getCornerTwo().getBlockY()));
out.newLine();
out.write(Integer.toString(volume.getCornerTwo().getZ()));
out.write(Integer.toString(volume.getCornerTwo().getBlockZ()));
out.newLine();
int x = 0;

View File

@ -152,19 +152,19 @@ public class VolumeMapper {
out.write("corner1");
out.newLine();
out.write(Integer.toString(volume.getCornerOne().getX()));
out.write(Integer.toString(volume.getCornerOne().getBlockX()));
out.newLine();
out.write(Integer.toString(volume.getCornerOne().getY()));
out.write(Integer.toString(volume.getCornerOne().getBlockY()));
out.newLine();
out.write(Integer.toString(volume.getCornerOne().getZ()));
out.write(Integer.toString(volume.getCornerOne().getBlockZ()));
out.newLine();
out.write("corner2");
out.newLine();
out.write(Integer.toString(volume.getCornerTwo().getX()));
out.write(Integer.toString(volume.getCornerTwo().getBlockX()));
out.newLine();
out.write(Integer.toString(volume.getCornerTwo().getY()));
out.write(Integer.toString(volume.getCornerTwo().getBlockY()));
out.newLine();
out.write(Integer.toString(volume.getCornerTwo().getZ()));
out.write(Integer.toString(volume.getCornerTwo().getBlockZ()));
out.newLine();
int blockWrites = 0;
for (int i = 0; i < volume.getSizeX(); i++) {

View File

@ -299,19 +299,19 @@ public class ZoneVolumeMapper {
cornersWriter.write("corner1");
cornersWriter.newLine();
cornersWriter.write(Integer.toString(volume.getCornerOne().getX()));
cornersWriter.write(Integer.toString(volume.getCornerOne().getBlockX()));
cornersWriter.newLine();
cornersWriter.write(Integer.toString(volume.getCornerOne().getY()));
cornersWriter.write(Integer.toString(volume.getCornerOne().getBlockY()));
cornersWriter.newLine();
cornersWriter.write(Integer.toString(volume.getCornerOne().getZ()));
cornersWriter.write(Integer.toString(volume.getCornerOne().getBlockZ()));
cornersWriter.newLine();
cornersWriter.write("corner2");
cornersWriter.newLine();
cornersWriter.write(Integer.toString(volume.getCornerTwo().getX()));
cornersWriter.write(Integer.toString(volume.getCornerTwo().getBlockX()));
cornersWriter.newLine();
cornersWriter.write(Integer.toString(volume.getCornerTwo().getY()));
cornersWriter.write(Integer.toString(volume.getCornerTwo().getBlockY()));
cornersWriter.newLine();
cornersWriter.write(Integer.toString(volume.getCornerTwo().getZ()));
cornersWriter.write(Integer.toString(volume.getCornerTwo().getBlockZ()));
cornersWriter.newLine();
int x = 0;

View File

@ -9,7 +9,6 @@ import org.bukkit.entity.Player;
import com.tommytony.war.Warzone;
import com.tommytony.war.utility.Direction;
import com.tommytony.war.volume.BlockInfo;
import com.tommytony.war.volume.Volume;
/**
@ -35,19 +34,12 @@ public class Bomb {
public void addBombBlocks() {
// make air (old two-high above floor)
Volume airGap = new Volume("airgap", this.warzone.getWorld());
airGap.setCornerOne(new BlockInfo(
this.volume.getCornerOne().getX(),
this.volume.getCornerOne().getY() + 1,
this.volume.getCornerOne().getZ(),
0,
(byte)0));
airGap.setCornerTwo(new BlockInfo(
this.volume.getCornerTwo().getX(),
this.volume.getCornerOne().getY() + 3,
this.volume.getCornerTwo().getZ(),
0,
(byte)0));
Volume airGap = new Volume(new Location(this.volume.getWorld(),
this.volume.getCornerOne().getX(), this.volume.getCornerOne()
.getY() + 1, this.volume.getCornerOne().getZ()),
new Location(this.volume.getWorld(), this.volume.getCornerTwo()
.getX(), this.volume.getCornerOne().getY() + 3,
this.volume.getCornerTwo().getZ()));
airGap.setToMaterial(Material.AIR);
int x = this.location.getBlockX();

View File

@ -9,7 +9,6 @@ import org.bukkit.entity.Player;
import com.tommytony.war.Warzone;
import com.tommytony.war.utility.Direction;
import com.tommytony.war.volume.BlockInfo;
import com.tommytony.war.volume.Volume;
/**
@ -35,19 +34,12 @@ public class Cake {
public void addCakeBlocks() {
// make air (old two-high above floor)
Volume airGap = new Volume("airgap", this.warzone.getWorld());
airGap.setCornerOne(new BlockInfo(
this.volume.getCornerOne().getX(),
this.volume.getCornerOne().getY() + 1,
this.volume.getCornerOne().getZ(),
0,
(byte)0));
airGap.setCornerTwo(new BlockInfo(
this.volume.getCornerTwo().getX(),
this.volume.getCornerOne().getY() + 2,
this.volume.getCornerTwo().getZ(),
0,
(byte)0));
Volume airGap = new Volume(new Location(this.volume.getWorld(),
this.volume.getCornerOne().getX(), this.volume.getCornerOne()
.getY() + 1, this.volume.getCornerOne().getZ()),
new Location(this.volume.getWorld(), this.volume.getCornerTwo()
.getX(), this.volume.getCornerOne().getY() + 2,
this.volume.getCornerTwo().getZ()));
airGap.setToMaterial(Material.AIR);
int x = this.location.getBlockX();

View File

@ -10,7 +10,6 @@ import org.bukkit.material.MaterialData;
import com.tommytony.war.Team;
import com.tommytony.war.Warzone;
import com.tommytony.war.utility.Direction;
import com.tommytony.war.volume.BlockInfo;
import com.tommytony.war.volume.Volume;
/**
@ -36,19 +35,12 @@ public class Monument {
public void addMonumentBlocks() {
// make air (old three-high above floor)
Volume airGap = new Volume("airgap", this.warzone.getWorld());
airGap.setCornerOne(new BlockInfo(
this.volume.getCornerOne().getX(),
this.volume.getCornerOne().getY() + 1,
this.volume.getCornerOne().getZ(),
0,
(byte)0));
airGap.setCornerTwo(new BlockInfo(
this.volume.getCornerTwo().getX(),
this.volume.getCornerOne().getY() + 3,
this.volume.getCornerTwo().getZ(),
0,
(byte)0));
Volume airGap = new Volume(new Location(this.volume.getWorld(),
this.volume.getCornerOne().getX(), this.volume.getCornerOne()
.getY() + 1, this.volume.getCornerOne().getZ()),
new Location(this.volume.getWorld(), this.volume.getCornerTwo()
.getX(), this.volume.getCornerOne().getY() + 3,
this.volume.getCornerTwo().getZ()));
airGap.setToMaterial(Material.AIR);
this.ownerTeam = null;

View File

@ -18,7 +18,6 @@ import com.tommytony.war.Warzone;
import com.tommytony.war.config.TeamConfig;
import com.tommytony.war.config.WarzoneConfig;
import com.tommytony.war.utility.Direction;
import com.tommytony.war.volume.BlockInfo;
import com.tommytony.war.volume.Volume;
/**
@ -171,7 +170,7 @@ public class WarHub {
warhubTpVolume.setToMaterial(Material.AIR);
// draw gates
Block currentGateBlock = BlockInfo.getBlock(this.location.getWorld(), this.volume.getCornerOne()).getRelative(BlockFace.UP).getRelative(front, hubDepth).getRelative(right, 2);
Block currentGateBlock = this.volume.getCornerOne().getBlock().getRelative(BlockFace.UP).getRelative(front, hubDepth).getRelative(right, 2);
for (Warzone zone : War.war.getWarzones()) { // gonna use the index to find it again
if (!zone.getWarzoneConfig().getBoolean(WarzoneConfig.DISABLED)) {

View File

@ -22,7 +22,6 @@ import com.tommytony.war.config.TeamConfig;
import com.tommytony.war.config.TeamKind;
import com.tommytony.war.config.WarzoneConfig;
import com.tommytony.war.utility.Direction;
import com.tommytony.war.volume.BlockInfo;
import com.tommytony.war.volume.Volume;
import com.tommytony.war.volume.ZoneVolume;
@ -35,14 +34,14 @@ public class ZoneLobby {
private final Warzone warzone;
private BlockFace wall;
private Volume volume;
BlockInfo lobbyMiddleWallBlock = null; // on the zone wall, one above the zone lobby floor
Location lobbyMiddleWallBlock = null; // on the zone wall, one above the zone lobby floor
BlockInfo warHubLinkGate = null;
Location warHubLinkGate = null;
Map<String, BlockInfo> teamGateBlocks = new HashMap<String, BlockInfo>();
BlockInfo autoAssignGate = null;
Map<String, Location> teamGateBlocks = new HashMap<String, Location>();
Location autoAssignGate = null;
BlockInfo zoneTeleportBlock = null;
Location zoneTeleportBlock = null;
private final int lobbyHeight = 3;
private int lobbyHalfSide;
@ -99,13 +98,13 @@ public class ZoneLobby {
// we're setting the zoneVolume directly, so we need to figure out the lobbyMiddleWallBlock on our own
if (wall == Direction.NORTH()) {
this.lobbyMiddleWallBlock = new BlockInfo(BlockInfo.getBlock(warzone.getWorld(), volume.getCornerOne()).getRelative(BlockFace.UP).getRelative(Direction.EAST(), this.lobbyHalfSide));
this.lobbyMiddleWallBlock = volume.getCornerOne().getBlock().getRelative(BlockFace.UP).getRelative(Direction.EAST(), this.lobbyHalfSide).getLocation();
} else if (wall == Direction.EAST()) {
this.lobbyMiddleWallBlock = new BlockInfo(BlockInfo.getBlock(warzone.getWorld(), volume.getCornerOne()).getRelative(BlockFace.UP).getRelative(Direction.SOUTH(), this.lobbyHalfSide));
this.lobbyMiddleWallBlock = volume.getCornerOne().getBlock().getRelative(BlockFace.UP).getRelative(Direction.SOUTH(), this.lobbyHalfSide).getLocation();
} else if (wall == Direction.SOUTH()) {
this.lobbyMiddleWallBlock = new BlockInfo(BlockInfo.getBlock(warzone.getWorld(), volume.getCornerOne()).getRelative(BlockFace.UP).getRelative(Direction.WEST(), this.lobbyHalfSide));
this.lobbyMiddleWallBlock = volume.getCornerOne().getBlock().getRelative(BlockFace.UP).getRelative(Direction.WEST(), this.lobbyHalfSide).getLocation();
} else if (wall == Direction.WEST()) {
this.lobbyMiddleWallBlock = new BlockInfo(BlockInfo.getBlock(warzone.getWorld(), volume.getCornerOne()).getRelative(BlockFace.UP).getRelative(Direction.NORTH(), this.lobbyHalfSide));
this.lobbyMiddleWallBlock = volume.getCornerOne().getBlock().getRelative(BlockFace.UP).getRelative(Direction.NORTH(), this.lobbyHalfSide).getLocation();
}
}
@ -157,13 +156,13 @@ public class ZoneLobby {
this.wall = opposite; // a player facing south places a lobby that looks just like a lobby stuck to the north wall
this.calculateLobbyWidth();
this.lobbyMiddleWallBlock = new BlockInfo(lobbyWorld.getBlockAt(playerLocation.getBlockX(), playerLocation.getBlockY(), playerLocation.getBlockZ()).getRelative(facing, 6));
this.lobbyMiddleWallBlock = lobbyWorld.getBlockAt(playerLocation.getBlockX(), playerLocation.getBlockY(), playerLocation.getBlockZ()).getRelative(facing, 6).getLocation();
Block corner1 = null;
Block corner2 = null;
int x = this.lobbyMiddleWallBlock.getX();
int y = this.lobbyMiddleWallBlock.getY();
int z = this.lobbyMiddleWallBlock.getZ();
int x = this.lobbyMiddleWallBlock.getBlockX();
int y = this.lobbyMiddleWallBlock.getBlockY();
int z = this.lobbyMiddleWallBlock.getBlockZ();
if (this.wall == Direction.NORTH()) {
corner1 = lobbyWorld.getBlockAt(x, y - 1, z + this.lobbyHalfSide);
@ -204,7 +203,7 @@ public class ZoneLobby {
int wallLength = wallEnd - wallStart + 1;
int wallCenterPos = wallStart + wallLength / 2;
int y = zoneVolume.getCenterY();
this.lobbyMiddleWallBlock = new BlockInfo(this.warzone.getWorld().getBlockAt(x, y, wallCenterPos));
this.lobbyMiddleWallBlock = this.warzone.getWorld().getBlockAt(x, y, wallCenterPos).getLocation();
corner1 = this.warzone.getWorld().getBlockAt(x, y - 1, wallCenterPos + this.lobbyHalfSide);
corner2 = this.warzone.getWorld().getBlockAt(x - this.lobbyDepth, y + 1 + this.lobbyHeight, wallCenterPos - this.lobbyHalfSide);
} else if (this.wall == Direction.EAST()) {
@ -214,7 +213,7 @@ public class ZoneLobby {
int wallLength = wallEnd - wallStart + 1;
int wallCenterPos = wallStart + wallLength / 2;
int y = zoneVolume.getCenterY();
this.lobbyMiddleWallBlock = new BlockInfo(this.warzone.getWorld().getBlockAt(wallCenterPos, y, z));
this.lobbyMiddleWallBlock = this.warzone.getWorld().getBlockAt(wallCenterPos, y, z).getLocation();
corner1 = this.warzone.getWorld().getBlockAt(wallCenterPos - this.lobbyHalfSide, y - 1, z);
corner2 = this.warzone.getWorld().getBlockAt(wallCenterPos + this.lobbyHalfSide, y + 1 + this.lobbyHeight, z - this.lobbyDepth);
} else if (this.wall == Direction.SOUTH()) {
@ -224,7 +223,7 @@ public class ZoneLobby {
int wallLength = wallEnd - wallStart + 1;
int wallCenterPos = wallStart + wallLength / 2;
int y = zoneVolume.getCenterY();
this.lobbyMiddleWallBlock = new BlockInfo(this.warzone.getWorld().getBlockAt(x, y, wallCenterPos));
this.lobbyMiddleWallBlock = this.warzone.getWorld().getBlockAt(x, y, wallCenterPos).getLocation();
corner1 = this.warzone.getWorld().getBlockAt(x, y - 1, wallCenterPos - this.lobbyHalfSide);
corner2 = this.warzone.getWorld().getBlockAt(x + this.lobbyDepth, y + 1 + this.lobbyHeight, wallCenterPos + this.lobbyHalfSide);
} else if (this.wall == Direction.WEST()) {
@ -234,7 +233,7 @@ public class ZoneLobby {
int wallLength = wallEnd - wallStart + 1;
int wallCenterPos = wallStart + wallLength / 2;
int y = zoneVolume.getCenterY();
this.lobbyMiddleWallBlock = new BlockInfo(this.warzone.getWorld().getBlockAt(wallCenterPos, y, z));
this.lobbyMiddleWallBlock = this.warzone.getWorld().getBlockAt(wallCenterPos, y, z).getLocation();
corner1 = this.warzone.getWorld().getBlockAt(wallCenterPos + this.lobbyHalfSide, y - 1, z);
corner2 = this.warzone.getWorld().getBlockAt(wallCenterPos - this.lobbyHalfSide, y + 1 + this.lobbyHeight, z + this.lobbyDepth);
}
@ -276,7 +275,7 @@ public class ZoneLobby {
public void initialize() {
// maybe the number of teams change, now reset the gate positions
if (this.lobbyMiddleWallBlock != null && this.volume != null) {
this.setGatePositions(BlockInfo.getBlock(this.volume.getWorld(), this.lobbyMiddleWallBlock));
this.setGatePositions(this.lobbyMiddleWallBlock.getBlock());
if (!warzone.getLobbyMaterials().getFloorBlock().getType().equals(Material.AIR)) {
// If air, leave original blocks.
this.volume.setFaceMaterial(BlockFace.DOWN, warzone.getLobbyMaterials().getFloorBlock());
@ -289,7 +288,7 @@ public class ZoneLobby {
// add war hub link gate
if (War.war.getWarHub() != null) {
Block linkGateBlock = BlockInfo.getBlock(this.volume.getWorld(), this.warHubLinkGate);
Block linkGateBlock = this.warHubLinkGate.getBlock();
this.placeWarhubLinkGate(linkGateBlock, warzone.getLobbyMaterials().getGateBlock());
// add warhub sign
String[] lines = War.war.getString("sign.lobby.warhub").split("\n");
@ -299,15 +298,15 @@ public class ZoneLobby {
// add team gates or single auto assign gate
this.placeAutoAssignGate();
for (String teamName : this.teamGateBlocks.keySet()) {
BlockInfo gateInfo = this.teamGateBlocks.get(teamName);
this.placeTeamGate(BlockInfo.getBlock(this.volume.getWorld(), gateInfo), TeamKind.teamKindFromString(teamName));
Block gateInfo = this.teamGateBlocks.get(teamName).getBlock();
this.placeTeamGate(gateInfo, TeamKind.teamKindFromString(teamName));
}
for (Team t : this.warzone.getTeams()) {
this.resetTeamGateSign(t);
}
// set zone tp
this.zoneTeleportBlock = new BlockInfo(BlockInfo.getBlock(this.volume.getWorld(), this.lobbyMiddleWallBlock).getRelative(this.wall, 6));
this.zoneTeleportBlock = this.lobbyMiddleWallBlock.getBlock().getRelative(this.wall, 6).getLocation();
int yaw = 0;
if (this.wall == Direction.WEST()) {
yaw = 180;
@ -339,7 +338,7 @@ public class ZoneLobby {
rightSide = Direction.SOUTH();
}
Block clearedPathStartBlock = BlockInfo.getBlock(this.warzone.getWorld(), this.lobbyMiddleWallBlock).getRelative(this.wall, 2);
Block clearedPathStartBlock = this.lobbyMiddleWallBlock.getBlock().getRelative(this.wall, 2);
Volume warzoneTeleportAir = new Volume("warzoneTeleport", clearedPathStartBlock.getWorld());
warzoneTeleportAir.setCornerOne(clearedPathStartBlock.getRelative(leftSide));
warzoneTeleportAir.setCornerTwo(clearedPathStartBlock.getRelative(rightSide).getRelative(front, 4).getRelative(BlockFace.UP));
@ -359,7 +358,7 @@ public class ZoneLobby {
clearedPathStartBlock.getRelative(this.wall).getRelative(this.wall).getRelative(this.wall).getRelative(this.wall).getRelative(this.wall).getRelative(BlockFace.UP).setType(Material.AIR);
// set zone sign
Block zoneSignBlock = BlockInfo.getBlock(this.volume.getWorld(), this.lobbyMiddleWallBlock).getRelative(this.wall, 4);
Block zoneSignBlock = this.lobbyMiddleWallBlock.getBlock().getRelative(this.wall, 4);
zoneSignBlock.setType(Material.SIGN_POST);
org.bukkit.block.Sign block = (org.bukkit.block.Sign) zoneSignBlock.getState();
org.bukkit.material.Sign data = (Sign) block.getData();
@ -377,20 +376,20 @@ public class ZoneLobby {
block.update(true);
// lets get some light in here
if (this.wall == Direction.NORTH() || this.wall == Direction.SOUTH()) {
BlockState one = BlockInfo.getBlock(this.volume.getWorld(), this.lobbyMiddleWallBlock).getRelative(BlockFace.DOWN).getRelative(Direction.WEST(), this.lobbyHalfSide - 1).getRelative(this.wall, 9).getState();
BlockState one = this.lobbyMiddleWallBlock.getBlock().getRelative(BlockFace.DOWN).getRelative(Direction.WEST(), this.lobbyHalfSide - 1).getRelative(this.wall, 9).getState();
one.setType(warzone.getLobbyMaterials().getLightBlock().getType());
one.setData(warzone.getLobbyMaterials().getLightBlock().getData());
one.update(true);
one = BlockInfo.getBlock(this.volume.getWorld(), this.lobbyMiddleWallBlock).getRelative(BlockFace.DOWN).getRelative(Direction.EAST(), this.lobbyHalfSide - 1).getRelative(this.wall, 9).getState();
one = this.lobbyMiddleWallBlock.getBlock().getRelative(BlockFace.DOWN).getRelative(Direction.EAST(), this.lobbyHalfSide - 1).getRelative(this.wall, 9).getState();
one.setType(warzone.getLobbyMaterials().getLightBlock().getType());
one.setData(warzone.getLobbyMaterials().getLightBlock().getData());
one.update(true);
} else {
BlockState one = BlockInfo.getBlock(this.volume.getWorld(), this.lobbyMiddleWallBlock).getRelative(BlockFace.DOWN).getRelative(Direction.NORTH(), this.lobbyHalfSide - 1).getRelative(this.wall, 9).getState();
BlockState one = this.lobbyMiddleWallBlock.getBlock().getRelative(BlockFace.DOWN).getRelative(Direction.NORTH(), this.lobbyHalfSide - 1).getRelative(this.wall, 9).getState();
one.setType(warzone.getLobbyMaterials().getLightBlock().getType());
one.setData(warzone.getLobbyMaterials().getLightBlock().getData());
one.update(true);
one = BlockInfo.getBlock(this.volume.getWorld(), this.lobbyMiddleWallBlock).getRelative(BlockFace.DOWN).getRelative(Direction.SOUTH(), this.lobbyHalfSide - 1).getRelative(this.wall, 9).getState();
one = this.lobbyMiddleWallBlock.getBlock().getRelative(BlockFace.DOWN).getRelative(Direction.SOUTH(), this.lobbyHalfSide - 1).getRelative(this.wall, 9).getState();
one.setType(warzone.getLobbyMaterials().getLightBlock().getType());
one.setData(warzone.getLobbyMaterials().getLightBlock().getData());
one.update(true);
@ -418,7 +417,7 @@ public class ZoneLobby {
}
this.teamGateBlocks.clear();
if (this.warzone.getWarzoneConfig().getBoolean(WarzoneConfig.AUTOASSIGN)) {
this.autoAssignGate = new BlockInfo(lobbyMiddleWallBlock);
this.autoAssignGate = lobbyMiddleWallBlock.getLocation();
} else {
this.autoAssignGate = null;
for (int doorIndex = 0; doorIndex < this.warzone.getTeams().size(); doorIndex++) {
@ -427,23 +426,23 @@ public class ZoneLobby {
if (this.warzone.getTeams().size() % 2 == 0) {
// even number of teams
if (doorIndex % 2 == 0) {
this.teamGateBlocks.put(team.getName(), new BlockInfo(lobbyMiddleWallBlock.getRelative(rightSide, doorIndex * 2 + 2)));
this.teamGateBlocks.put(team.getName(), lobbyMiddleWallBlock.getRelative(rightSide, doorIndex * 2 + 2).getLocation());
} else {
this.teamGateBlocks.put(team.getName(), new BlockInfo(lobbyMiddleWallBlock.getRelative(leftSide, doorIndex * 2)));
this.teamGateBlocks.put(team.getName(), lobbyMiddleWallBlock.getRelative(leftSide, doorIndex * 2).getLocation());
}
} else {
if (doorIndex == 0) {
this.teamGateBlocks.put(team.getName(), new BlockInfo(lobbyMiddleWallBlock));
this.teamGateBlocks.put(team.getName(), lobbyMiddleWallBlock.getLocation());
} else if (doorIndex % 2 == 0) {
this.teamGateBlocks.put(team.getName(), new BlockInfo(lobbyMiddleWallBlock.getRelative(rightSide, doorIndex * 2)));
this.teamGateBlocks.put(team.getName(), lobbyMiddleWallBlock.getRelative(rightSide, doorIndex * 2).getLocation());
} else {
this.teamGateBlocks.put(team.getName(), new BlockInfo(lobbyMiddleWallBlock.getRelative(leftSide, doorIndex * 2 + 2)));
this.teamGateBlocks.put(team.getName(), lobbyMiddleWallBlock.getRelative(leftSide, doorIndex * 2 + 2).getLocation());
}
}
}
}
this.warHubLinkGate = new BlockInfo(lobbyMiddleWallBlock.getRelative(this.wall, 9));
this.warHubLinkGate = lobbyMiddleWallBlock.getRelative(this.wall, 9).getLocation();
}
private void placeTeamGate(Block block, TeamKind teamKind) {
@ -573,7 +572,7 @@ public class ZoneLobby {
List<Team> teams = this.warzone.getTeams();
Block autoAssignGateBlock = BlockInfo.getBlock(this.volume.getWorld(), this.autoAssignGate);
Block autoAssignGateBlock = this.autoAssignGate.getBlock();
// minimal air path
this.clearGatePath(autoAssignGateBlock, front, leftSide, rightSide, false);
@ -601,7 +600,7 @@ public class ZoneLobby {
}
public boolean isInTeamGate(Team team, Location location) {
BlockInfo info = this.teamGateBlocks.get(team.getName());
Location info = this.teamGateBlocks.get(team.getName());
if (info != null) {
if (location.getBlockX() == info.getX() && location.getBlockY() == info.getY() && location.getBlockZ() == info.getZ()) {
return true;
@ -648,13 +647,13 @@ public class ZoneLobby {
public boolean blockIsAGateBlock(Block block, BlockFace blockWall) {
if (blockWall == this.wall) {
for (String teamName : this.teamGateBlocks.keySet()) {
BlockInfo gateInfo = this.teamGateBlocks.get(teamName);
if (this.isPartOfGate(BlockInfo.getBlock(this.volume.getWorld(), gateInfo), block)) {
Location gateInfo = this.teamGateBlocks.get(teamName);
if (this.isPartOfGate(gateInfo.getBlock(), block)) {
return true;
}
}
if (this.autoAssignGate != null && this.isPartOfGate(BlockInfo.getBlock(this.volume.getWorld(), this.autoAssignGate), block)) {
if (this.autoAssignGate != null && this.isPartOfGate(this.autoAssignGate.getBlock(), block)) {
// auto assign
return true;
}
@ -689,9 +688,9 @@ public class ZoneLobby {
}
public void resetTeamGateSign(Team team) {
BlockInfo info = this.teamGateBlocks.get(team.getName());
Location info = this.teamGateBlocks.get(team.getName());
if (info != null) {
this.resetTeamGateSign(team, BlockInfo.getBlock(this.volume.getWorld(), info));
this.resetTeamGateSign(team, info.getBlock());
}
}
@ -783,14 +782,14 @@ public class ZoneLobby {
right = Direction.NORTH();
}
if (this.autoAssignGate != null) {
if (this.leaving(location, BlockInfo.getBlock(this.volume.getWorld(), this.autoAssignGate), inside, left, right)) {
if (this.leaving(location, this.autoAssignGate.getBlock(), inside, left, right)) {
return true;
}
}
for (String teamName : this.teamGateBlocks.keySet()) {
BlockInfo info = this.teamGateBlocks.get(teamName);
if (this.leaving(location, BlockInfo.getBlock(this.volume.getWorld(), info), inside, left, right)) {
Location info = this.teamGateBlocks.get(teamName);
if (this.leaving(location, info.getBlock(), inside, left, right)) {
return true;
}
}

View File

@ -1,110 +0,0 @@
package com.tommytony.war.volume;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
/**
*
* @author tommytony
*
*/
public class BlockInfo {
private int x;
private int y;
private int z;
private int type;
private byte data;
// private String[] signLines;
public static Block getBlock(World world, BlockInfo info) {
return world.getBlockAt(info.getX(), info.getY(), info.getZ());
}
public BlockInfo(int x, int y, int z, int type, byte data) {
this.x = x;
this.y = y;
this.z = z;
this.type = type;
this.data = data;
}
public BlockInfo(Block block) {
this.x = block.getX();
this.y = block.getY();
this.z = block.getZ();
this.type = block.getTypeId();
this.data = block.getData();
// if (is(Material.SIGN) || is(Material.SIGN_POST)) {
// Sign sign = (Sign)block.getState();
// this.signLines = sign.getLines();
// }
}
// public BlockInfo(BlockState blockState) {
// this.x = blockState.getX();
// this.y = blockState.getY();
// this.z = blockState.getZ();
// this.type = blockState.getTypeId();
// this.data = blockState.getData().getData();
// // if (is(Material.SIGN) || is(Material.SIGN_POST)) {
// // Sign sign = (Sign)blockState;
// // this.signLines = sign.getLines();
// // }
// }
// public BlockInfo(int typeID, byte data, String[] lines) {
// type = typeID;
// this.data = data;
// //signLines = lines;
// }
public int getX() {
return this.x;
}
public int getY() {
return this.y;
}
public int getZ() {
return this.z;
}
// letting us mutate the BlockInfos might be a bad idea; use setters with care
public void setX(int x) {
this.x = x;
}
public void setY(int y) {
this.y = y;
}
public void setZ(int z) {
this.z = z;
}
public int getTypeId() {
return this.type;
}
public Material getType() {
return Material.getMaterial(this.type);
}
public byte getData() {
return this.data;
}
public boolean is(Material material) {
return this.getType() == material;
}
// public String[] getSignLines() {
// if (is(Material.SIGN) || is(Material.SIGN_POST)){
// return new String[4] {"", ""};
// }
// return null;
// }
}

View File

@ -1,171 +0,0 @@
package com.tommytony.war.volume;
import java.util.logging.Level;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import com.tommytony.war.War;
import com.tommytony.war.utility.Direction;
/**
*
* @author tommytony
*
*/
@Deprecated
public class VerticalVolume extends Volume {
public VerticalVolume(String name, World world) {
super(name, world);
}
@Override
public void setCornerOne(Block block) {
// corner one defaults to topmost corner
Block topBlock = this.getWorld().getBlockAt(block.getX(), 127, block.getZ());
super.setCornerOne(topBlock);
}
@Override
public void setCornerTwo(Block block) {
// corner two defaults to bottom most corner
Block bottomBlock = this.getWorld().getBlockAt(block.getX(), 0, block.getZ());
super.setCornerTwo(bottomBlock);
}
public boolean isWallBlock(Block block) {
return this.isEastWallBlock(block) || this.isNorthWallBlock(block) || this.isSouthWallBlock(block) || this.isWestWallBlock(block);
}
public boolean isEastWallBlock(Block block) {
if (this.getMinZ() == block.getZ() && block.getX() <= this.getMaxX() && block.getX() >= this.getMinX()) {
return true; // east wall
}
return false;
}
public boolean isSouthWallBlock(Block block) {
if (this.getMaxX() == block.getX() && block.getZ() <= this.getMaxZ() && block.getZ() >= this.getMinZ()) {
return true; // south wall
}
return false;
}
public boolean isNorthWallBlock(Block block) {
if (this.getMinX() == block.getX() && block.getZ() <= this.getMaxZ() && block.getZ() >= this.getMinZ()) {
return true; // north wall
}
return false;
}
public boolean isWestWallBlock(Block block) {
if (this.getMaxZ() == block.getZ() && block.getX() <= this.getMaxX() && block.getX() >= this.getMinX()) {
return true; // west wall
}
return false;
}
public int resetWallBlocks(BlockFace wall) {
int noOfResetBlocks = 0;
try {
if (this.hasTwoCorners() && this.getBlockTypes() != null) {
if (wall == Direction.EAST()) {
int z = this.getMinZ();
int k = 0;
int y = this.getMinY();
for (int j = 0; j < this.getSizeY(); j++) {
int x = this.getMinX();
for (int i = 0; i < this.getSizeX(); i++) {
int oldBlockType = this.getBlockTypes()[i][j][k];
byte oldBlockData = this.getBlockDatas()[i][j][k];
Block currentBlock = this.getWorld().getBlockAt(x, y, z);
if (this.resetBlock(oldBlockType, oldBlockData, currentBlock)) {
noOfResetBlocks++;
}
x++;
}
y++;
}
} else if (wall == Direction.WEST()) {
int z = this.getMaxZ();
int k = this.getSizeZ() - 1;
int y = this.getMinY();
for (int j = 0; j < this.getSizeY(); j++) {
int x = this.getMinX();
for (int i = 0; i < this.getSizeX(); i++) {
int oldBlockType = this.getBlockTypes()[i][j][k];
byte oldBlockData = this.getBlockDatas()[i][j][k];
Block currentBlock = this.getWorld().getBlockAt(x, y, z);
if (this.resetBlock(oldBlockType, oldBlockData, currentBlock)) {
noOfResetBlocks++;
}
x++;
}
y++;
}
} else if (wall == Direction.NORTH()) {
int x = this.getMinX();
int i = 0;
int y = this.getMinY();
for (int j = 0; j < this.getSizeY(); j++) {
int z = this.getMinZ();
for (int k = 0; k < this.getSizeZ(); k++) {
int oldBlockType = this.getBlockTypes()[i][j][k];
byte oldBlockData = this.getBlockDatas()[i][j][k];
Block currentBlock = this.getWorld().getBlockAt(x, y, z);
if (this.resetBlock(oldBlockType, oldBlockData, currentBlock)) {
noOfResetBlocks++;
}
z++;
}
y++;
}
} else if (wall == Direction.SOUTH()) {
int x = this.getMaxX();
int i = this.getSizeX() - 1;
int y = this.getMinY();
for (int j = 0; j < this.getSizeY(); j++) {
int z = this.getMinZ();
for (int k = 0; k < this.getSizeZ(); k++) {
int oldBlockType = this.getBlockTypes()[i][j][k];
byte oldBlockData = this.getBlockDatas()[i][j][k];
Block currentBlock = this.getWorld().getBlockAt(x, y, z);
if (this.resetBlock(oldBlockType, oldBlockData, currentBlock)) {
noOfResetBlocks++;
}
z++;
}
y++;
}
}
}
} catch (Exception e) {
War.war.log("Failed to reset wall " + wall + " in volume " + this.getName() + ". " + e.getClass().toString() + " " + e.getMessage(), Level.WARNING);
}
return noOfResetBlocks;
}
private boolean resetBlock(int oldBlockType, byte oldBlockData, Block currentBlock) {
if (currentBlock.getTypeId() != oldBlockType || (currentBlock.getTypeId() == oldBlockType && currentBlock.getData() != oldBlockData) || (currentBlock.getTypeId() == oldBlockType && currentBlock.getData() == oldBlockData && (oldBlockType == Material.WALL_SIGN.getId() || oldBlockType == Material.SIGN_POST.getId()))) {
currentBlock.setTypeId(oldBlockType);
currentBlock.setData(oldBlockData);
// if (oldBlockInfo.is(Material.SIGN) || oldBlockInfo.is(Material.SIGN_POST)) {
// BlockState state = currentBlock.getState();
// Sign currentSign = (Sign) state;
// currentSign.setLine(0, oldBlockInfo.getSignLines()[0]);
// currentSign.setLine(1, oldBlockInfo.getSignLines()[0]);
// currentSign.setLine(2, oldBlockInfo.getSignLines()[0]);
// currentSign.setLine(3, oldBlockInfo.getSignLines()[0]);
// state.update();
// }
return true;
}
return false;
}
}

View File

@ -31,12 +31,12 @@ import com.tommytony.war.utility.Direction;
public class Volume {
private String name;
private World world;
private BlockInfo cornerOne;
private BlockInfo cornerTwo;
private int[][][] blockTypes = null;
private byte[][][] blockDatas = null;
private HashMap<String, String[]> signLines = new HashMap<String, String[]>();
private HashMap<String, List<ItemStack>> invBlockContents = new HashMap<String, List<ItemStack>>();
private Location cornerOne;
private Location cornerTwo;
public Volume(String name, World world) {
this.name = name;
@ -50,8 +50,8 @@ public class Volume {
public Volume(Location corner1, Location corner2) {
this(corner1.getWorld());
Validate.isTrue(corner1.getWorld() == corner2.getWorld(), "Cross-world volume");
this.cornerOne = new BlockInfo(corner1.getBlock());
this.cornerTwo = new BlockInfo(corner2.getBlock());
this.cornerOne = corner1;
this.cornerTwo = corner2;
}
public void setName(String newName) {
@ -71,11 +71,11 @@ public class Volume {
}
public void setCornerOne(Block block) {
this.cornerOne = new BlockInfo(block);
this.cornerOne = block.getLocation();
}
public void setCornerOne(BlockInfo blockInfo) {
this.cornerOne = blockInfo;
public void setCornerOne(Location location) {
this.cornerOne = location;
}
public int saveBlocks() {
@ -314,28 +314,28 @@ public class Volume {
}
public void setCornerTwo(Block block) {
this.cornerTwo = new BlockInfo(block);
this.cornerTwo = block.getLocation();
}
public void setCornerTwo(BlockInfo blockInfo) {
this.cornerTwo = blockInfo;
public void setCornerTwo(Location location) {
this.cornerTwo = location;
}
public BlockInfo getMinXBlock() {
public Location getMinXBlock() {
if (this.cornerOne.getX() < this.cornerTwo.getX()) {
return this.cornerOne;
}
return this.cornerTwo;
}
public BlockInfo getMinYBlock() {
public Location getMinYBlock() {
if (this.cornerOne.getY() < this.cornerTwo.getY()) {
return this.cornerOne;
}
return this.cornerTwo;
}
public BlockInfo getMinZBlock() {
public Location getMinZBlock() {
if (this.cornerOne.getZ() < this.cornerTwo.getZ()) {
return this.cornerOne;
}
@ -343,32 +343,32 @@ public class Volume {
}
public int getMinX() {
return this.getMinXBlock().getX();
return this.getMinXBlock().getBlockX();
}
public int getMinY() {
return this.getMinYBlock().getY();
return this.getMinYBlock().getBlockY();
}
public int getMinZ() {
return this.getMinZBlock().getZ();
return this.getMinZBlock().getBlockZ();
}
public BlockInfo getMaxXBlock() {
public Location getMaxXBlock() {
if (this.cornerOne.getX() < this.cornerTwo.getX()) {
return this.cornerTwo;
}
return this.cornerOne;
}
public BlockInfo getMaxYBlock() {
public Location getMaxYBlock() {
if (this.cornerOne.getY() < this.cornerTwo.getY()) {
return this.cornerTwo;
}
return this.cornerOne;
}
public BlockInfo getMaxZBlock() {
public Location getMaxZBlock() {
if (this.cornerOne.getZ() < this.cornerTwo.getZ()) {
return this.cornerTwo;
}
@ -376,15 +376,15 @@ public class Volume {
}
public int getMaxX() {
return this.getMaxXBlock().getX();
return this.getMaxXBlock().getBlockX();
}
public int getMaxY() {
return this.getMaxYBlock().getY();
return this.getMaxYBlock().getBlockY();
}
public int getMaxZ() {
return this.getMaxZBlock().getZ();
return this.getMaxZBlock().getBlockZ();
}
public int getSizeX() {
@ -407,11 +407,11 @@ public class Volume {
return this.blockTypes;
}
public BlockInfo getCornerOne() {
public Location getCornerOne() {
return this.cornerOne;
}
public BlockInfo getCornerTwo() {
public Location getCornerTwo() {
return this.cornerTwo;
}
@ -557,4 +557,8 @@ public class Volume {
this.invBlockContents.clear();
this.invBlockContents = null;
}
public int size() {
return this.getSizeX() * this.getSizeY() * this.getSizeZ();
}
}

View File

@ -1,5 +1,6 @@
package com.tommytony.war.volume;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.block.Block;
@ -63,11 +64,11 @@ public class ZoneVolume extends Volume {
return;
}
public void setNorthwest(Block block) throws NotNorthwestException, TooSmallException, TooBigException {
public void setNorthwest(Location block) throws NotNorthwestException, TooSmallException, TooBigException {
// northwest defaults to top block
BlockInfo topBlock = new BlockInfo(block.getX(), 127, block.getZ(), block.getTypeId(), block.getData());
BlockInfo oldCornerOne = this.getCornerOne();
BlockInfo oldCornerTwo = this.getCornerTwo();
Location topBlock = new Location(block.getWorld(), block.getX(), block.getWorld().getMaxHeight(), block.getZ());
Location oldCornerOne = this.getCornerOne();
Location oldCornerTwo = this.getCornerTwo();
if (this.getCornerOne() == null) {
if (this.getCornerTwo() == null) {
// northwest defaults to corner 1
@ -89,10 +90,8 @@ public class ZoneVolume extends Volume {
if (this.getSoutheastX() <= block.getX() || this.getSoutheastZ() >= block.getZ()) {
throw new NotNorthwestException();
}
BlockInfo minXBlock = this.getMinXBlock(); // north means min X
minXBlock.setX(block.getX()); // mutating, argh!
BlockInfo maxZBlock = this.getMaxZBlock(); // west means max Z
maxZBlock.setZ(block.getZ());
this.getMinXBlock().setX(block.getX()); // north means min X
this.getMaxZBlock().setZ(block.getZ()); // west means max Z
}
if (this.tooSmall() || this.zoneStructuresAreOutside()) {
super.setCornerOne(oldCornerOne);
@ -121,11 +120,11 @@ public class ZoneVolume extends Volume {
}
}
public void setSoutheast(Block block) throws NotSoutheastException, TooSmallException, TooBigException {
public void setSoutheast(Location block) throws NotSoutheastException, TooSmallException, TooBigException {
// southeast defaults to bottom block
BlockInfo bottomBlock = new BlockInfo(block.getX(), 0, block.getZ(), block.getTypeId(), block.getData());
BlockInfo oldCornerOne = this.getCornerOne();
BlockInfo oldCornerTwo = this.getCornerTwo();
Location bottomBlock = new Location(block.getWorld(), block.getX(), 0, block.getZ());
Location oldCornerOne = this.getCornerOne();
Location oldCornerTwo = this.getCornerTwo();
if (this.getCornerTwo() == null) {
if (this.getCornerOne() == null) {
// southeast defaults to corner 2
@ -147,10 +146,8 @@ public class ZoneVolume extends Volume {
if (this.getNorthwestX() >= block.getX() || this.getNorthwestZ() <= block.getZ()) {
throw new NotSoutheastException();
}
BlockInfo maxXBlock = this.getMaxXBlock(); // south means max X
maxXBlock.setX(block.getX()); // mutating, argh!
BlockInfo minZBlock = this.getMinZBlock(); // east means min Z
minZBlock.setZ(block.getZ());
this.getMaxXBlock().setX(block.getX()); // south means max X
this.getMinZBlock().setZ(block.getZ()); // east means min Z
}
if (this.tooSmall() || this.zoneStructuresAreOutside()) {
super.setCornerOne(oldCornerOne);
@ -189,7 +186,7 @@ public class ZoneVolume extends Volume {
}
public void setZoneCornerOne(Block block) throws TooSmallException, TooBigException {
BlockInfo oldCornerOne = this.getCornerOne();
Location oldCornerOne = this.getCornerOne();
super.setCornerOne(block);
if (this.tooSmall() || this.zoneStructuresAreOutside()) {
super.setCornerOne(oldCornerOne);
@ -201,7 +198,7 @@ public class ZoneVolume extends Volume {
}
public void setZoneCornerTwo(Block block) throws TooSmallException, TooBigException {
BlockInfo oldCornerTwo = this.getCornerTwo();
Location oldCornerTwo = this.getCornerTwo();
super.setCornerTwo(block);
if (this.tooSmall() || this.zoneStructuresAreOutside()) {
super.setCornerTwo(oldCornerTwo);
@ -251,8 +248,8 @@ public class ZoneVolume extends Volume {
return false;
}
private boolean isInside(BlockInfo info) {
if (info.getX() <= this.getMaxX() && info.getX() >= this.getMinX() && info.getY() <= this.getMaxY() && info.getY() >= this.getMinY() && info.getZ() <= this.getMaxZ() && info.getZ() >= this.getMinZ()) {
private boolean isInside(Location location) {
if (location.getX() <= this.getMaxX() && location.getX() >= this.getMinX() && location.getY() <= this.getMaxY() && location.getY() >= this.getMinY() && location.getZ() <= this.getMaxZ() && location.getZ() >= this.getMinZ()) {
return true;
}
return false;