From d9701b910d7c09267e11a0e2d32ab1a8e17c0fc4 Mon Sep 17 00:00:00 2001 From: Chris Sp Date: Sun, 4 Dec 2011 12:40:10 +0100 Subject: [PATCH] Piston Exploit Fix, and removal of deprecated functions - Fixed an exploit where it would be possible to move the flag with pistons, rendering it unstealable. You cannot move any important blocks with pistons now, and can't push them into protected zones. Reported here: http://forums.bukkit.org/threads/mech-fun-war-v1-6-de-gaulle-final-minecraft-tdm-ctf-1337.250/page-67#post-831054 Special thanks to TerXIII! - Changed all calls of the deprecated getRelative() to getRelative() --- .../tommytony/war/WarBlockListener.java | 27 +-- .../main/java/com/tommytony/war/Monument.java | 4 +- war/src/main/java/com/tommytony/war/Team.java | 16 +- .../main/java/com/tommytony/war/WarHub.java | 28 +-- .../java/com/tommytony/war/ZoneLobby.java | 96 ++++---- .../java/com/tommytony/war/ZoneWallGuard.java | 216 +++++++++--------- .../tommytony/war/jobs/ResetCursorJob.java | 16 +- .../com/tommytony/war/volumes/Volume.java | 4 +- 8 files changed, 199 insertions(+), 208 deletions(-) diff --git a/war/src/main/java/bukkit/tommytony/war/WarBlockListener.java b/war/src/main/java/bukkit/tommytony/war/WarBlockListener.java index df76e48..87604aa 100644 --- a/war/src/main/java/bukkit/tommytony/war/WarBlockListener.java +++ b/war/src/main/java/bukkit/tommytony/war/WarBlockListener.java @@ -116,42 +116,33 @@ public class WarBlockListener extends BlockListener { event.setCancelled(true); return; } - - /*// disallow placing of sticky pistons near flags. If the flag is pulled from the right position, you can't pick it up - if (block.getType() == Material.PISTON_STICKY_BASE && Team.getTeamByPlayerName(player.getName()).getTeamFlag().distance(block.getLocation()) < 4) { - War.war.badMsg(player, "You can't place sticky pistons this close to the flag."); - event.setCancelled(true); - return; - }*/ } - /*public void onPistonExtend(BlockPistonExtendEvent event) { + // Do not allow moving of block into or from important zones + public void onBlockPistonExtend(BlockPistonExtendEvent event) { Warzone zone = Warzone.getZoneByLocation(event.getBlock().getLocation()); if (zone!=null) { for (Block b : event.getBlocks()) { - if (zone.isMonumentCenterBlock(b) || zone.isFlagBlock(b)) { + if (zone.isImportantBlock(b)) { event.setCancelled(true); return; } } + if (zone.isImportantBlock(event.getBlock().getRelative(event.getDirection(), event.getLength()+1))) { + event.setCancelled(true); + return; + } } } - - public void onPistonRetract(BlockPistonRetractEvent event) { + public void onBlockPistonRetract(BlockPistonRetractEvent event) { Warzone zone = Warzone.getZoneByLocation(event.getBlock().getLocation()); if (zone!=null) { - Block b = event.getBlock(); + Block b = event.getBlock().getRelative(event.getDirection(), 2); if (zone.isImportantBlock(b)) { event.setCancelled(true); return; } } - }*/ - public void onPistonExtend(BlockPistonExtendEvent event) { - War.war.log("EXTENDING",Level.INFO); - } - public void onPistonRetract(BlockPistonRetractEvent event) { - War.war.log("RETRACTING",Level.INFO); } /** diff --git a/war/src/main/java/com/tommytony/war/Monument.java b/war/src/main/java/com/tommytony/war/Monument.java index 25a29b2..e43fd9d 100644 --- a/war/src/main/java/com/tommytony/war/Monument.java +++ b/war/src/main/java/com/tommytony/war/Monument.java @@ -140,8 +140,8 @@ public class Monument { public void setLocation(Location location) { Block locationBlock = this.warzone.getWorld().getBlockAt(location.getBlockX(), location.getBlockY(), location.getBlockZ()); - this.volume.setCornerOne(locationBlock.getFace(BlockFace.DOWN).getFace(BlockFace.EAST, 2).getFace(BlockFace.SOUTH, 2)); - this.volume.setCornerTwo(locationBlock.getFace(BlockFace.UP, 2).getFace(BlockFace.WEST, 2).getFace(BlockFace.NORTH, 2)); + this.volume.setCornerOne(locationBlock.getRelative(BlockFace.DOWN).getRelative(BlockFace.EAST, 2).getRelative(BlockFace.SOUTH, 2)); + this.volume.setCornerTwo(locationBlock.getRelative(BlockFace.UP, 2).getRelative(BlockFace.WEST, 2).getRelative(BlockFace.NORTH, 2)); this.volume.saveBlocks(); this.location = 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 992ebce..c31bf1e 100644 --- a/war/src/main/java/com/tommytony/war/Team.java +++ b/war/src/main/java/com/tommytony/war/Team.java @@ -129,16 +129,16 @@ public class Team { // SMALL style if (yaw >= 0 && yaw < 90) { signData = 10; - signBlock = this.warzone.getWorld().getBlockAt(x, y, z).getFace(BlockFace.NORTH).getFace(BlockFace.WEST); + signBlock = this.warzone.getWorld().getBlockAt(x, y, z).getRelative(BlockFace.NORTH).getRelative(BlockFace.WEST); } else if (yaw >= 90 && yaw <= 180) { signData = 14; - signBlock = this.warzone.getWorld().getBlockAt(x, y, z).getFace(BlockFace.NORTH).getFace(BlockFace.EAST); + signBlock = this.warzone.getWorld().getBlockAt(x, y, z).getRelative(BlockFace.NORTH).getRelative(BlockFace.EAST); } else if (yaw >= 180 && yaw < 270) { signData = 2; - signBlock = this.warzone.getWorld().getBlockAt(x, y, z).getFace(BlockFace.SOUTH).getFace(BlockFace.EAST); + signBlock = this.warzone.getWorld().getBlockAt(x, y, z).getRelative(BlockFace.SOUTH).getRelative(BlockFace.EAST); } else if (yaw >= 270 && yaw <= 360) { signData = 6; - signBlock = this.warzone.getWorld().getBlockAt(x, y, z).getFace(BlockFace.SOUTH).getFace(BlockFace.WEST); + signBlock = this.warzone.getWorld().getBlockAt(x, y, z).getRelative(BlockFace.SOUTH).getRelative(BlockFace.WEST); } } else { // outer ring (FLAT or BIG) @@ -169,7 +169,7 @@ public class Team { facing = BlockFace.NORTH_WEST; opposite = BlockFace.SOUTH_EAST; signData = 10; - signBlock = this.warzone.getWorld().getBlockAt(x, y, z).getFace(BlockFace.NORTH, 2).getFace(BlockFace.WEST, 2); + signBlock = this.warzone.getWorld().getBlockAt(x, y, z).getRelative(BlockFace.NORTH, 2).getRelative(BlockFace.WEST, 2); if (this.warzone.getSpawnStyle().equals(TeamSpawnStyle.BIG)) { // rim @@ -202,7 +202,7 @@ public class Team { facing = BlockFace.NORTH_EAST; opposite = BlockFace.SOUTH_WEST; signData = 14; - signBlock = this.warzone.getWorld().getBlockAt(x, y, z).getFace(BlockFace.NORTH, 2).getFace(BlockFace.EAST, 2); + signBlock = this.warzone.getWorld().getBlockAt(x, y, z).getRelative(BlockFace.NORTH, 2).getRelative(BlockFace.EAST, 2); if (this.warzone.getSpawnStyle().equals(TeamSpawnStyle.BIG)) { // rim this.setBlock(x + 1, y, z - 2, this.kind); @@ -234,7 +234,7 @@ public class Team { facing = BlockFace.SOUTH_EAST; opposite = BlockFace.NORTH_WEST; signData = 2; - signBlock = this.warzone.getWorld().getBlockAt(x, y, z).getFace(BlockFace.SOUTH, 2).getFace(BlockFace.EAST, 2); + signBlock = this.warzone.getWorld().getBlockAt(x, y, z).getRelative(BlockFace.SOUTH, 2).getRelative(BlockFace.EAST, 2); if (this.warzone.getSpawnStyle().equals(TeamSpawnStyle.BIG)) { // rim this.setBlock(x + 2, y, z + 1, this.kind); @@ -266,7 +266,7 @@ public class Team { facing = BlockFace.SOUTH_WEST; opposite = BlockFace.NORTH_EAST; signData = 6; - signBlock = this.warzone.getWorld().getBlockAt(x, y, z).getFace(BlockFace.SOUTH, 2).getFace(BlockFace.WEST, 2); + signBlock = this.warzone.getWorld().getBlockAt(x, y, z).getRelative(BlockFace.SOUTH, 2).getRelative(BlockFace.WEST, 2); if (this.warzone.getSpawnStyle().equals(TeamSpawnStyle.BIG)) { // rim this.setBlock(x - 1, y, z + 2, this.kind); diff --git a/war/src/main/java/com/tommytony/war/WarHub.java b/war/src/main/java/com/tommytony/war/WarHub.java index e03c4e5..b472d2a 100644 --- a/war/src/main/java/com/tommytony/war/WarHub.java +++ b/war/src/main/java/com/tommytony/war/WarHub.java @@ -143,8 +143,8 @@ public class WarHub { } Block locationBlock = this.location.getWorld().getBlockAt(this.location.getBlockX(), this.location.getBlockY(), this.location.getBlockZ()); - this.volume.setCornerOne(locationBlock.getFace(back).getFace(left, halfHubWidth).getFace(BlockFace.DOWN)); - this.volume.setCornerTwo(locationBlock.getFace(right, halfHubWidth).getFace(front, hubDepth).getFace(BlockFace.UP, hubHeigth)); + this.volume.setCornerOne(locationBlock.getRelative(back).getRelative(left, halfHubWidth).getRelative(BlockFace.DOWN)); + this.volume.setCornerTwo(locationBlock.getRelative(right, halfHubWidth).getRelative(front, hubDepth).getRelative(BlockFace.UP, hubHeigth)); this.volume.saveBlocks(); // glass floor @@ -153,26 +153,26 @@ public class WarHub { this.volume.setFaceMaterial(BlockFace.DOWN, Material.GLASS); // draw gates - Block currentGateBlock = BlockInfo.getBlock(this.location.getWorld(), this.volume.getCornerOne()).getFace(BlockFace.UP).getFace(front, hubDepth).getFace(right, 2); + Block currentGateBlock = BlockInfo.getBlock(this.location.getWorld(), this.volume.getCornerOne()).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.isDisabled()) { this.zoneGateBlocks.put(zone.getName(), currentGateBlock); - currentGateBlock.getFace(BlockFace.DOWN).setType(Material.GLOWSTONE); - currentGateBlock.getFace(left).setType(Material.OBSIDIAN); - currentGateBlock.getFace(right).getFace(BlockFace.UP).setType(Material.OBSIDIAN); - currentGateBlock.getFace(left).getFace(BlockFace.UP).getFace(BlockFace.UP).setType(Material.OBSIDIAN); - currentGateBlock.getFace(right).setType(Material.OBSIDIAN); - currentGateBlock.getFace(left).getFace(BlockFace.UP).setType(Material.OBSIDIAN); - currentGateBlock.getFace(right).getFace(BlockFace.UP).getFace(BlockFace.UP).setType(Material.OBSIDIAN); - currentGateBlock.getFace(BlockFace.UP).getFace(BlockFace.UP).setType(Material.OBSIDIAN); - currentGateBlock = currentGateBlock.getFace(right, 4); + currentGateBlock.getRelative(BlockFace.DOWN).setType(Material.GLOWSTONE); + currentGateBlock.getRelative(left).setType(Material.OBSIDIAN); + currentGateBlock.getRelative(right).getRelative(BlockFace.UP).setType(Material.OBSIDIAN); + currentGateBlock.getRelative(left).getRelative(BlockFace.UP).getRelative(BlockFace.UP).setType(Material.OBSIDIAN); + currentGateBlock.getRelative(right).setType(Material.OBSIDIAN); + currentGateBlock.getRelative(left).getRelative(BlockFace.UP).setType(Material.OBSIDIAN); + currentGateBlock.getRelative(right).getRelative(BlockFace.UP).getRelative(BlockFace.UP).setType(Material.OBSIDIAN); + currentGateBlock.getRelative(BlockFace.UP).getRelative(BlockFace.UP).setType(Material.OBSIDIAN); + currentGateBlock = currentGateBlock.getRelative(right, 4); } } // War hub sign - Block signBlock = locationBlock.getFace(front); + Block signBlock = locationBlock.getRelative(front); String[] lines = new String[4]; lines[0] = "War hub"; @@ -219,7 +219,7 @@ public class WarHub { } Block zoneGate = this.zoneGateBlocks.get(zone.getName()); - Block block = zoneGate.getFace(left).getFace(back, 1); + Block block = zoneGate.getRelative(left).getRelative(back, 1); if (block.getType() != Material.SIGN_POST) { block.setType(Material.SIGN_POST); } diff --git a/war/src/main/java/com/tommytony/war/ZoneLobby.java b/war/src/main/java/com/tommytony/war/ZoneLobby.java index be105e8..1ea81d4 100644 --- a/war/src/main/java/com/tommytony/war/ZoneLobby.java +++ b/war/src/main/java/com/tommytony/war/ZoneLobby.java @@ -90,13 +90,13 @@ public class ZoneLobby { // we're setting the zoneVolume directly, so we need to figure out the lobbyMiddleWallBlock on our own if (wall == BlockFace.NORTH) { - this.lobbyMiddleWallBlock = new BlockInfo(BlockInfo.getBlock(warzone.getWorld(), volume.getCornerOne()).getFace(BlockFace.UP).getFace(BlockFace.EAST, this.lobbyHalfSide)); + this.lobbyMiddleWallBlock = new BlockInfo(BlockInfo.getBlock(warzone.getWorld(), volume.getCornerOne()).getRelative(BlockFace.UP).getRelative(BlockFace.EAST, this.lobbyHalfSide)); } else if (wall == BlockFace.EAST) { - this.lobbyMiddleWallBlock = new BlockInfo(BlockInfo.getBlock(warzone.getWorld(), volume.getCornerOne()).getFace(BlockFace.UP).getFace(BlockFace.SOUTH, this.lobbyHalfSide)); + this.lobbyMiddleWallBlock = new BlockInfo(BlockInfo.getBlock(warzone.getWorld(), volume.getCornerOne()).getRelative(BlockFace.UP).getRelative(BlockFace.SOUTH, this.lobbyHalfSide)); } else if (wall == BlockFace.SOUTH) { - this.lobbyMiddleWallBlock = new BlockInfo(BlockInfo.getBlock(warzone.getWorld(), volume.getCornerOne()).getFace(BlockFace.UP).getFace(BlockFace.WEST, this.lobbyHalfSide)); + this.lobbyMiddleWallBlock = new BlockInfo(BlockInfo.getBlock(warzone.getWorld(), volume.getCornerOne()).getRelative(BlockFace.UP).getRelative(BlockFace.WEST, this.lobbyHalfSide)); } else if (wall == BlockFace.WEST) { - this.lobbyMiddleWallBlock = new BlockInfo(BlockInfo.getBlock(warzone.getWorld(), volume.getCornerOne()).getFace(BlockFace.UP).getFace(BlockFace.NORTH, this.lobbyHalfSide)); + this.lobbyMiddleWallBlock = new BlockInfo(BlockInfo.getBlock(warzone.getWorld(), volume.getCornerOne()).getRelative(BlockFace.UP).getRelative(BlockFace.NORTH, this.lobbyHalfSide)); } } @@ -147,7 +147,7 @@ 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(this.warzone.getWorld().getBlockAt(playerLocation.getBlockX(), playerLocation.getBlockY(), playerLocation.getBlockZ()).getFace(facing, 6)); + this.lobbyMiddleWallBlock = new BlockInfo(this.warzone.getWorld().getBlockAt(playerLocation.getBlockX(), playerLocation.getBlockY(), playerLocation.getBlockZ()).getRelative(facing, 6)); Block corner1 = null; Block corner2 = null; @@ -295,7 +295,7 @@ public class ZoneLobby { } // set zone tp - this.zoneTeleportBlock = new BlockInfo(BlockInfo.getBlock(this.warzone.getWorld(), this.lobbyMiddleWallBlock).getFace(this.wall, 6)); + this.zoneTeleportBlock = new BlockInfo(BlockInfo.getBlock(this.warzone.getWorld(), this.lobbyMiddleWallBlock).getRelative(this.wall, 6)); int yaw = 0; if (this.wall == BlockFace.WEST) { yaw = 180; @@ -309,7 +309,7 @@ public class ZoneLobby { this.warzone.setTeleport(new Location(this.warzone.getWorld(), this.zoneTeleportBlock.getX(), this.zoneTeleportBlock.getY(), this.zoneTeleportBlock.getZ(), yaw, 0)); // set zone sign - Block zoneSignBlock = BlockInfo.getBlock(this.warzone.getWorld(), this.lobbyMiddleWallBlock).getFace(this.wall, 4); + Block zoneSignBlock = BlockInfo.getBlock(this.warzone.getWorld(), this.lobbyMiddleWallBlock).getRelative(this.wall, 4); byte data = 0; if (this.wall == BlockFace.NORTH) { data = (byte) 4; @@ -334,11 +334,11 @@ public class ZoneLobby { // lets get some light in here if (this.wall == BlockFace.NORTH || this.wall == BlockFace.SOUTH) { - BlockInfo.getBlock(this.warzone.getWorld(), this.lobbyMiddleWallBlock).getFace(BlockFace.DOWN).getFace(BlockFace.WEST, this.lobbyHalfSide - 1).getFace(this.wall, 9).setType(Material.GLOWSTONE); - BlockInfo.getBlock(this.warzone.getWorld(), this.lobbyMiddleWallBlock).getFace(BlockFace.DOWN).getFace(BlockFace.EAST, this.lobbyHalfSide - 1).getFace(this.wall, 9).setType(Material.GLOWSTONE); + BlockInfo.getBlock(this.warzone.getWorld(), this.lobbyMiddleWallBlock).getRelative(BlockFace.DOWN).getRelative(BlockFace.WEST, this.lobbyHalfSide - 1).getRelative(this.wall, 9).setType(Material.GLOWSTONE); + BlockInfo.getBlock(this.warzone.getWorld(), this.lobbyMiddleWallBlock).getRelative(BlockFace.DOWN).getRelative(BlockFace.EAST, this.lobbyHalfSide - 1).getRelative(this.wall, 9).setType(Material.GLOWSTONE); } else { - BlockInfo.getBlock(this.warzone.getWorld(), this.lobbyMiddleWallBlock).getFace(BlockFace.DOWN).getFace(BlockFace.NORTH, this.lobbyHalfSide - 1).getFace(this.wall, 9).setType(Material.GLOWSTONE); - BlockInfo.getBlock(this.warzone.getWorld(), this.lobbyMiddleWallBlock).getFace(BlockFace.DOWN).getFace(BlockFace.SOUTH, this.lobbyHalfSide - 1).getFace(this.wall, 9).setType(Material.GLOWSTONE); + BlockInfo.getBlock(this.warzone.getWorld(), this.lobbyMiddleWallBlock).getRelative(BlockFace.DOWN).getRelative(BlockFace.NORTH, this.lobbyHalfSide - 1).getRelative(this.wall, 9).setType(Material.GLOWSTONE); + BlockInfo.getBlock(this.warzone.getWorld(), this.lobbyMiddleWallBlock).getRelative(BlockFace.DOWN).getRelative(BlockFace.SOUTH, this.lobbyHalfSide - 1).getRelative(this.wall, 9).setType(Material.GLOWSTONE); } } else { War.war.log("Failed to initalize zone lobby for zone " + this.warzone.getName(), java.util.logging.Level.WARNING); @@ -372,23 +372,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.getFace(rightSide, doorIndex * 2 + 2))); + this.teamGateBlocks.put(team.getName(), new BlockInfo(lobbyMiddleWallBlock.getRelative(rightSide, doorIndex * 2 + 2))); } else { - this.teamGateBlocks.put(team.getName(), new BlockInfo(lobbyMiddleWallBlock.getFace(leftSide, doorIndex * 2))); + this.teamGateBlocks.put(team.getName(), new BlockInfo(lobbyMiddleWallBlock.getRelative(leftSide, doorIndex * 2))); } } else { if (doorIndex == 0) { this.teamGateBlocks.put(team.getName(), new BlockInfo(lobbyMiddleWallBlock)); } else if (doorIndex % 2 == 0) { - this.teamGateBlocks.put(team.getName(), new BlockInfo(lobbyMiddleWallBlock.getFace(rightSide, doorIndex * 2))); + this.teamGateBlocks.put(team.getName(), new BlockInfo(lobbyMiddleWallBlock.getRelative(rightSide, doorIndex * 2))); } else { - this.teamGateBlocks.put(team.getName(), new BlockInfo(lobbyMiddleWallBlock.getFace(leftSide, doorIndex * 2 + 2))); + this.teamGateBlocks.put(team.getName(), new BlockInfo(lobbyMiddleWallBlock.getRelative(leftSide, doorIndex * 2 + 2))); } } } } - this.warHubLinkGate = new BlockInfo(lobbyMiddleWallBlock.getFace(this.wall, 9)); + this.warHubLinkGate = new BlockInfo(lobbyMiddleWallBlock.getRelative(this.wall, 9)); } private void placeGate(Block block, TeamKind teamKind) { @@ -408,14 +408,14 @@ public class ZoneLobby { leftSide = BlockFace.NORTH; rightSide = BlockFace.SOUTH; } - block.getFace(BlockFace.DOWN).setType(Material.GLOWSTONE); - this.setBlock(block.getFace(leftSide), teamKind); - this.setBlock(block.getFace(rightSide).getFace(BlockFace.UP), teamKind); - this.setBlock(block.getFace(leftSide).getFace(BlockFace.UP).getFace(BlockFace.UP), teamKind); - this.setBlock(block.getFace(rightSide), teamKind); - this.setBlock(block.getFace(leftSide).getFace(BlockFace.UP), teamKind); - this.setBlock(block.getFace(rightSide).getFace(BlockFace.UP).getFace(BlockFace.UP), teamKind); - this.setBlock(block.getFace(BlockFace.UP).getFace(BlockFace.UP), teamKind); + block.getRelative(BlockFace.DOWN).setType(Material.GLOWSTONE); + this.setBlock(block.getRelative(leftSide), teamKind); + this.setBlock(block.getRelative(rightSide).getRelative(BlockFace.UP), teamKind); + this.setBlock(block.getRelative(leftSide).getRelative(BlockFace.UP).getRelative(BlockFace.UP), teamKind); + this.setBlock(block.getRelative(rightSide), teamKind); + this.setBlock(block.getRelative(leftSide).getRelative(BlockFace.UP), teamKind); + this.setBlock(block.getRelative(rightSide).getRelative(BlockFace.UP).getRelative(BlockFace.UP), teamKind); + this.setBlock(block.getRelative(BlockFace.UP).getRelative(BlockFace.UP), teamKind); } } @@ -436,14 +436,14 @@ public class ZoneLobby { leftSide = BlockFace.NORTH; rightSide = BlockFace.SOUTH; } - block.getFace(BlockFace.DOWN).setType(Material.GLOWSTONE); - this.setBlock(block.getFace(leftSide), material); - this.setBlock(block.getFace(rightSide).getFace(BlockFace.UP), material); - this.setBlock(block.getFace(leftSide).getFace(BlockFace.UP).getFace(BlockFace.UP), material); - this.setBlock(block.getFace(rightSide), material); - this.setBlock(block.getFace(leftSide).getFace(BlockFace.UP), material); - this.setBlock(block.getFace(rightSide).getFace(BlockFace.UP).getFace(BlockFace.UP), material); - this.setBlock(block.getFace(BlockFace.UP).getFace(BlockFace.UP), material); + block.getRelative(BlockFace.DOWN).setType(Material.GLOWSTONE); + this.setBlock(block.getRelative(leftSide), material); + this.setBlock(block.getRelative(rightSide).getRelative(BlockFace.UP), material); + this.setBlock(block.getRelative(leftSide).getRelative(BlockFace.UP).getRelative(BlockFace.UP), material); + this.setBlock(block.getRelative(rightSide), material); + this.setBlock(block.getRelative(leftSide).getRelative(BlockFace.UP), material); + this.setBlock(block.getRelative(rightSide).getRelative(BlockFace.UP).getRelative(BlockFace.UP), material); + this.setBlock(block.getRelative(BlockFace.UP).getRelative(BlockFace.UP), material); } } @@ -475,20 +475,20 @@ public class ZoneLobby { } List teams = this.warzone.getTeams(); Block autoAssignGateBlock = BlockInfo.getBlock(this.warzone.getWorld(), this.autoAssignGate); - this.setBlock(autoAssignGateBlock.getFace(BlockFace.DOWN), (Material.GLOWSTONE)); + this.setBlock(autoAssignGateBlock.getRelative(BlockFace.DOWN), (Material.GLOWSTONE)); int size = teams.size(); if (size > 0) { TeamKind[] doorBlockKinds = new TeamKind[7]; for (int i = 0; i < 7; i++) { doorBlockKinds[i] = teams.get(i % size).getKind(); } - this.setBlock(autoAssignGateBlock.getFace(leftSide), doorBlockKinds[0]); - this.setBlock(autoAssignGateBlock.getFace(leftSide).getFace(BlockFace.UP), doorBlockKinds[1]); - this.setBlock(autoAssignGateBlock.getFace(leftSide).getFace(BlockFace.UP).getFace(BlockFace.UP), doorBlockKinds[2]); - this.setBlock(autoAssignGateBlock.getFace(BlockFace.UP).getFace(BlockFace.UP), doorBlockKinds[3]); - this.setBlock(autoAssignGateBlock.getFace(rightSide).getFace(BlockFace.UP).getFace(BlockFace.UP), doorBlockKinds[4]); - this.setBlock(autoAssignGateBlock.getFace(rightSide).getFace(BlockFace.UP), doorBlockKinds[5]); - this.setBlock(autoAssignGateBlock.getFace(rightSide), doorBlockKinds[6]); + this.setBlock(autoAssignGateBlock.getRelative(leftSide), doorBlockKinds[0]); + this.setBlock(autoAssignGateBlock.getRelative(leftSide).getRelative(BlockFace.UP), doorBlockKinds[1]); + this.setBlock(autoAssignGateBlock.getRelative(leftSide).getRelative(BlockFace.UP).getRelative(BlockFace.UP), doorBlockKinds[2]); + this.setBlock(autoAssignGateBlock.getRelative(BlockFace.UP).getRelative(BlockFace.UP), doorBlockKinds[3]); + this.setBlock(autoAssignGateBlock.getRelative(rightSide).getRelative(BlockFace.UP).getRelative(BlockFace.UP), doorBlockKinds[4]); + this.setBlock(autoAssignGateBlock.getRelative(rightSide).getRelative(BlockFace.UP), doorBlockKinds[5]); + this.setBlock(autoAssignGateBlock.getRelative(rightSide), doorBlockKinds[6]); } } } @@ -562,7 +562,7 @@ public class ZoneLobby { leftSide = BlockFace.NORTH; rightSide = BlockFace.SOUTH; } - return (block.getX() == gateBlock.getX() && block.getY() == gateBlock.getY() && block.getZ() == gateBlock.getZ()) || (block.getX() == gateBlock.getFace(BlockFace.UP).getX() && block.getY() == gateBlock.getFace(BlockFace.UP).getY() && block.getZ() == gateBlock.getFace(BlockFace.UP).getZ()) || (block.getX() == gateBlock.getFace(leftSide).getX() && block.getY() == gateBlock.getFace(leftSide).getY() && block.getZ() == gateBlock.getFace(leftSide).getZ()) || (block.getX() == gateBlock.getFace(leftSide).getFace(BlockFace.UP).getX() && block.getY() == gateBlock.getFace(leftSide).getFace(BlockFace.UP).getY() && block.getZ() == gateBlock.getFace(leftSide).getFace(BlockFace.UP).getZ()) || (block.getX() == gateBlock.getFace(leftSide).getFace(BlockFace.UP).getFace(BlockFace.UP).getX() && block.getY() == gateBlock.getFace(leftSide).getFace(BlockFace.UP).getFace(BlockFace.UP).getY() && block.getZ() == gateBlock.getFace(leftSide).getFace(BlockFace.UP).getFace(BlockFace.UP).getZ()) || (block.getX() == gateBlock.getFace(BlockFace.UP).getFace(BlockFace.UP).getX() && block.getY() == gateBlock.getFace(BlockFace.UP).getFace(BlockFace.UP).getY() && block.getZ() == gateBlock.getFace(BlockFace.UP).getFace(BlockFace.UP).getZ()) || (block.getX() == gateBlock.getFace(rightSide).getFace(BlockFace.UP).getX() && block.getY() == gateBlock.getFace(rightSide).getFace(BlockFace.UP).getY() && block.getZ() == gateBlock.getFace(rightSide).getFace(BlockFace.UP).getZ()) || (block.getX() == gateBlock.getFace(rightSide).getFace(BlockFace.UP).getFace(BlockFace.UP).getX() && block.getY() == gateBlock.getFace(rightSide).getFace(BlockFace.UP).getFace(BlockFace.UP).getY() && block.getZ() == gateBlock.getFace(rightSide).getFace(BlockFace.UP).getFace(BlockFace.UP).getZ()) || (block.getX() == gateBlock.getFace(rightSide).getX() && block.getY() == gateBlock.getFace(rightSide).getY() && block.getZ() == gateBlock.getFace(rightSide).getZ()) || (block.getX() == gateBlock.getX() && block.getY() == gateBlock.getY() - 1 && block.getZ() == gateBlock.getZ()); + return (block.getX() == gateBlock.getX() && block.getY() == gateBlock.getY() && block.getZ() == gateBlock.getZ()) || (block.getX() == gateBlock.getRelative(BlockFace.UP).getX() && block.getY() == gateBlock.getRelative(BlockFace.UP).getY() && block.getZ() == gateBlock.getRelative(BlockFace.UP).getZ()) || (block.getX() == gateBlock.getRelative(leftSide).getX() && block.getY() == gateBlock.getRelative(leftSide).getY() && block.getZ() == gateBlock.getRelative(leftSide).getZ()) || (block.getX() == gateBlock.getRelative(leftSide).getRelative(BlockFace.UP).getX() && block.getY() == gateBlock.getRelative(leftSide).getRelative(BlockFace.UP).getY() && block.getZ() == gateBlock.getRelative(leftSide).getRelative(BlockFace.UP).getZ()) || (block.getX() == gateBlock.getRelative(leftSide).getRelative(BlockFace.UP).getRelative(BlockFace.UP).getX() && block.getY() == gateBlock.getRelative(leftSide).getRelative(BlockFace.UP).getRelative(BlockFace.UP).getY() && block.getZ() == gateBlock.getRelative(leftSide).getRelative(BlockFace.UP).getRelative(BlockFace.UP).getZ()) || (block.getX() == gateBlock.getRelative(BlockFace.UP).getRelative(BlockFace.UP).getX() && block.getY() == gateBlock.getRelative(BlockFace.UP).getRelative(BlockFace.UP).getY() && block.getZ() == gateBlock.getRelative(BlockFace.UP).getRelative(BlockFace.UP).getZ()) || (block.getX() == gateBlock.getRelative(rightSide).getRelative(BlockFace.UP).getX() && block.getY() == gateBlock.getRelative(rightSide).getRelative(BlockFace.UP).getY() && block.getZ() == gateBlock.getRelative(rightSide).getRelative(BlockFace.UP).getZ()) || (block.getX() == gateBlock.getRelative(rightSide).getRelative(BlockFace.UP).getRelative(BlockFace.UP).getX() && block.getY() == gateBlock.getRelative(rightSide).getRelative(BlockFace.UP).getRelative(BlockFace.UP).getY() && block.getZ() == gateBlock.getRelative(rightSide).getRelative(BlockFace.UP).getRelative(BlockFace.UP).getZ()) || (block.getX() == gateBlock.getRelative(rightSide).getX() && block.getY() == gateBlock.getRelative(rightSide).getY() && block.getZ() == gateBlock.getRelative(rightSide).getZ()) || (block.getX() == gateBlock.getX() && block.getY() == gateBlock.getY() - 1 && block.getZ() == gateBlock.getZ()); } return false; } @@ -609,28 +609,28 @@ public class ZoneLobby { } byte data = 0; if (this.wall == BlockFace.NORTH) { - block = gate.getFace(direction).getFace(BlockFace.EAST); + block = gate.getRelative(direction).getRelative(BlockFace.EAST); if (awayFromWall) { data = (byte) 4; } else { data = (byte) 12; } } else if (this.wall == BlockFace.EAST) { - block = gate.getFace(direction).getFace(BlockFace.SOUTH); + block = gate.getRelative(direction).getRelative(BlockFace.SOUTH); if (awayFromWall) { data = (byte) 8; } else { data = (byte) 0; } } else if (this.wall == BlockFace.SOUTH) { - block = gate.getFace(direction).getFace(BlockFace.WEST); + block = gate.getRelative(direction).getRelative(BlockFace.WEST); if (awayFromWall) { data = (byte) 12; } else { data = (byte) 4; } } else if (this.wall == BlockFace.WEST) { - block = gate.getFace(direction).getFace(BlockFace.NORTH); + block = gate.getRelative(direction).getRelative(BlockFace.NORTH); if (awayFromWall) { data = (byte) 0; } else { @@ -680,9 +680,9 @@ public class ZoneLobby { private boolean leaving(Location location, Block gate, BlockFace inside, BlockFace left, BlockFace right) { // 3x4x1 deep Volume gateExitVolume = new Volume("tempGateExit", location.getWorld()); - Block out = gate.getFace(inside); - gateExitVolume.setCornerOne(out.getFace(left).getFace(BlockFace.DOWN)); - gateExitVolume.setCornerTwo(gate.getFace(right, 1).getFace(BlockFace.UP, 2)); + Block out = gate.getRelative(inside); + gateExitVolume.setCornerOne(out.getRelative(left).getRelative(BlockFace.DOWN)); + gateExitVolume.setCornerTwo(gate.getRelative(right, 1).getRelative(BlockFace.UP, 2)); if (gateExitVolume.contains(location)) { return true; diff --git a/war/src/main/java/com/tommytony/war/ZoneWallGuard.java b/war/src/main/java/com/tommytony/war/ZoneWallGuard.java index 25c0ef6..a4e8cfa 100644 --- a/war/src/main/java/com/tommytony/war/ZoneWallGuard.java +++ b/war/src/main/java/com/tommytony/war/ZoneWallGuard.java @@ -40,121 +40,121 @@ public class ZoneWallGuard { for (Block block : nearestWallBlocks) { this.glassify(block, this.wall); if (this.wall != BlockFace.UP && this.wall != BlockFace.DOWN) { - this.glassify(block.getFace(BlockFace.UP), this.wall); - this.glassify(block.getFace(BlockFace.UP, 2), this.wall); - this.glassify(block.getFace(BlockFace.DOWN), this.wall); - this.glassify(block.getFace(BlockFace.DOWN, 2), this.wall); + this.glassify(block.getRelative(BlockFace.UP), this.wall); + this.glassify(block.getRelative(BlockFace.UP, 2), this.wall); + this.glassify(block.getRelative(BlockFace.DOWN), this.wall); + this.glassify(block.getRelative(BlockFace.DOWN, 2), this.wall); } if (this.wall == BlockFace.NORTH && this.warzone.getVolume().isNorthWallBlock(block)) { - this.glassify(block.getFace(BlockFace.EAST), BlockFace.NORTH); - this.glassify(block.getFace(BlockFace.EAST).getFace(BlockFace.UP), BlockFace.NORTH); - this.glassify(block.getFace(BlockFace.EAST).getFace(BlockFace.DOWN), BlockFace.NORTH); - this.glassify(block.getFace(BlockFace.EAST, 2), BlockFace.NORTH); - this.glassify(block.getFace(BlockFace.EAST, 2).getFace(BlockFace.UP), BlockFace.NORTH); - this.glassify(block.getFace(BlockFace.EAST, 2).getFace(BlockFace.DOWN), BlockFace.NORTH); - this.glassify(block.getFace(BlockFace.EAST).getFace(BlockFace.UP, 2), BlockFace.NORTH); - this.glassify(block.getFace(BlockFace.EAST).getFace(BlockFace.DOWN, 2), BlockFace.NORTH); - this.glassify(block.getFace(BlockFace.WEST), BlockFace.NORTH); - this.glassify(block.getFace(BlockFace.WEST).getFace(BlockFace.UP), BlockFace.NORTH); - this.glassify(block.getFace(BlockFace.WEST).getFace(BlockFace.DOWN), BlockFace.NORTH); - this.glassify(block.getFace(BlockFace.WEST, 2), BlockFace.NORTH); - this.glassify(block.getFace(BlockFace.WEST, 2).getFace(BlockFace.UP), BlockFace.NORTH); - this.glassify(block.getFace(BlockFace.WEST, 2).getFace(BlockFace.DOWN), BlockFace.NORTH); - this.glassify(block.getFace(BlockFace.WEST).getFace(BlockFace.UP, 2), BlockFace.NORTH); - this.glassify(block.getFace(BlockFace.WEST).getFace(BlockFace.DOWN, 2), BlockFace.NORTH); + this.glassify(block.getRelative(BlockFace.EAST), BlockFace.NORTH); + this.glassify(block.getRelative(BlockFace.EAST).getRelative(BlockFace.UP), BlockFace.NORTH); + this.glassify(block.getRelative(BlockFace.EAST).getRelative(BlockFace.DOWN), BlockFace.NORTH); + this.glassify(block.getRelative(BlockFace.EAST, 2), BlockFace.NORTH); + this.glassify(block.getRelative(BlockFace.EAST, 2).getRelative(BlockFace.UP), BlockFace.NORTH); + this.glassify(block.getRelative(BlockFace.EAST, 2).getRelative(BlockFace.DOWN), BlockFace.NORTH); + this.glassify(block.getRelative(BlockFace.EAST).getRelative(BlockFace.UP, 2), BlockFace.NORTH); + this.glassify(block.getRelative(BlockFace.EAST).getRelative(BlockFace.DOWN, 2), BlockFace.NORTH); + this.glassify(block.getRelative(BlockFace.WEST), BlockFace.NORTH); + this.glassify(block.getRelative(BlockFace.WEST).getRelative(BlockFace.UP), BlockFace.NORTH); + this.glassify(block.getRelative(BlockFace.WEST).getRelative(BlockFace.DOWN), BlockFace.NORTH); + this.glassify(block.getRelative(BlockFace.WEST, 2), BlockFace.NORTH); + this.glassify(block.getRelative(BlockFace.WEST, 2).getRelative(BlockFace.UP), BlockFace.NORTH); + this.glassify(block.getRelative(BlockFace.WEST, 2).getRelative(BlockFace.DOWN), BlockFace.NORTH); + this.glassify(block.getRelative(BlockFace.WEST).getRelative(BlockFace.UP, 2), BlockFace.NORTH); + this.glassify(block.getRelative(BlockFace.WEST).getRelative(BlockFace.DOWN, 2), BlockFace.NORTH); } else if (this.wall == BlockFace.SOUTH && this.warzone.getVolume().isSouthWallBlock(block)) { - this.glassify(block.getFace(BlockFace.EAST), BlockFace.SOUTH); - this.glassify(block.getFace(BlockFace.EAST).getFace(BlockFace.UP), BlockFace.SOUTH); - this.glassify(block.getFace(BlockFace.EAST).getFace(BlockFace.DOWN), BlockFace.SOUTH); - this.glassify(block.getFace(BlockFace.EAST, 2), BlockFace.SOUTH); - this.glassify(block.getFace(BlockFace.EAST, 2).getFace(BlockFace.UP), BlockFace.SOUTH); - this.glassify(block.getFace(BlockFace.EAST, 2).getFace(BlockFace.DOWN), BlockFace.SOUTH); - this.glassify(block.getFace(BlockFace.EAST).getFace(BlockFace.UP, 2), BlockFace.SOUTH); - this.glassify(block.getFace(BlockFace.EAST).getFace(BlockFace.DOWN, 2), BlockFace.SOUTH); - this.glassify(block.getFace(BlockFace.WEST), BlockFace.SOUTH); - this.glassify(block.getFace(BlockFace.WEST).getFace(BlockFace.UP), BlockFace.SOUTH); - this.glassify(block.getFace(BlockFace.WEST).getFace(BlockFace.DOWN), BlockFace.SOUTH); - this.glassify(block.getFace(BlockFace.WEST, 2), BlockFace.SOUTH); - this.glassify(block.getFace(BlockFace.WEST, 2).getFace(BlockFace.UP), BlockFace.SOUTH); - this.glassify(block.getFace(BlockFace.WEST, 2).getFace(BlockFace.DOWN), BlockFace.SOUTH); - this.glassify(block.getFace(BlockFace.WEST).getFace(BlockFace.UP, 2), BlockFace.SOUTH); - this.glassify(block.getFace(BlockFace.WEST).getFace(BlockFace.DOWN, 2), BlockFace.SOUTH); + this.glassify(block.getRelative(BlockFace.EAST), BlockFace.SOUTH); + this.glassify(block.getRelative(BlockFace.EAST).getRelative(BlockFace.UP), BlockFace.SOUTH); + this.glassify(block.getRelative(BlockFace.EAST).getRelative(BlockFace.DOWN), BlockFace.SOUTH); + this.glassify(block.getRelative(BlockFace.EAST, 2), BlockFace.SOUTH); + this.glassify(block.getRelative(BlockFace.EAST, 2).getRelative(BlockFace.UP), BlockFace.SOUTH); + this.glassify(block.getRelative(BlockFace.EAST, 2).getRelative(BlockFace.DOWN), BlockFace.SOUTH); + this.glassify(block.getRelative(BlockFace.EAST).getRelative(BlockFace.UP, 2), BlockFace.SOUTH); + this.glassify(block.getRelative(BlockFace.EAST).getRelative(BlockFace.DOWN, 2), BlockFace.SOUTH); + this.glassify(block.getRelative(BlockFace.WEST), BlockFace.SOUTH); + this.glassify(block.getRelative(BlockFace.WEST).getRelative(BlockFace.UP), BlockFace.SOUTH); + this.glassify(block.getRelative(BlockFace.WEST).getRelative(BlockFace.DOWN), BlockFace.SOUTH); + this.glassify(block.getRelative(BlockFace.WEST, 2), BlockFace.SOUTH); + this.glassify(block.getRelative(BlockFace.WEST, 2).getRelative(BlockFace.UP), BlockFace.SOUTH); + this.glassify(block.getRelative(BlockFace.WEST, 2).getRelative(BlockFace.DOWN), BlockFace.SOUTH); + this.glassify(block.getRelative(BlockFace.WEST).getRelative(BlockFace.UP, 2), BlockFace.SOUTH); + this.glassify(block.getRelative(BlockFace.WEST).getRelative(BlockFace.DOWN, 2), BlockFace.SOUTH); } else if (this.wall == BlockFace.EAST && this.warzone.getVolume().isEastWallBlock(block)) { - this.glassify(block.getFace(BlockFace.NORTH), BlockFace.EAST); - this.glassify(block.getFace(BlockFace.NORTH).getFace(BlockFace.UP), BlockFace.EAST); - this.glassify(block.getFace(BlockFace.NORTH).getFace(BlockFace.DOWN), BlockFace.EAST); - this.glassify(block.getFace(BlockFace.NORTH, 2), BlockFace.EAST); - this.glassify(block.getFace(BlockFace.NORTH, 2).getFace(BlockFace.UP), BlockFace.EAST); - this.glassify(block.getFace(BlockFace.NORTH, 2).getFace(BlockFace.DOWN), BlockFace.EAST); - this.glassify(block.getFace(BlockFace.NORTH).getFace(BlockFace.UP, 2), BlockFace.EAST); - this.glassify(block.getFace(BlockFace.NORTH).getFace(BlockFace.DOWN, 2), BlockFace.EAST); - this.glassify(block.getFace(BlockFace.SOUTH), BlockFace.EAST); - this.glassify(block.getFace(BlockFace.SOUTH).getFace(BlockFace.UP), BlockFace.EAST); - this.glassify(block.getFace(BlockFace.SOUTH).getFace(BlockFace.DOWN), BlockFace.EAST); - this.glassify(block.getFace(BlockFace.SOUTH, 2), BlockFace.EAST); - this.glassify(block.getFace(BlockFace.SOUTH, 2).getFace(BlockFace.UP), BlockFace.EAST); - this.glassify(block.getFace(BlockFace.SOUTH, 2).getFace(BlockFace.DOWN), BlockFace.EAST); - this.glassify(block.getFace(BlockFace.SOUTH).getFace(BlockFace.UP, 2), BlockFace.EAST); - this.glassify(block.getFace(BlockFace.SOUTH).getFace(BlockFace.DOWN, 2), BlockFace.EAST); + this.glassify(block.getRelative(BlockFace.NORTH), BlockFace.EAST); + this.glassify(block.getRelative(BlockFace.NORTH).getRelative(BlockFace.UP), BlockFace.EAST); + this.glassify(block.getRelative(BlockFace.NORTH).getRelative(BlockFace.DOWN), BlockFace.EAST); + this.glassify(block.getRelative(BlockFace.NORTH, 2), BlockFace.EAST); + this.glassify(block.getRelative(BlockFace.NORTH, 2).getRelative(BlockFace.UP), BlockFace.EAST); + this.glassify(block.getRelative(BlockFace.NORTH, 2).getRelative(BlockFace.DOWN), BlockFace.EAST); + this.glassify(block.getRelative(BlockFace.NORTH).getRelative(BlockFace.UP, 2), BlockFace.EAST); + this.glassify(block.getRelative(BlockFace.NORTH).getRelative(BlockFace.DOWN, 2), BlockFace.EAST); + this.glassify(block.getRelative(BlockFace.SOUTH), BlockFace.EAST); + this.glassify(block.getRelative(BlockFace.SOUTH).getRelative(BlockFace.UP), BlockFace.EAST); + this.glassify(block.getRelative(BlockFace.SOUTH).getRelative(BlockFace.DOWN), BlockFace.EAST); + this.glassify(block.getRelative(BlockFace.SOUTH, 2), BlockFace.EAST); + this.glassify(block.getRelative(BlockFace.SOUTH, 2).getRelative(BlockFace.UP), BlockFace.EAST); + this.glassify(block.getRelative(BlockFace.SOUTH, 2).getRelative(BlockFace.DOWN), BlockFace.EAST); + this.glassify(block.getRelative(BlockFace.SOUTH).getRelative(BlockFace.UP, 2), BlockFace.EAST); + this.glassify(block.getRelative(BlockFace.SOUTH).getRelative(BlockFace.DOWN, 2), BlockFace.EAST); } else if (this.wall == BlockFace.WEST && this.warzone.getVolume().isWestWallBlock(block)) { - this.glassify(block.getFace(BlockFace.NORTH), BlockFace.WEST); - this.glassify(block.getFace(BlockFace.NORTH).getFace(BlockFace.UP), BlockFace.WEST); - this.glassify(block.getFace(BlockFace.NORTH).getFace(BlockFace.DOWN), BlockFace.WEST); - this.glassify(block.getFace(BlockFace.NORTH, 2), BlockFace.WEST); - this.glassify(block.getFace(BlockFace.NORTH, 2).getFace(BlockFace.UP), BlockFace.WEST); - this.glassify(block.getFace(BlockFace.NORTH, 2).getFace(BlockFace.DOWN), BlockFace.WEST); - this.glassify(block.getFace(BlockFace.NORTH).getFace(BlockFace.UP, 2), BlockFace.WEST); - this.glassify(block.getFace(BlockFace.NORTH).getFace(BlockFace.DOWN, 2), BlockFace.WEST); - this.glassify(block.getFace(BlockFace.SOUTH), BlockFace.WEST); - this.glassify(block.getFace(BlockFace.SOUTH).getFace(BlockFace.UP), BlockFace.WEST); - this.glassify(block.getFace(BlockFace.SOUTH).getFace(BlockFace.DOWN), BlockFace.WEST); - this.glassify(block.getFace(BlockFace.SOUTH, 2), BlockFace.WEST); - this.glassify(block.getFace(BlockFace.SOUTH, 2).getFace(BlockFace.UP), BlockFace.WEST); - this.glassify(block.getFace(BlockFace.SOUTH, 2).getFace(BlockFace.DOWN), BlockFace.WEST); - this.glassify(block.getFace(BlockFace.SOUTH).getFace(BlockFace.UP, 2), BlockFace.WEST); - this.glassify(block.getFace(BlockFace.SOUTH).getFace(BlockFace.DOWN, 2), BlockFace.WEST); + this.glassify(block.getRelative(BlockFace.NORTH), BlockFace.WEST); + this.glassify(block.getRelative(BlockFace.NORTH).getRelative(BlockFace.UP), BlockFace.WEST); + this.glassify(block.getRelative(BlockFace.NORTH).getRelative(BlockFace.DOWN), BlockFace.WEST); + this.glassify(block.getRelative(BlockFace.NORTH, 2), BlockFace.WEST); + this.glassify(block.getRelative(BlockFace.NORTH, 2).getRelative(BlockFace.UP), BlockFace.WEST); + this.glassify(block.getRelative(BlockFace.NORTH, 2).getRelative(BlockFace.DOWN), BlockFace.WEST); + this.glassify(block.getRelative(BlockFace.NORTH).getRelative(BlockFace.UP, 2), BlockFace.WEST); + this.glassify(block.getRelative(BlockFace.NORTH).getRelative(BlockFace.DOWN, 2), BlockFace.WEST); + this.glassify(block.getRelative(BlockFace.SOUTH), BlockFace.WEST); + this.glassify(block.getRelative(BlockFace.SOUTH).getRelative(BlockFace.UP), BlockFace.WEST); + this.glassify(block.getRelative(BlockFace.SOUTH).getRelative(BlockFace.DOWN), BlockFace.WEST); + this.glassify(block.getRelative(BlockFace.SOUTH, 2), BlockFace.WEST); + this.glassify(block.getRelative(BlockFace.SOUTH, 2).getRelative(BlockFace.UP), BlockFace.WEST); + this.glassify(block.getRelative(BlockFace.SOUTH, 2).getRelative(BlockFace.DOWN), BlockFace.WEST); + this.glassify(block.getRelative(BlockFace.SOUTH).getRelative(BlockFace.UP, 2), BlockFace.WEST); + this.glassify(block.getRelative(BlockFace.SOUTH).getRelative(BlockFace.DOWN, 2), BlockFace.WEST); } else if (this.wall == BlockFace.UP && this.warzone.getVolume().isUpWallBlock(block)) { - this.glassify(block.getFace(BlockFace.EAST), BlockFace.UP); - this.glassify(block.getFace(BlockFace.EAST, 2), BlockFace.UP); - this.glassify(block.getFace(BlockFace.WEST), BlockFace.UP); - this.glassify(block.getFace(BlockFace.WEST, 2), BlockFace.UP); - this.glassify(block.getFace(BlockFace.NORTH), BlockFace.UP); - this.glassify(block.getFace(BlockFace.NORTH).getFace(BlockFace.EAST), BlockFace.UP); - this.glassify(block.getFace(BlockFace.NORTH).getFace(BlockFace.WEST), BlockFace.UP); - this.glassify(block.getFace(BlockFace.NORTH, 2), BlockFace.UP); - this.glassify(block.getFace(BlockFace.NORTH, 2).getFace(BlockFace.EAST), BlockFace.UP); - this.glassify(block.getFace(BlockFace.NORTH, 2).getFace(BlockFace.WEST), BlockFace.UP); - this.glassify(block.getFace(BlockFace.NORTH).getFace(BlockFace.EAST, 2), BlockFace.UP); - this.glassify(block.getFace(BlockFace.NORTH).getFace(BlockFace.WEST, 2), BlockFace.UP); - this.glassify(block.getFace(BlockFace.SOUTH), BlockFace.UP); - this.glassify(block.getFace(BlockFace.SOUTH).getFace(BlockFace.EAST), BlockFace.UP); - this.glassify(block.getFace(BlockFace.SOUTH).getFace(BlockFace.WEST), BlockFace.UP); - this.glassify(block.getFace(BlockFace.SOUTH, 2), BlockFace.UP); - this.glassify(block.getFace(BlockFace.SOUTH, 2).getFace(BlockFace.EAST), BlockFace.UP); - this.glassify(block.getFace(BlockFace.SOUTH, 2).getFace(BlockFace.WEST), BlockFace.UP); - this.glassify(block.getFace(BlockFace.SOUTH).getFace(BlockFace.UP, 2), BlockFace.UP); - this.glassify(block.getFace(BlockFace.SOUTH).getFace(BlockFace.DOWN, 2), BlockFace.UP); + this.glassify(block.getRelative(BlockFace.EAST), BlockFace.UP); + this.glassify(block.getRelative(BlockFace.EAST, 2), BlockFace.UP); + this.glassify(block.getRelative(BlockFace.WEST), BlockFace.UP); + this.glassify(block.getRelative(BlockFace.WEST, 2), BlockFace.UP); + this.glassify(block.getRelative(BlockFace.NORTH), BlockFace.UP); + this.glassify(block.getRelative(BlockFace.NORTH).getRelative(BlockFace.EAST), BlockFace.UP); + this.glassify(block.getRelative(BlockFace.NORTH).getRelative(BlockFace.WEST), BlockFace.UP); + this.glassify(block.getRelative(BlockFace.NORTH, 2), BlockFace.UP); + this.glassify(block.getRelative(BlockFace.NORTH, 2).getRelative(BlockFace.EAST), BlockFace.UP); + this.glassify(block.getRelative(BlockFace.NORTH, 2).getRelative(BlockFace.WEST), BlockFace.UP); + this.glassify(block.getRelative(BlockFace.NORTH).getRelative(BlockFace.EAST, 2), BlockFace.UP); + this.glassify(block.getRelative(BlockFace.NORTH).getRelative(BlockFace.WEST, 2), BlockFace.UP); + this.glassify(block.getRelative(BlockFace.SOUTH), BlockFace.UP); + this.glassify(block.getRelative(BlockFace.SOUTH).getRelative(BlockFace.EAST), BlockFace.UP); + this.glassify(block.getRelative(BlockFace.SOUTH).getRelative(BlockFace.WEST), BlockFace.UP); + this.glassify(block.getRelative(BlockFace.SOUTH, 2), BlockFace.UP); + this.glassify(block.getRelative(BlockFace.SOUTH, 2).getRelative(BlockFace.EAST), BlockFace.UP); + this.glassify(block.getRelative(BlockFace.SOUTH, 2).getRelative(BlockFace.WEST), BlockFace.UP); + this.glassify(block.getRelative(BlockFace.SOUTH).getRelative(BlockFace.UP, 2), BlockFace.UP); + this.glassify(block.getRelative(BlockFace.SOUTH).getRelative(BlockFace.DOWN, 2), BlockFace.UP); } else if (this.wall == BlockFace.DOWN && this.warzone.getVolume().isDownWallBlock(block)) { - this.glassify(block.getFace(BlockFace.EAST), BlockFace.DOWN); - this.glassify(block.getFace(BlockFace.EAST, 2), BlockFace.DOWN); - this.glassify(block.getFace(BlockFace.WEST), BlockFace.DOWN); - this.glassify(block.getFace(BlockFace.WEST, 2), BlockFace.DOWN); - this.glassify(block.getFace(BlockFace.NORTH), BlockFace.DOWN); - this.glassify(block.getFace(BlockFace.NORTH).getFace(BlockFace.EAST), BlockFace.DOWN); - this.glassify(block.getFace(BlockFace.NORTH).getFace(BlockFace.WEST), BlockFace.DOWN); - this.glassify(block.getFace(BlockFace.NORTH, 2), BlockFace.DOWN); - this.glassify(block.getFace(BlockFace.NORTH, 2).getFace(BlockFace.EAST), BlockFace.DOWN); - this.glassify(block.getFace(BlockFace.NORTH, 2).getFace(BlockFace.WEST), BlockFace.DOWN); - this.glassify(block.getFace(BlockFace.NORTH).getFace(BlockFace.EAST, 2), BlockFace.DOWN); - this.glassify(block.getFace(BlockFace.NORTH).getFace(BlockFace.WEST, 2), BlockFace.DOWN); - this.glassify(block.getFace(BlockFace.SOUTH), BlockFace.DOWN); - this.glassify(block.getFace(BlockFace.SOUTH).getFace(BlockFace.EAST), BlockFace.DOWN); - this.glassify(block.getFace(BlockFace.SOUTH).getFace(BlockFace.WEST), BlockFace.DOWN); - this.glassify(block.getFace(BlockFace.SOUTH, 2), BlockFace.DOWN); - this.glassify(block.getFace(BlockFace.SOUTH, 2).getFace(BlockFace.EAST), BlockFace.DOWN); - this.glassify(block.getFace(BlockFace.SOUTH, 2).getFace(BlockFace.WEST), BlockFace.DOWN); - this.glassify(block.getFace(BlockFace.SOUTH).getFace(BlockFace.DOWN, 2), BlockFace.DOWN); - this.glassify(block.getFace(BlockFace.SOUTH).getFace(BlockFace.DOWN, 2), BlockFace.DOWN); + this.glassify(block.getRelative(BlockFace.EAST), BlockFace.DOWN); + this.glassify(block.getRelative(BlockFace.EAST, 2), BlockFace.DOWN); + this.glassify(block.getRelative(BlockFace.WEST), BlockFace.DOWN); + this.glassify(block.getRelative(BlockFace.WEST, 2), BlockFace.DOWN); + this.glassify(block.getRelative(BlockFace.NORTH), BlockFace.DOWN); + this.glassify(block.getRelative(BlockFace.NORTH).getRelative(BlockFace.EAST), BlockFace.DOWN); + this.glassify(block.getRelative(BlockFace.NORTH).getRelative(BlockFace.WEST), BlockFace.DOWN); + this.glassify(block.getRelative(BlockFace.NORTH, 2), BlockFace.DOWN); + this.glassify(block.getRelative(BlockFace.NORTH, 2).getRelative(BlockFace.EAST), BlockFace.DOWN); + this.glassify(block.getRelative(BlockFace.NORTH, 2).getRelative(BlockFace.WEST), BlockFace.DOWN); + this.glassify(block.getRelative(BlockFace.NORTH).getRelative(BlockFace.EAST, 2), BlockFace.DOWN); + this.glassify(block.getRelative(BlockFace.NORTH).getRelative(BlockFace.WEST, 2), BlockFace.DOWN); + this.glassify(block.getRelative(BlockFace.SOUTH), BlockFace.DOWN); + this.glassify(block.getRelative(BlockFace.SOUTH).getRelative(BlockFace.EAST), BlockFace.DOWN); + this.glassify(block.getRelative(BlockFace.SOUTH).getRelative(BlockFace.WEST), BlockFace.DOWN); + this.glassify(block.getRelative(BlockFace.SOUTH, 2), BlockFace.DOWN); + this.glassify(block.getRelative(BlockFace.SOUTH, 2).getRelative(BlockFace.EAST), BlockFace.DOWN); + this.glassify(block.getRelative(BlockFace.SOUTH, 2).getRelative(BlockFace.WEST), BlockFace.DOWN); + this.glassify(block.getRelative(BlockFace.SOUTH).getRelative(BlockFace.DOWN, 2), BlockFace.DOWN); + this.glassify(block.getRelative(BlockFace.SOUTH).getRelative(BlockFace.DOWN, 2), BlockFace.DOWN); } } } diff --git a/war/src/main/java/com/tommytony/war/jobs/ResetCursorJob.java b/war/src/main/java/com/tommytony/war/jobs/ResetCursorJob.java index 11fd145..e14faf3 100644 --- a/war/src/main/java/com/tommytony/war/jobs/ResetCursorJob.java +++ b/war/src/main/java/com/tommytony/war/jobs/ResetCursorJob.java @@ -21,17 +21,17 @@ public class ResetCursorJob implements Runnable { if (this.isSoutheast) { this.cornerBlock.setType(this.originalCursorBlocks[0].getType()); this.cornerBlock.setData(this.originalCursorBlocks[0].getData()); - this.cornerBlock.getFace(BlockFace.WEST).setType(this.originalCursorBlocks[1].getType()); - this.cornerBlock.getFace(BlockFace.WEST).setData(this.originalCursorBlocks[1].getData()); - this.cornerBlock.getFace(BlockFace.NORTH).setType(this.originalCursorBlocks[2].getType()); - this.cornerBlock.getFace(BlockFace.NORTH).setData(this.originalCursorBlocks[2].getData()); + this.cornerBlock.getRelative(BlockFace.WEST).setType(this.originalCursorBlocks[1].getType()); + this.cornerBlock.getRelative(BlockFace.WEST).setData(this.originalCursorBlocks[1].getData()); + this.cornerBlock.getRelative(BlockFace.NORTH).setType(this.originalCursorBlocks[2].getType()); + this.cornerBlock.getRelative(BlockFace.NORTH).setData(this.originalCursorBlocks[2].getData()); } else { this.cornerBlock.setType(this.originalCursorBlocks[0].getType()); this.cornerBlock.setData(this.originalCursorBlocks[0].getData()); - this.cornerBlock.getFace(BlockFace.EAST).setType(this.originalCursorBlocks[1].getType()); - this.cornerBlock.getFace(BlockFace.EAST).setData(this.originalCursorBlocks[1].getData()); - this.cornerBlock.getFace(BlockFace.SOUTH).setType(this.originalCursorBlocks[2].getType()); - this.cornerBlock.getFace(BlockFace.SOUTH).setData(this.originalCursorBlocks[2].getData()); + this.cornerBlock.getRelative(BlockFace.EAST).setType(this.originalCursorBlocks[1].getType()); + this.cornerBlock.getRelative(BlockFace.EAST).setData(this.originalCursorBlocks[1].getData()); + this.cornerBlock.getRelative(BlockFace.SOUTH).setType(this.originalCursorBlocks[2].getType()); + this.cornerBlock.getRelative(BlockFace.SOUTH).setData(this.originalCursorBlocks[2].getData()); } } } 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 5ab8130..4910686 100644 --- a/war/src/main/java/com/tommytony/war/volumes/Volume.java +++ b/war/src/main/java/com/tommytony/war/volumes/Volume.java @@ -165,7 +165,7 @@ public class Volume { if (oldBlockType == Material.WALL_SIGN.getId() || oldBlockType == Material.SIGN_POST.getId()) { // Signs if (oldBlockType == Material.SIGN_POST.getId() && ((oldBlockData & 0x04) == 0x04) && i + 1 != this.getSizeX()) { - Block southBlock = currentBlock.getFace(BlockFace.SOUTH); + Block southBlock = currentBlock.getRelative(BlockFace.SOUTH); int oldSouthBlockType = this.getBlockTypes()[i + 1][j][k]; byte oldSouthBlockData = this.getBlockDatas()[i + 1][j][k]; if (southBlock.getTypeId() != oldSouthBlockType) { @@ -251,7 +251,7 @@ public class Volume { } } else if (((oldBlockType == Material.TORCH.getId() && ((oldBlockData & 0x02) == 0x02)) || (oldBlockType == Material.REDSTONE_TORCH_OFF.getId() && ((oldBlockData & 0x02) == 0x02)) || (oldBlockType == Material.REDSTONE_TORCH_ON.getId() && ((oldBlockData & 0x02) == 0x02)) || (oldBlockType == Material.LEVER.getId() && ((oldBlockData & 0x02) == 0x02)) || (oldBlockType == Material.STONE_BUTTON.getId() && ((oldBlockData & 0x02) == 0x02)) || (oldBlockType == Material.LADDER.getId() && ((oldBlockData & 0x04) == 0x04)) || (oldBlockType == Material.RAILS.getId() && ((oldBlockData & 0x02) == 0x02))) && i + 1 != this.getSizeX()) { // Blocks that hang on a block south of themselves need to make sure that block is there before placing themselves... lol - Block southBlock = currentBlock.getFace(BlockFace.SOUTH); + Block southBlock = currentBlock.getRelative(BlockFace.SOUTH); int oldSouthBlockType = this.getBlockTypes()[i + 1][j][k]; byte oldSouthBlockData = this.getBlockDatas()[i + 1][j][k]; if (southBlock.getTypeId() != oldSouthBlockType) {