From 6fa2d91130f5b04bf14d64efee41069896430fe7 Mon Sep 17 00:00:00 2001 From: TimWolla Date: Mon, 23 May 2011 17:47:18 +0200 Subject: [PATCH 1/3] Thieves can also be attacked in spawn --- .../java/bukkit/tommytony/war/WarEntityListener.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/war/src/main/java/bukkit/tommytony/war/WarEntityListener.java b/war/src/main/java/bukkit/tommytony/war/WarEntityListener.java index 92f6b26..2a5f2db 100644 --- a/war/src/main/java/bukkit/tommytony/war/WarEntityListener.java +++ b/war/src/main/java/bukkit/tommytony/war/WarEntityListener.java @@ -70,12 +70,16 @@ public class WarEntityListener extends EntityListener { && attackerWarzone == defenderWarzone) { // Make sure one of the players isn't in the spawn if(defenderTeam.getSpawnVolume().contains(d.getLocation())) { // attacking person in spawn - war.badMsg(a, "Can't attack a player that's inside his team's spawn."); - event.setCancelled(true); + if(!defenderWarzone.isFlagThief(d.getName())) { // thiefs can always be attacked + war.badMsg(a, "Can't attack a player that's inside his team's spawn."); + event.setCancelled(true); + } } else if(attackerTeam.getSpawnVolume().contains(a.getLocation()) && !attackerTeam.getSpawnVolume().contains(d.getLocation())) { // only let a player inside spawn attack an enemy player if that player enters the spawn - war.badMsg(a, "Can't attack a player from inside your spawn."); - event.setCancelled(true); + if(!attackerWarzone.isFlagThief(a.getName())) { // thiefs can always attack + war.badMsg(a, "Can't attack a player from inside your spawn."); + event.setCancelled(true); + } } // Detect death, prevent it and respawn the player From 55b5ecfdbf4c14bac882c511247b78f545e57c53 Mon Sep 17 00:00:00 2001 From: TimWolla Date: Mon, 23 May 2011 18:22:33 +0200 Subject: [PATCH 2/3] Closes https://github.com/taoneill/war/issues/44, warzones can be deleted by name now --- .../main/java/bukkit/tommytony/war/War.java | 29 ++++++++++++++----- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/war/src/main/java/bukkit/tommytony/war/War.java b/war/src/main/java/bukkit/tommytony/war/War.java index 7001d80..4cf9340 100644 --- a/war/src/main/java/bukkit/tommytony/war/War.java +++ b/war/src/main/java/bukkit/tommytony/war/War.java @@ -232,7 +232,7 @@ public class War extends JavaPlugin { } else if(command.equals("resetzone")) { performResetZone(player, arguments); } else if(command.equals("deletezone")) { - performDeleteZone(player); + performDeleteZone(player, arguments); } else if(command.equals("setteam")) { performSetTeam(player, arguments); } else if(command.equals("setteamflag")) { @@ -564,14 +564,29 @@ public class War extends JavaPlugin { } } - public void performDeleteZone(Player player) { - if(!this.inAnyWarzone(player.getLocation()) && !this.inAnyWarzoneLobby(player.getLocation())) { - this.badMsg(player, "Usage: /deletezone. " + + public void performDeleteZone(Player player, String[] arguments) { + if(arguments.length == 0 && !this.inAnyWarzone(player.getLocation()) && !this.inAnyWarzoneLobby(player.getLocation())) { + this.badMsg(player, "Usage: /deletezone [warzone-name]. " + "Deletes the warzone. " + - "Must be in the warzone (try /zones and /zone). "); + "Must be in the warzone or name must be provided (try /zones and /zone). "); } else { - Warzone warzone = this.warzone(player.getLocation()); - ZoneLobby lobby = this.lobby(player.getLocation()); + ZoneLobby lobby = null; + Warzone warzone = null; + if(arguments.length == 1) { // get zone by name + for(Warzone tmp : this.getWarzones()) { + if(tmp.getName().toLowerCase().startsWith(arguments[0].toLowerCase())) { + warzone = tmp; + break; + } + } + if (warzone == null) { + this.badMsg(player, "No such warzone."); + return; + } + } else { // get zone by position + warzone = this.warzone(player.getLocation()); + lobby = this.lobby(player.getLocation()); + } if(warzone == null && lobby != null) { warzone = lobby.getZone(); } else { From aaef9f9915261ca7b1726f94b43d2ab39e7b9e23 Mon Sep 17 00:00:00 2001 From: TimWolla Date: Mon, 23 May 2011 18:41:28 +0200 Subject: [PATCH 3/3] Implemented invisible spawn-style Closes https://github.com/taoneill/war/issues/153 --- .../main/java/bukkit/tommytony/war/War.java | 2 + war/src/main/java/com/tommytony/war/Team.java | 46 ++++++++++++++----- .../com/tommytony/war/mappers/WarMapper.java | 2 + .../tommytony/war/mappers/WarzoneMapper.java | 2 + 4 files changed, 40 insertions(+), 12 deletions(-) diff --git a/war/src/main/java/bukkit/tommytony/war/War.java b/war/src/main/java/bukkit/tommytony/war/War.java index 4cf9340..8d8ceae 100644 --- a/war/src/main/java/bukkit/tommytony/war/War.java +++ b/war/src/main/java/bukkit/tommytony/war/War.java @@ -1068,6 +1068,8 @@ public class War extends JavaPlugin { warzone.setSpawnStyle(spawnStyle); } else if (spawnStyle.equals(TeamSpawnStyles.FLAT)){ warzone.setSpawnStyle(spawnStyle); + } else if (spawnStyle.equals(TeamSpawnStyles.INVISIBLE)){ + warzone.setSpawnStyle(spawnStyle); } else { warzone.setSpawnStyle(TeamSpawnStyles.BIG); } diff --git a/war/src/main/java/com/tommytony/war/Team.java b/war/src/main/java/com/tommytony/war/Team.java index 923f489..a127af8 100644 --- a/war/src/main/java/com/tommytony/war/Team.java +++ b/war/src/main/java/com/tommytony/war/Team.java @@ -51,7 +51,11 @@ public class Team { int x = teamSpawn.getBlockX(); int y = teamSpawn.getBlockY(); int z = teamSpawn.getBlockZ(); - if(warzone.getSpawnStyle().equals(TeamSpawnStyles.SMALL)) { + + if(warzone.getSpawnStyle().equals(TeamSpawnStyles.INVISIBLE)) { + this.spawnVolume.setCornerOne(warzone.getWorld().getBlockAt(x, y-1, z)); + this.spawnVolume.setCornerTwo(warzone.getWorld().getBlockAt(x, y+3, z)); + } else if(warzone.getSpawnStyle().equals(TeamSpawnStyles.SMALL)) { this.spawnVolume.setCornerOne(warzone.getWorld().getBlockAt(x-1, y-1, z-1)); this.spawnVolume.setCornerTwo(warzone.getWorld().getBlockAt(x+1, y+3, z+1)); } else { @@ -71,16 +75,22 @@ public class Team { int y = teamSpawn.getBlockY(); int z = teamSpawn.getBlockZ(); - // first ring - setBlock(x+1, y-1, z+1, kind); - setBlock(x+1, y-1, z, kind); - setBlock(x+1, y-1, z-1, kind); - setBlock(x, y-1, z+1, kind); - warzone.getWorld().getBlockAt(x, y-1, z).setType(Material.GLOWSTONE); - setBlock(x, y-1, z-1, kind); - setBlock(x-1, y-1, z+1, kind); - setBlock(x-1, y-1, z, kind); - setBlock(x-1, y-1, z-1, kind); + + if(warzone.getSpawnStyle().equals(TeamSpawnStyles.INVISIBLE)) { + // nothing but glowstone + warzone.getWorld().getBlockAt(x, y-1, z).setType(Material.GLOWSTONE); + } else { + // first ring + setBlock(x+1, y-1, z+1, kind); + setBlock(x+1, y-1, z, kind); + setBlock(x+1, y-1, z-1, kind); + setBlock(x, y-1, z+1, kind); + warzone.getWorld().getBlockAt(x, y-1, z).setType(Material.GLOWSTONE); + setBlock(x, y-1, z-1, kind); + setBlock(x-1, y-1, z+1, kind); + setBlock(x-1, y-1, z, kind); + setBlock(x-1, y-1, z-1, kind); + } // Orientation int yaw = 0; @@ -92,7 +102,19 @@ public class Team { Block signBlock = null; int signData = 0; - if(warzone.getSpawnStyle().equals(TeamSpawnStyles.SMALL)){ + if(warzone.getSpawnStyle().equals(TeamSpawnStyles.INVISIBLE)){ + // INVISIBLE style + signBlock = warzone.getWorld().getBlockAt(x, y, z); + if(yaw >= 0 && yaw < 90) { + signData = 10; + }else if(yaw >= 90 && yaw <= 180) { + signData = 14; + } else if(yaw >= 180 && yaw < 270) { + signData = 2; + } else if(yaw >= 270 && yaw <= 360) { + signData = 6; + } + } else if(warzone.getSpawnStyle().equals(TeamSpawnStyles.SMALL)){ // SMALL style if(yaw >= 0 && yaw < 90) { signData = 10; 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 8b72ff9..573fd42 100644 --- a/war/src/main/java/com/tommytony/war/mappers/WarMapper.java +++ b/war/src/main/java/com/tommytony/war/mappers/WarMapper.java @@ -114,6 +114,8 @@ public class WarMapper { war.setDefaultSpawnStyle(spawnStyle); } else if (spawnStyle.equals(TeamSpawnStyles.FLAT)){ war.setDefaultSpawnStyle(spawnStyle); + } else if (spawnStyle.equals(TeamSpawnStyles.INVISIBLE)){ + war.setDefaultSpawnStyle(spawnStyle); } // default is already initialized to BIG (see Warzone) } diff --git a/war/src/main/java/com/tommytony/war/mappers/WarzoneMapper.java b/war/src/main/java/com/tommytony/war/mappers/WarzoneMapper.java index b9c8f8f..8b666d5 100644 --- a/war/src/main/java/com/tommytony/war/mappers/WarzoneMapper.java +++ b/war/src/main/java/com/tommytony/war/mappers/WarzoneMapper.java @@ -173,6 +173,8 @@ public class WarzoneMapper { warzone.setSpawnStyle(spawnStyle); } else if (spawnStyle.equals(TeamSpawnStyles.FLAT)){ warzone.setSpawnStyle(spawnStyle); + } else if (spawnStyle.equals(TeamSpawnStyles.INVISIBLE)){ + warzone.setSpawnStyle(spawnStyle); } // default is already initialized to BIG (see Warzone) }