From 2692f7ec8ebb932b23663a11f672afdf99e23eae Mon Sep 17 00:00:00 2001 From: taoneill Date: Sun, 16 Jan 2011 19:23:43 -0500 Subject: [PATCH] Warhub works. For one zone at least. --- .../main/java/bukkit/tommytony/war/War.java | 19 +++++++++++-------- .../tommytony/war/WarPlayerListener.java | 4 +--- .../main/java/com/tommytony/war/WarHub.java | 5 +++-- .../com/tommytony/war/mappers/WarMapper.java | 1 + 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/war/src/main/java/bukkit/tommytony/war/War.java b/war/src/main/java/bukkit/tommytony/war/War.java index 19ba935..b8fcfd9 100644 --- a/war/src/main/java/bukkit/tommytony/war/War.java +++ b/war/src/main/java/bukkit/tommytony/war/War.java @@ -87,7 +87,7 @@ public class War extends JavaPlugin { this.defaultLifepool = 7; this.defaultFriendlyFire = false; this.defaultAutoAssignOnly = false; - getLogger().info("Loading War files..."); + getLogger().info("Loading War secrets..."); WarMapper.load(this, this.getServer().getWorlds()[0]); getLogger().info("War v" + version + " is on."); } @@ -285,15 +285,18 @@ public class War extends JavaPlugin { // /setwarhub else if(command.equals("setwarhub")) { - WarHub hub = this.getWarHub(); - if(hub != null) { + if(warHub != null) { // reset existing hub - hub.getVolume().resetBlocks(); - hub.setLocation(player.getLocation()); - hub.initialize(); + warHub.getVolume().resetBlocks(); + warHub.setLocation(player.getLocation()); + warHub.initialize(); } else { - hub = new WarHub(this, player.getLocation()); - hub.initialize(); + warHub = new WarHub(this, player.getLocation()); + warHub.initialize(); + for(Warzone zone : warzones) { + zone.getLobby().getVolume().resetBlocks(); + zone.getLobby().initialize(); + } } WarMapper.save(this); } diff --git a/war/src/main/java/bukkit/tommytony/war/WarPlayerListener.java b/war/src/main/java/bukkit/tommytony/war/WarPlayerListener.java index d2bfb93..c4ee2dd 100644 --- a/war/src/main/java/bukkit/tommytony/war/WarPlayerListener.java +++ b/war/src/main/java/bukkit/tommytony/war/WarPlayerListener.java @@ -165,8 +165,7 @@ public class WarPlayerListener extends PlayerListener { } } else if (zone.getLobby().isInWarHubLinkGate(to)){ dropFromOldTeamIfAny(player); - event.setTo(to); - player.teleportTo(war.getWarHub().getLocation()); + event.setTo(war.getWarHub().getLocation()); } } else if(war.inAnyWarzone(event.getFrom())) { // already in a team and in warzone, leaving if(zone.getLobby().isAutoAssignGate(to) @@ -191,7 +190,6 @@ public class WarPlayerListener extends PlayerListener { if(hub != null) { Warzone zone = hub.getDestinationWarzoneForLocation(player.getLocation()); synchronized(player) { - if(zone != null) { event.setTo(zone.getTeleport()); //player.teleportTo(zone.getTeleport()); diff --git a/war/src/main/java/com/tommytony/war/WarHub.java b/war/src/main/java/com/tommytony/war/WarHub.java index c3b7129..673cbf7 100644 --- a/war/src/main/java/com/tommytony/war/WarHub.java +++ b/war/src/main/java/com/tommytony/war/WarHub.java @@ -71,8 +71,9 @@ public class WarHub { // draw gates Block currentGateBlock = locationBlock.getFace(BlockFace.SOUTH, halfHubWidth - 2).getFace(BlockFace.WEST, hubDepth); - for(Warzone zone : war.getWarzones()) { // gonna use the index to find it again - zoneGateBlocks.add(currentGateBlock); + + for(int i = 0;i < war.getWarzones().size(); i++) { // gonna use the index to find it again + zoneGateBlocks.add(0, currentGateBlock); currentGateBlock.setType(Material.PORTAL); currentGateBlock.getFace(BlockFace.UP).setType(Material.PORTAL); currentGateBlock.getFace(BlockFace.SOUTH).setType(Material.OBSIDIAN); 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 3073729..5e924c5 100644 --- a/war/src/main/java/com/tommytony/war/mappers/WarMapper.java +++ b/war/src/main/java/com/tommytony/war/mappers/WarMapper.java @@ -161,6 +161,7 @@ public class WarMapper { WarHub hub = war.getWarHub(); if(hub != null) { hubStr = hub.getLocation().getBlockX() + "," + hub.getLocation().getBlockY() + "," + hub.getLocation().getBlockZ(); + VolumeMapper.save(hub.getVolume(), "", war); } warConfig.setString("warhub", hubStr);