From 5d5f2ada5e2e4f1fd1ba52dc9d8e23af89c15a09 Mon Sep 17 00:00:00 2001 From: taoneill Date: Fri, 21 Jan 2011 00:54:04 -0500 Subject: [PATCH] Updated to new command args for #107+. Fixed rezising messing up the world, except for that damn row of glass for the lobbies. Lobby set down with outline now. --- .../main/java/bukkit/tommytony/war/War.java | 158 +++++++++++------- .../tommytony/war/WarEntityListener.java | 1 - .../tommytony/war/WarPlayerListener.java | 25 ++- .../main/java/com/tommytony/war/Warzone.java | 34 ++-- .../java/com/tommytony/war/ZoneLobby.java | 139 ++++++++------- .../com/tommytony/war/mappers/WarMapper.java | 2 +- war/src/main/java/plugin.yml | 33 ++-- war/target/classes/plugin.yml | 33 ++-- 8 files changed, 228 insertions(+), 197 deletions(-) diff --git a/war/src/main/java/bukkit/tommytony/war/War.java b/war/src/main/java/bukkit/tommytony/war/War.java index 0d69700..fa99d26 100644 --- a/war/src/main/java/bukkit/tommytony/war/War.java +++ b/war/src/main/java/bukkit/tommytony/war/War.java @@ -42,6 +42,7 @@ public class War extends JavaPlugin { PluginDescriptionFile desc, File folder, File plugin, ClassLoader cLoader) { super(pluginLoader, instance, desc, folder, plugin, cLoader); // TODO: switch to bukkit config file + this.desc = desc; } @@ -49,9 +50,7 @@ public class War extends JavaPlugin { private WarEntityListener entityListener = new WarEntityListener(this); private WarBlockListener blockListener = new WarBlockListener(this); private Logger log; - String name = "War"; - String version = "0.3"; - String versionCodeName = "Patton"; + private PluginDescriptionFile desc = null; private final List warzones = new ArrayList(); private final List zoneMakerNames = new ArrayList(); @@ -76,17 +75,18 @@ public class War extends JavaPlugin { if(warHub != null) { warHub.getVolume().resetBlocks(); } - this.info("All warzone blocks reset. War v" + version + " (" + versionCodeName + ") is off."); + this.info("All warzone blocks reset. War v" + desc.getVersion() + " is off."); } public void onEnable() { this.log = Logger.getLogger("Minecraft"); + // Register hooks PluginManager pm = getServer().getPluginManager(); - pm.registerEvent(Event.Type.PLAYER_LOGIN, playerListener, Priority.Normal, this); - pm.registerEvent(Event.Type.PLAYER_QUIT, playerListener, Priority.Normal, this); + pm.registerEvent(Event.Type.PLAYER_LOGIN, playerListener, Priority.Monitor, this); + pm.registerEvent(Event.Type.PLAYER_QUIT, playerListener, Priority.Monitor, this); pm.registerEvent(Event.Type.PLAYER_MOVE, playerListener, Priority.High, this); pm.registerEvent(Event.Type.ENTITY_DAMAGEDBY_ENTITY, entityListener, Priority.Normal, this); @@ -103,8 +103,8 @@ public class War extends JavaPlugin { this.defaultLifepool = 7; this.defaultFriendlyFire = false; this.defaultAutoAssignOnly = false; - WarMapper.load(this, this.getServer().getWorlds()[0]); - this.info("War v"+ version + " (" + versionCodeName + ") is on."); + WarMapper.load(this, this.getServer().getWorlds()[0]); + this.info("War v"+ desc.getVersion() + " is on."); } public boolean onCommand(Player player, Command cmd, String commandLabel, String[] args) { @@ -113,18 +113,15 @@ public class War extends JavaPlugin { // Handle both /war and /. I.e. "/war zone temple" == "/zone temple" if((command.equals("war") || command.equals("War")) && args.length > 1) { command = args[1]; - arguments = new String[args.length - 2]; + arguments = new String[args.length - 1]; for(int i = 2; i <= arguments.length; i++) { - arguments[i-2] = args[i]; + arguments[i-1] = args[i]; } } else if (command.equals("war") || command.equals("War")) { player.sendMessage(this.str("War is on. Please pick your battle. " + "Use /warhub, /zones and /zone.")); } else { - arguments = new String[args.length - 1]; - for(int i = 1; i <= arguments.length; i++) { - arguments[i-1] = args[i]; - } + arguments = args; } // Player commands: /warzones, /warzone, /teams, /join, /leave @@ -245,10 +242,17 @@ public class War extends JavaPlugin { playerTeam.resetSign(); Warzone zone = this.warzone(player.getLocation()); + if(zone.getLobby() != null) { + zone.getLobby().resetTeamGateSign(playerTeam); + } player.teleportTo(zone.getTeleport()); - player.sendMessage(this.str("Left the zone.")); - zone.restorePlayerInventory(player); - player.sendMessage(this.str("Your inventory has (hopefully) been restored.")); + if(zone.hasPlayerInventory(player.getName())) { + zone.restorePlayerInventory(player); + } + player.sendMessage(this.str("Left the zone. Your inventory has (hopefully) been restored.")); + if(this.getWarHub() != null) { + this.getWarHub().resetZoneSign(zone); + } } } @@ -316,7 +320,6 @@ public class War extends JavaPlugin { "Saves the zone blocks if the zone if the outline is correct.")); } else { Warzone warzone = this.findWarzone(arguments[0]); - String message = ""; if(warzone == null) { // create the warzone warzone = new Warzone(this, player.getLocation().getWorld(), arguments[0]); @@ -324,12 +327,12 @@ public class War extends JavaPlugin { WarMapper.save(this); if(arguments[1].equals("northwest") || arguments[1].equals("nw")) { warzone.setNorthwest(player.getLocation()); - player.sendMessage(this.str("Warzone " + warzone.getName() + " added. Northwesternmost point set at x=" - + (int)warzone.getNorthwest().getBlockX() + " z=" + (int)warzone.getNorthwest().getBlockZ() + ".")); + player.sendMessage(this.str("Warzone " + warzone.getName() + " created. Northwesternmost point set to x:" + + (int)warzone.getNorthwest().getBlockX() + " z:" + (int)warzone.getNorthwest().getBlockZ() + ".")); } else { warzone.setSoutheast(player.getLocation()); - player.sendMessage(this.str("Warzone " + warzone.getName() + " added. Southeasternmost point set at x=" - + (int)warzone.getSoutheast().getBlockX() + " z=" + (int)warzone.getSoutheast().getBlockZ() + ".")); + player.sendMessage(this.str("Warzone " + warzone.getName() + " created. Southeasternmost point set to x:" + + (int)warzone.getSoutheast().getBlockX() + " z:" + (int)warzone.getSoutheast().getBlockZ() + ".")); } WarzoneMapper.save(this, warzone, false); } else { @@ -339,51 +342,93 @@ public class War extends JavaPlugin { && (player.getLocation().getBlockX() >= warzone.getSoutheast().getBlockX() || player.getLocation().getBlockZ() <= warzone.getSoutheast().getBlockZ())) { player.sendMessage(this.str("You must place that corner northwest relative to the existing southeast corner!")); - } else { - int reset = warzone.getVolume().resetBlocks(); + } else if (warzone.getSoutheast() == null){ + // just moving the single nw corner we've placed so far warzone.setNorthwest(player.getLocation()); - player.sendMessage(this.str("Saving warzone " + warzone.getName() + ".")); - warzone.saveState(); - warzone.initializeZone(); - message += "Northwesternmost point set at x=" + (int)warzone.getNorthwest().getBlockX() - + " z=" + (int)warzone.getNorthwest().getBlockZ() + " on warzone " + warzone.getName() + ". " + - reset + " blocks reset. Zone saved. "; + }else { + String msgString = ""; + if(warzone.getVolume().isSaved()) { + player.sendMessage(str("Resetting " + warzone.getName() + " blocks.")); + if(warzone.getLobby() != null) { + warzone.getLobby().getVolume().resetBlocks(); + } + int reset = warzone.getVolume().resetBlocks(); + + msgString = reset + " blocks reset. "; + } + warzone.setNorthwest(player.getLocation()); + if(warzone.tooSmall()) { + player.sendMessage(str("Warzone " + warzone.getName() + " is too small. Min north-south size: 20. Min east-west size: 20.")); + } else if (warzone.tooBig()) { + player.sendMessage(str("Warzone " + warzone.getName() + " is too Big. Max north-south size: 500. Max east-west size: 500.")); + } + else { + msgString += "New zone outline ok. Northwesternmost point of zone " + warzone.getName() + " set to x:" + (int)warzone.getNorthwest().getBlockX() + + " z:" + (int)warzone.getNorthwest().getBlockZ()+ ". Saving new warzone blocks..."; + player.sendMessage(str(msgString)); + } } - } else { + } else if(arguments[1].equals("southeast") || arguments[1].equals("se")) { if(warzone.getNorthwest() != null && (player.getLocation().getBlockX() <= warzone.getNorthwest().getBlockX() || player.getLocation().getBlockZ() >= warzone.getNorthwest().getBlockZ())) { player.sendMessage(this.str("You must place that corner southeast relative to the existing northwest corner! ")); - } else { - int reset = warzone.getVolume().resetBlocks(); + } else if (warzone.getNorthwest() == null){ + // just moving the single se corner we've placed so far warzone.setSoutheast(player.getLocation()); - player.sendMessage(this.str("Saving warzone " + warzone.getName() + ".")); - warzone.saveState(); - warzone.initializeZone(); - - message += "Southeasternmost point set at x=" + (int)warzone.getSoutheast().getBlockX() - + " z=" + (int)warzone.getSoutheast().getBlockZ() + " on warzone " + warzone.getName() + ". " + - reset + " blocks reset. Zone saved. "; + } else { + String msgString = ""; + if(warzone.getVolume().isSaved()) { + player.sendMessage(str("Resetting zone " + warzone.getName() + " blocks.")); + if(warzone.getLobby() != null) { + warzone.getLobby().getVolume().resetBlocks(); + } + int reset = warzone.getVolume().resetBlocks(); + + msgString = reset + " blocks reset. "; + } + warzone.setSoutheast(player.getLocation()); + if(warzone.tooSmall()) { + player.sendMessage(str("Warzone " + warzone.getName() + " is too small. Min north-south size: 20. Min east-west size: 20.")); + } else if (warzone.tooBig()) { + player.sendMessage(str("Warzone " + warzone.getName() + " is too Big. Max north-south size: 500. Max east-west size: 500.")); + } + else { + msgString += "New zone outline ok. Southeasternmost point of zone " + warzone.getName() + " set to x:" + (int)warzone.getSoutheast().getBlockX() + + " z:" + (int)warzone.getSoutheast().getBlockZ()+ ". Saving new warzone blocks..."; + player.sendMessage(str(msgString)); + } } } - WarzoneMapper.save(this, warzone, true); } if(warzone.getNorthwest() == null) { - message += "Still missing northwesternmost point. "; + player.sendMessage(str("Still missing northwesternmost point.")); } if(warzone.getSoutheast() == null) { - message += "Still missing southeasternmost point. "; + player.sendMessage(str("Still missing southeasternmost point.")); } if(warzone.getNorthwest() != null && warzone.getSoutheast() != null) { if(warzone.ready()) { - message += "Warzone " + warzone.getName() + " outline done. Use /setteam, /setmonument and /savezone to complete the zone."; - } else if (warzone.tooSmall()) { - message += "Warzone " + warzone.getName() + " is too small. Min north-south size: 20. Min east-west size: 20."; - } else if (warzone.tooBig()) { - message += "Warzone " + warzone.getName() + " is too Big. Max north-south size: 500. Max east-west size: 500."; + warzone.saveState(false); // we just changed the volume, cant reset walls + if(warzone.getLobby() == null) { + // Set default lobby on south side + ZoneLobby lobby = new ZoneLobby(this, warzone, BlockFace.SOUTH); + warzone.setLobby(lobby); + //lobby.initialize(); + if(warHub != null) { // warhub has to change + warHub.getVolume().resetBlocks(); + warHub.initialize(); + } + player.sendMessage(this.str("Default lobby created on south side of zone. Use /setzonelobby to change which zone wall it is attached to.")); + } else { + // gotta move the lobby + warzone.getLobby().changeWall(warzone.getLobby().getWall()); + } + warzone.initializeZone(); + WarzoneMapper.save(this, warzone, true); + player.sendMessage(this.str("Warzone saved. Use /setteam, /setmonument and /savezone to configure the zone.")); } } - player.sendMessage(this.str(message)); } } @@ -456,18 +501,7 @@ public class War extends JavaPlugin { lobby = warzone.getLobby(); } player.sendMessage(this.str("Saving warzone " + warzone.getName() + ".")); - int savedBlocks = warzone.saveState(); - if(warzone.getLobby() == null) { - // Set default lobby on south side - lobby = new ZoneLobby(this, warzone, BlockFace.SOUTH); - warzone.setLobby(lobby); - lobby.initialize(); - if(warHub != null) { // warhub has to change - warHub.getVolume().resetBlocks(); - warHub.initialize(); - } - player.sendMessage(this.str("Default lobby created on south side of zone.")); - } + int savedBlocks = warzone.saveState(true); updateZoneFromNamedParams(warzone, arguments); WarzoneMapper.save(this, warzone, true); warzone.getVolume().resetBlocks(); @@ -1028,7 +1062,7 @@ public class War extends JavaPlugin { } public String getName() { - return name; + return desc.getName(); } public Warzone zoneOfZoneWallAtProximity(Location location) { diff --git a/war/src/main/java/bukkit/tommytony/war/WarEntityListener.java b/war/src/main/java/bukkit/tommytony/war/WarEntityListener.java index 1ad0137..4ea7501 100644 --- a/war/src/main/java/bukkit/tommytony/war/WarEntityListener.java +++ b/war/src/main/java/bukkit/tommytony/war/WarEntityListener.java @@ -122,7 +122,6 @@ public class WarEntityListener extends EntityListener { // } public void onEntityDamageByEntity(EntityDamageByEntityEvent event) { - // BUKKIT !! Entity attacker = event.getDamager(); Entity defender = event.getEntity(); diff --git a/war/src/main/java/bukkit/tommytony/war/WarPlayerListener.java b/war/src/main/java/bukkit/tommytony/war/WarPlayerListener.java index e3f26ec..fefbf9c 100644 --- a/war/src/main/java/bukkit/tommytony/war/WarPlayerListener.java +++ b/war/src/main/java/bukkit/tommytony/war/WarPlayerListener.java @@ -2,7 +2,6 @@ package bukkit.tommytony.war; import java.util.ArrayList; import java.util.List; import java.util.Random; -import java.util.logging.Level; import org.bukkit.Location; import org.bukkit.entity.Player; @@ -33,15 +32,27 @@ public class WarPlayerListener extends PlayerListener { } public void onPlayerJoin(PlayerEvent event) { - event.getPlayer().sendMessage(war.str("War is on! Pick your battle (try /warzones).")); + event.getPlayer().sendMessage(war.str("War is on! Pick your battle (try /warhub, /zones and /zone).")); } public void onPlayerQuit(PlayerEvent event) { Player player = event.getPlayer(); Team team = war.getPlayerTeam(player.getName()); if(team != null) { + Warzone zone = war.getPlayerWarzone(player.getName()); + if(zone != null && zone.hasPlayerInventory(player.getName())) { + player.teleportTo(zone.getTeleport()); + zone.restorePlayerInventory(player); + if(zone.getLobby() != null) { + zone.getLobby().resetTeamGateSign(team); + } + } team.removePlayer(player.getName()); team.resetSign(); + if(war.getWarHub() != null) { + war.getWarHub().resetZoneSign(zone); + } + player.sendMessage(war.str("You have left the warzone. Your inventory has (hopefully) been restored.")); } } @@ -240,10 +251,14 @@ public class WarPlayerListener extends PlayerListener { playerTeam.removePlayer(player.getName()); playerTeam.resetSign(); event.setTo(playerWarzone.getTeleport()); - player.sendMessage(war.str("Left the zone.")); playerWarzone.restorePlayerInventory(player); - player.sendMessage(war.str("Your inventory has (hopefully) been restored.")); - + if(playerWarzone.getLobby() != null) { + playerWarzone.getLobby().resetTeamGateSign(playerTeam); + } + player.sendMessage(war.str("Left the zone. Your inventory has (hopefully) been restored.")); + if(war.getWarHub() != null) { + war.getWarHub().resetZoneSign(zone); + } } } } diff --git a/war/src/main/java/com/tommytony/war/Warzone.java b/war/src/main/java/com/tommytony/war/Warzone.java index bcfbc95..b60221a 100644 --- a/war/src/main/java/com/tommytony/war/Warzone.java +++ b/war/src/main/java/com/tommytony/war/Warzone.java @@ -174,25 +174,29 @@ public class Warzone { return this.teleport; } - public int saveState() { + public int saveState(boolean clearArtifacts) { if(ready()){ - // removed everything to keep save clean - volume.resetWallBlocks(BlockFace.EAST); - volume.resetWallBlocks(BlockFace.WEST); - volume.resetWallBlocks(BlockFace.NORTH); - volume.resetWallBlocks(BlockFace.SOUTH); - - for(Team team : teams) { - team.getVolume().resetBlocks(); + if(clearArtifacts) { + // removed everything to keep save clean + volume.resetWallBlocks(BlockFace.EAST); + volume.resetWallBlocks(BlockFace.WEST); + volume.resetWallBlocks(BlockFace.NORTH); + volume.resetWallBlocks(BlockFace.SOUTH); + + for(Team team : teams) { + team.getVolume().resetBlocks(); + } + + for(Monument monument : monuments) { + monument.getVolume().resetBlocks(); + } + + if(lobby != null) { + lobby.getVolume().resetBlocks(); + } } - for(Monument monument : monuments) { - monument.getVolume().resetBlocks(); - } - if(lobby != null) { - lobby.getVolume().resetBlocks(); - } int saved = volume.saveBlocks(); initializeZone(); // bring back stuff diff --git a/war/src/main/java/com/tommytony/war/ZoneLobby.java b/war/src/main/java/com/tommytony/war/ZoneLobby.java index 50ef6f5..0448cb9 100644 --- a/war/src/main/java/com/tommytony/war/ZoneLobby.java +++ b/war/src/main/java/com/tommytony/war/ZoneLobby.java @@ -52,7 +52,6 @@ public class ZoneLobby { public ZoneLobby(War war, Warzone warzone, BlockFace wall, Volume volume) { this.war = war; this.warzone = warzone; - Volume zoneVolume = warzone.getVolume(); this.wall = wall; this.setVolume(volume); // we're setting the zoneVolume directly, so we need to figure out the lobbyMiddleWallBlock on our own @@ -68,74 +67,72 @@ public class ZoneLobby { } public void changeWall(BlockFace newWall) { - if(this.wall != newWall) { - if(volume == null) { - // no previous wall - this.volume = new Volume("lobby", war, warzone.getWorld()); - } else { - // move the lobby - this.volume.resetBlocks(); - } - - this.wall = newWall; - // find center of the wall and set the new volume corners - VerticalVolume zoneVolume = warzone.getVolume(); - - Block corner1 = null; - Block corner2 = null; - - if(wall == BlockFace.NORTH) { - int wallStart = zoneVolume.getMinZ(); - int wallEnd = zoneVolume.getMaxZ(); - int x = zoneVolume.getMinX(); - int wallLength = wallEnd - wallStart + 1; - int wallCenterPos = wallStart + wallLength / 2; - int highestNonAirBlockAtCenter = warzone.getWorld().getHighestBlockYAt(x, wallCenterPos); - lobbyMiddleWallBlock = warzone.getWorld().getBlockAt(x, highestNonAirBlockAtCenter+1, wallCenterPos); - corner1 = warzone.getWorld().getBlockAt(x, highestNonAirBlockAtCenter, wallCenterPos + lobbyHalfSide); - corner2 = warzone.getWorld().getBlockAt(x - lobbyDepth, - highestNonAirBlockAtCenter + 1 + lobbyHeight, wallCenterPos - lobbyHalfSide); - } else if (wall == BlockFace.EAST){ - int wallStart = zoneVolume.getMinX(); - int wallEnd = zoneVolume.getMaxX(); - int z = zoneVolume.getMinZ(); - int wallLength = wallEnd - wallStart + 1; - int wallCenterPos = wallStart + wallLength / 2; - int highestNonAirBlockAtCenter = warzone.getWorld().getHighestBlockYAt(wallCenterPos, z); - lobbyMiddleWallBlock = warzone.getWorld().getBlockAt(wallCenterPos, highestNonAirBlockAtCenter + 1, z); - corner1 = warzone.getWorld().getBlockAt(wallCenterPos - lobbyHalfSide, highestNonAirBlockAtCenter, z); - corner2 = warzone.getWorld().getBlockAt(wallCenterPos + lobbyHalfSide, - highestNonAirBlockAtCenter + 1 + lobbyHeight, z - lobbyDepth); - } else if (wall == BlockFace.SOUTH){ - int wallStart = zoneVolume.getMinZ(); - int wallEnd = zoneVolume.getMaxZ(); - int x = zoneVolume.getMaxX(); - int wallLength = wallEnd - wallStart + 1; - int wallCenterPos = wallStart + wallLength / 2; - int highestNonAirBlockAtCenter = warzone.getWorld().getHighestBlockYAt(x, wallCenterPos); - lobbyMiddleWallBlock = warzone.getWorld().getBlockAt(x, highestNonAirBlockAtCenter + 1, wallCenterPos); - corner1 = warzone.getWorld().getBlockAt(x, highestNonAirBlockAtCenter, wallCenterPos - lobbyHalfSide); - corner2 = warzone.getWorld().getBlockAt(x + lobbyDepth, - highestNonAirBlockAtCenter + 1 + lobbyHeight, wallCenterPos + lobbyHalfSide); - } else if (wall == BlockFace.WEST){ - int wallStart = zoneVolume.getMinX(); - int wallEnd = zoneVolume.getMaxX(); - int z = zoneVolume.getMaxZ(); - int wallLength = wallEnd - wallStart + 1; - int wallCenterPos = wallStart + wallLength / 2; - int highestNonAirBlockAtCenter = warzone.getWorld().getHighestBlockYAt(wallCenterPos, z); - lobbyMiddleWallBlock = warzone.getWorld().getBlockAt(wallCenterPos, highestNonAirBlockAtCenter + 1, z); - corner1 = warzone.getWorld().getBlockAt(wallCenterPos + lobbyHalfSide, highestNonAirBlockAtCenter, z); - corner2 = warzone.getWorld().getBlockAt(wallCenterPos - lobbyHalfSide, highestNonAirBlockAtCenter + 1 + lobbyHeight, z + lobbyDepth); - } - - if(corner1 != null && corner2 != null) { - // save the blocks, wide enough for three team gates, 3+1 high and 10 deep, extruding out from the zone wall. - this.volume.setCornerOne(corner1); - this.volume.setCornerTwo(corner2); - this.volume.saveBlocks(); - VolumeMapper.save(volume, warzone.getName(), war); - } + if(volume == null) { + // no previous wall + this.volume = new Volume("lobby", war, warzone.getWorld()); + } else { + // move the lobby + // this.volume.resetBlocks(); // should be done previously thru getVolume + } + + this.wall = newWall; + // find center of the wall and set the new volume corners + VerticalVolume zoneVolume = warzone.getVolume(); + + Block corner1 = null; + Block corner2 = null; + + if(wall == BlockFace.NORTH) { + int wallStart = zoneVolume.getMinZ(); + int wallEnd = zoneVolume.getMaxZ(); + int x = zoneVolume.getMinX(); + int wallLength = wallEnd - wallStart + 1; + int wallCenterPos = wallStart + wallLength / 2; + int highestNonAirBlockAtCenter = warzone.getWorld().getHighestBlockYAt(x, wallCenterPos); + lobbyMiddleWallBlock = warzone.getWorld().getBlockAt(x, highestNonAirBlockAtCenter+1, wallCenterPos); + corner1 = warzone.getWorld().getBlockAt(x, highestNonAirBlockAtCenter, wallCenterPos + lobbyHalfSide); + corner2 = warzone.getWorld().getBlockAt(x - lobbyDepth, + highestNonAirBlockAtCenter + 1 + lobbyHeight, wallCenterPos - lobbyHalfSide); + } else if (wall == BlockFace.EAST){ + int wallStart = zoneVolume.getMinX(); + int wallEnd = zoneVolume.getMaxX(); + int z = zoneVolume.getMinZ(); + int wallLength = wallEnd - wallStart + 1; + int wallCenterPos = wallStart + wallLength / 2; + int highestNonAirBlockAtCenter = warzone.getWorld().getHighestBlockYAt(wallCenterPos, z); + lobbyMiddleWallBlock = warzone.getWorld().getBlockAt(wallCenterPos, highestNonAirBlockAtCenter + 1, z); + corner1 = warzone.getWorld().getBlockAt(wallCenterPos - lobbyHalfSide, highestNonAirBlockAtCenter, z); + corner2 = warzone.getWorld().getBlockAt(wallCenterPos + lobbyHalfSide, + highestNonAirBlockAtCenter + 1 + lobbyHeight, z - lobbyDepth); + } else if (wall == BlockFace.SOUTH){ + int wallStart = zoneVolume.getMinZ(); + int wallEnd = zoneVolume.getMaxZ(); + int x = zoneVolume.getMaxX(); + int wallLength = wallEnd - wallStart + 1; + int wallCenterPos = wallStart + wallLength / 2; + int highestNonAirBlockAtCenter = warzone.getWorld().getHighestBlockYAt(x, wallCenterPos); + lobbyMiddleWallBlock = warzone.getWorld().getBlockAt(x, highestNonAirBlockAtCenter + 1, wallCenterPos); + corner1 = warzone.getWorld().getBlockAt(x, highestNonAirBlockAtCenter, wallCenterPos - lobbyHalfSide); + corner2 = warzone.getWorld().getBlockAt(x + lobbyDepth, + highestNonAirBlockAtCenter + 1 + lobbyHeight, wallCenterPos + lobbyHalfSide); + } else if (wall == BlockFace.WEST){ + int wallStart = zoneVolume.getMinX(); + int wallEnd = zoneVolume.getMaxX(); + int z = zoneVolume.getMaxZ(); + int wallLength = wallEnd - wallStart + 1; + int wallCenterPos = wallStart + wallLength / 2; + int highestNonAirBlockAtCenter = warzone.getWorld().getHighestBlockYAt(wallCenterPos, z); + lobbyMiddleWallBlock = warzone.getWorld().getBlockAt(wallCenterPos, highestNonAirBlockAtCenter + 1, z); + corner1 = warzone.getWorld().getBlockAt(wallCenterPos + lobbyHalfSide, highestNonAirBlockAtCenter, z); + corner2 = warzone.getWorld().getBlockAt(wallCenterPos - lobbyHalfSide, highestNonAirBlockAtCenter + 1 + lobbyHeight, z + lobbyDepth); + } + + if(corner1 != null && corner2 != null) { + // save the blocks, wide enough for three team gates, 3+1 high and 10 deep, extruding out from the zone wall. + this.volume.setCornerOne(corner1); + this.volume.setCornerTwo(corner2); + this.volume.saveBlocks(); + VolumeMapper.save(volume, warzone.getName(), war); } } @@ -515,10 +512,6 @@ public class ZoneLobby { } else if(team.getMaterial() == TeamMaterials.TEAMGOLD) { resetTeamGateSign(team, goldGate); } -// -// if(war.getWarHub() != null) { -// war.getWarHub().resetZoneSign(warzone); -// } } private void resetTeamGateSign(Team team, Block gate) { diff --git a/war/src/main/java/com/tommytony/war/mappers/WarMapper.java b/war/src/main/java/com/tommytony/war/mappers/WarMapper.java index 011f43b..2829f54 100644 --- a/war/src/main/java/com/tommytony/war/mappers/WarMapper.java +++ b/war/src/main/java/com/tommytony/war/mappers/WarMapper.java @@ -50,7 +50,7 @@ public class WarMapper { String warzonesStr = warConfig.getString("warzones"); String[] warzoneSplit = warzonesStr.split(","); war.getWarzones().clear(); - if(warzoneSplit.length > 1) war.info("Restoring saved warzones..."); + if(warzonesStr.length() > 1) war.info("Restoring warzones..."); for(String warzoneName : warzoneSplit) { if(warzoneName != null && !warzoneName.equals("")){ Warzone zone = WarzoneMapper.load(war, warzoneName, !newWar); // cascade load, only load blocks if warzone exists diff --git a/war/src/main/java/plugin.yml b/war/src/main/java/plugin.yml index 6729f77..0d383ee 100644 --- a/war/src/main/java/plugin.yml +++ b/war/src/main/java/plugin.yml @@ -1,10 +1,12 @@ name: War +version: 0.4 (Montgomery) +description: Lets you create team deathmatch arenas (warzones) for a more structured PVP experience. +author: tommytony +website: war.tommytony.com main: bukkit.tommytony.war.War -version: 0.3 commands: - -#-Player commands- - warzones: +# Player commands + warzones: description: Lists the warzones on the server. Each warzone is an independent TDM arena. usage: /warzones zones: @@ -31,16 +33,12 @@ commands: team: description: Team chat. usage: /team Leeeroooy!!! - - -#-Warzone maker commands- - -#|-Battle-related commands- +# Warzone maker commands +# 1- Battle-related commands nextbattle: description: War makers only. Zone blocks are restored (from memory). Teams are respawned. Just as if a team's life pool had been exhausted. usage: /nextbattle - -#|-Warzone creation commands- +# 2- Warzone creation commands setzone: description: Zone makers only. Use to create and adjust the warzone outline. A zone area is defined by its Northwest and Southeast corners, up to the sky and down to adminium. When the second corner is set down correctly, the zone blocks are saved. usage: /setzone , e.g. first, /setzone ziggy se, then, /setzone ziggy northwest @@ -74,28 +72,23 @@ commands: zonemaker: description: Zone makers only. Toggles between player mode and zone maker mode. Or gives/removes access to zonemaker commands for another player. usage: /zonemaker, /zonemaker - -#|-War hub-- +# 3- War hub setwarhub: description: War makers only. Create or moves a West-facing wall of portals. One portal per warzone. Warzones get a portal back to the warhub. usage: /setwarhub deletewarhub: description: War makers only. Deletes the warhub if it exists. Resets all warzone lobbies. usage: /deletewarhub - -#|-Defaults-- +# 4- Defaults setwarconfig: description: War makers only. Change the default warzone configuration values. usage: /setwarconfig pvpinzonesonly:on lifepool:8 teamsize:5 maxscore:7 autoassign:on outline:off ff:on - - -#-Fallback- +# Fallback war: description: Prompts you to use /warhub, /zones and /zone. Can also be used as a prefix for all commands as a fallback if they are taken. usage: /war, /war setzone ziggy northwest, /war warhub, /war zone ziggy, etc. War: description: Same as /war. Used as fallback. - usage: See /war. - + usage: See /war. #Note: When you /disable War with General, all warzone blocks will be reset and artifacts will disappear. # When you /enable War, all blocks will be loaded from disk and the War-related artifacts will reappear. \ No newline at end of file diff --git a/war/target/classes/plugin.yml b/war/target/classes/plugin.yml index 6729f77..0d383ee 100644 --- a/war/target/classes/plugin.yml +++ b/war/target/classes/plugin.yml @@ -1,10 +1,12 @@ name: War +version: 0.4 (Montgomery) +description: Lets you create team deathmatch arenas (warzones) for a more structured PVP experience. +author: tommytony +website: war.tommytony.com main: bukkit.tommytony.war.War -version: 0.3 commands: - -#-Player commands- - warzones: +# Player commands + warzones: description: Lists the warzones on the server. Each warzone is an independent TDM arena. usage: /warzones zones: @@ -31,16 +33,12 @@ commands: team: description: Team chat. usage: /team Leeeroooy!!! - - -#-Warzone maker commands- - -#|-Battle-related commands- +# Warzone maker commands +# 1- Battle-related commands nextbattle: description: War makers only. Zone blocks are restored (from memory). Teams are respawned. Just as if a team's life pool had been exhausted. usage: /nextbattle - -#|-Warzone creation commands- +# 2- Warzone creation commands setzone: description: Zone makers only. Use to create and adjust the warzone outline. A zone area is defined by its Northwest and Southeast corners, up to the sky and down to adminium. When the second corner is set down correctly, the zone blocks are saved. usage: /setzone , e.g. first, /setzone ziggy se, then, /setzone ziggy northwest @@ -74,28 +72,23 @@ commands: zonemaker: description: Zone makers only. Toggles between player mode and zone maker mode. Or gives/removes access to zonemaker commands for another player. usage: /zonemaker, /zonemaker - -#|-War hub-- +# 3- War hub setwarhub: description: War makers only. Create or moves a West-facing wall of portals. One portal per warzone. Warzones get a portal back to the warhub. usage: /setwarhub deletewarhub: description: War makers only. Deletes the warhub if it exists. Resets all warzone lobbies. usage: /deletewarhub - -#|-Defaults-- +# 4- Defaults setwarconfig: description: War makers only. Change the default warzone configuration values. usage: /setwarconfig pvpinzonesonly:on lifepool:8 teamsize:5 maxscore:7 autoassign:on outline:off ff:on - - -#-Fallback- +# Fallback war: description: Prompts you to use /warhub, /zones and /zone. Can also be used as a prefix for all commands as a fallback if they are taken. usage: /war, /war setzone ziggy northwest, /war warhub, /war zone ziggy, etc. War: description: Same as /war. Used as fallback. - usage: See /war. - + usage: See /war. #Note: When you /disable War with General, all warzone blocks will be reset and artifacts will disappear. # When you /enable War, all blocks will be loaded from disk and the War-related artifacts will reappear. \ No newline at end of file