Just missing death tp, better lobby height management and a non buggy way to let normal players thru the gate and the wall guard.

This commit is contained in:
taoneill 2011-01-15 02:03:04 -05:00
parent 5cd2d90173
commit 1e6d8d1e1d
6 changed files with 151 additions and 36 deletions

View File

@ -11,6 +11,7 @@ import org.bukkit.plugin.java.JavaPlugin;
import com.tommytony.war.Team;
import com.tommytony.war.WarHub;
import com.tommytony.war.Warzone;
import com.tommytony.war.ZoneLobby;
import com.tommytony.war.mappers.WarMapper;
import java.io.File;
@ -76,10 +77,7 @@ public class War extends JavaPlugin {
this.defaultLoadout.put(0, new ItemStack(Material.STONE_SWORD));
this.defaultLoadout.put(1, new ItemStack(Material.BOW));
this.defaultLoadout.put(2, new ItemStack(Material.ARROW, 7));
this.defaultLoadout.put(3, new ItemStack(Material.STONE_PICKAXE));
this.defaultLoadout.put(4, new ItemStack(Material.STONE_SPADE));
this.defaultLoadout.put(5, new ItemStack(Material.STONE_AXE));
this.defaultLoadout.put(6, new ItemStack(Material.BREAD, 2));
this.defaultLoadout.put(3, new ItemStack(Material.IRON_PICKAXE));
this.defaultLifepool = 7;
this.defaultFriendlyFire = false;
this.defaultAutoAssignOnly = false;
@ -210,7 +208,6 @@ public class War extends JavaPlugin {
}
public WarHub getWarHub() {
// TODO Auto-generated method stub
return warHub;
}
@ -218,5 +215,31 @@ public class War extends JavaPlugin {
this.warHub = warHub;
}
public ZoneLobby lobby(Location location) {
for(Warzone warzone : warzones) {
if(warzone.getLobby() != null
&& warzone.getLobby().getVolume() != null
&& warzone.getLobby().getVolume().contains(location))
return warzone.getLobby();
}
return null;
}
public boolean inAnyWarzoneLobby(Location location) {
if(lobby(location) == null) {
return false;
}
return true;
}
public boolean inWarzoneLobby(String warzoneName, Location location) {
ZoneLobby currentLobby = lobby(location);
if(currentLobby == null) {
return false;
} else if (warzoneName.equals(currentLobby.getZone().getName())){
return true;
}
return false;
}
}

View File

@ -316,16 +316,24 @@ public class WarPlayerListener extends PlayerListener {
}
else if(command.equals("setzonelobby")) {
if(!war.inAnyWarzone(player.getLocation()) || arguments.length < 2 || arguments.length > 2
|| (arguments.length == 2 && (!arguments[0].equals("north") && !arguments[0].equals("n")
if((!war.inAnyWarzone(player.getLocation())
&& !war.inAnyWarzoneLobby(player.getLocation()))
|| arguments.length < 1 || arguments.length > 1
|| (arguments.length == 1 && !arguments[0].equals("north") && !arguments[0].equals("n")
&& !arguments[0].equals("east") && !arguments[0].equals("e")
&& !arguments[0].equals("south") && !arguments[0].equals("s")
&& !arguments[0].equals("west") && !arguments[0].equals("w")))) {
&& !arguments[0].equals("west") && !arguments[0].equals("w"))) {
player.sendMessage(war.str("Usage: /setzonelobby <north/n/east/e/south/s/west/w>. Must be in warzone." +
"Defines on which side the zone lobby lies. " +
"Removes any previously set lobby."));
} else {
Warzone warzone = war.warzone(player.getLocation());
ZoneLobby lobby = war.lobby(player.getLocation());
if(warzone == null && lobby != null) {
warzone = lobby.getZone();
} else {
lobby = warzone.getLobby();
}
BlockFace wall = null;
String wallStr = "";
if(arguments[0].equals("north") || arguments[0].equals("n")) {
@ -340,8 +348,7 @@ public class WarPlayerListener extends PlayerListener {
} else if(arguments[0].equals("west") || arguments[0].equals("w")) {
wall = BlockFace.West;
wallStr = "west";
}
ZoneLobby lobby = warzone.getLobby();
}
if(lobby != null) {
// reset existing lobby
lobby.getVolume().resetBlocks();
@ -361,7 +368,7 @@ public class WarPlayerListener extends PlayerListener {
// /savewarzone
else if(command.equals("savezone") || command.equals("savewarzone")) {
if(!war.inAnyWarzone(player.getLocation())) {
if(!war.inAnyWarzone(player.getLocation()) && !war.inAnyWarzoneLobby(player.getLocation())) {
player.sendMessage(war.str("Usage: /savezone. Must be in warzone. " +
"Changes the warzone state loaded at the beginning of every battle. " +
"Also sets the teleport point for this warzone where you're standing." +
@ -371,10 +378,16 @@ public class WarPlayerListener extends PlayerListener {
"or /resetzone before changing start state). "));
} else {
Warzone warzone = war.warzone(player.getLocation());
ZoneLobby lobby = war.lobby(player.getLocation());
if(warzone == null && lobby != null) {
warzone = lobby.getZone();
} else {
lobby = warzone.getLobby();
}
int savedBlocks = warzone.saveState();
if(warzone.getLobby() == null) {
// Set default lobby on south side
ZoneLobby lobby = new ZoneLobby(war, warzone, BlockFace.South);
lobby = new ZoneLobby(war, warzone, BlockFace.South);
warzone.setLobby(lobby);
lobby.initialize();
player.sendMessage(war.str("Default lobby created on south side of zone."));
@ -388,10 +401,16 @@ public class WarPlayerListener extends PlayerListener {
// /resetwarzone
else if(command.equals("resetzone") || command.equals("resetwarzone")) {
if(!war.inAnyWarzone(player.getLocation())) {
if(!war.inAnyWarzone(player.getLocation()) && !war.inAnyWarzoneLobby(player.getLocation())) {
player.sendMessage(war.str("Usage: /resetzone pool=10. Reloads the zone. All named parameter are optional. Defaults: pool=7 maxScore=-1 (infinite). Must be in warzone."));
} else {
Warzone warzone = war.warzone(player.getLocation());
ZoneLobby lobby = war.lobby(player.getLocation());
if(warzone == null && lobby != null) {
warzone = lobby.getZone();
} else {
lobby = warzone.getLobby();
}
int resetBlocks = warzone.getVolume().resetBlocks();
warzone.initializeZone();
for(Team team: warzone.getTeams()) {

View File

@ -616,6 +616,10 @@ public class Warzone {
if(guard.getPlayer().getName().equals(player.getName())){
playerGuards.add(guard);
int reset = volume.resetWallBlocks(guard.getWall()); // this should restore old blocks
if(lobby != null) {
lobby.getVolume().resetBlocks();
lobby.initialize();
}
if(drawZoneOutline) {
addZoneOutline(guard.getWall());
}

View File

@ -5,12 +5,12 @@ import org.bukkit.BlockFace;
import org.bukkit.Location;
import org.bukkit.Material;
import bukkit.tommytony.war.War;
import com.tommytony.war.mappers.VolumeMapper;
import com.tommytony.war.volumes.VerticalVolume;
import com.tommytony.war.volumes.Volume;
import bukkit.tommytony.war.War;
/**
*
* @author tommytony
@ -60,7 +60,7 @@ public class ZoneLobby {
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+1, wallCenterPos + lobbyHalfSide);
corner1 = warzone.getWorld().getBlockAt(x, highestNonAirBlockAtCenter, wallCenterPos + lobbyHalfSide);
corner2 = warzone.getWorld().getBlockAt(x - lobbyDepth, highestNonAirBlockAtCenter + 1 + lobbyHeight, wallCenterPos - lobbyHalfSide);
setGatePositions(lobbyMiddleWallBlock);
} else if (wall == BlockFace.East){
@ -71,7 +71,7 @@ public class ZoneLobby {
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+1, z);
corner1 = warzone.getWorld().getBlockAt(wallCenterPos - lobbyHalfSide, highestNonAirBlockAtCenter, z);
corner2 = warzone.getWorld().getBlockAt(wallCenterPos + lobbyHalfSide, highestNonAirBlockAtCenter + 1 + lobbyHeight, z - lobbyDepth);
setGatePositions(lobbyMiddleWallBlock);
} else if (wall == BlockFace.South){
@ -82,7 +82,7 @@ public class ZoneLobby {
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+1, wallCenterPos - lobbyHalfSide);
corner1 = warzone.getWorld().getBlockAt(x, highestNonAirBlockAtCenter, wallCenterPos - lobbyHalfSide);
corner2 = warzone.getWorld().getBlockAt(x + lobbyDepth, highestNonAirBlockAtCenter + 1 + lobbyHeight, wallCenterPos + lobbyHalfSide);
setGatePositions(lobbyMiddleWallBlock);
} else if (wall == BlockFace.West){
@ -93,7 +93,7 @@ public class ZoneLobby {
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+1, z);
corner1 = warzone.getWorld().getBlockAt(wallCenterPos + lobbyHalfSide, highestNonAirBlockAtCenter, z);
corner2 = warzone.getWorld().getBlockAt(wallCenterPos - lobbyHalfSide, highestNonAirBlockAtCenter + 1 + lobbyHeight, z + lobbyDepth);
setGatePositions(lobbyMiddleWallBlock);
}
@ -107,7 +107,7 @@ public class ZoneLobby {
// flatten the area (set all but floor to air, then replace any floor air blocks with glass)
this.volume.setToMaterial(Material.AIR);
this.volume.setFaceMaterial(BlockFace.Down, Material.AIR); // beautiful
this.volume.setFaceMaterial(BlockFace.Down, Material.GLASS); // beautiful
// add war hub link gate
if(war.getWarHub() != null) {
@ -324,4 +324,70 @@ public class ZoneLobby {
}
return false;
}
public boolean blockIsAGateBlock(Block block, BlockFace blockWall) {
if(blockWall == wall) {
return isPartOfGate(diamondGate, block)
|| isPartOfGate(ironGate, block)
|| isPartOfGate(goldGate, block);
}
return false;
}
private boolean isPartOfGate(Block gateBlock, Block block) {
BlockFace leftSide = null; // look at the zone
BlockFace rightSide = null;
if(wall == BlockFace.North) {
leftSide = BlockFace.East;
rightSide = BlockFace.West;
} else if(wall == BlockFace.East) {
leftSide = BlockFace.South;
rightSide = BlockFace.North;
} else if(wall == BlockFace.South) {
leftSide = BlockFace.West;
rightSide = BlockFace.East;
} else if(wall == BlockFace.West) {
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());
}
public Warzone getZone() {
return this.warzone;
}
}

View File

@ -76,21 +76,23 @@ public class ZoneWallGuard {
private void toGlass(Block block, BlockFace wall) {
// face here means which wall we are working on
if(wall == BlockFace.North) {
if(warzone.getVolume().isNorthWallBlock(block)) {
block.setType(Material.GLASS);
}
} else if (wall == BlockFace.South) {
if(warzone.getVolume().isSouthWallBlock(block)) {
block.setType(Material.GLASS);
}
} else if (wall == BlockFace.East) {
if(warzone.getVolume().isEastWallBlock(block)) {
block.setType(Material.GLASS);
}
} else if (wall == BlockFace.West) {
if(warzone.getVolume().isWestWallBlock(block)) {
block.setType(Material.GLASS);
if(warzone.getLobby() == null || (warzone.getLobby() != null && !warzone.getLobby().blockIsAGateBlock(block, wall))){
if(wall == BlockFace.North) {
if(warzone.getVolume().isNorthWallBlock(block)) {
block.setType(Material.GLASS);
}
} else if (wall == BlockFace.South) {
if(warzone.getVolume().isSouthWallBlock(block)) {
block.setType(Material.GLASS);
}
} else if (wall == BlockFace.East) {
if(warzone.getVolume().isEastWallBlock(block)) {
block.setType(Material.GLASS);
}
} else if (wall == BlockFace.West) {
if(warzone.getVolume().isWestWallBlock(block)) {
block.setType(Material.GLASS);
}
}
}
}

View File

@ -163,7 +163,8 @@ public class WarzoneMapper {
} else if(lobbyStr.equals("west")) {
lobbyFace = BlockFace.West;
}
warzone.setLobby(new ZoneLobby(war, warzone, lobbyFace));
ZoneLobby lobby = new ZoneLobby(war, warzone, lobbyFace);
warzone.setLobby(lobby);
}
warzoneConfig.close();