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.

This commit is contained in:
taoneill 2011-01-21 00:54:04 -05:00
parent 88d8632931
commit 5d5f2ada5e
8 changed files with 228 additions and 197 deletions

View File

@ -42,6 +42,7 @@ public class War extends JavaPlugin {
PluginDescriptionFile desc, File folder, File plugin, ClassLoader cLoader) { PluginDescriptionFile desc, File folder, File plugin, ClassLoader cLoader) {
super(pluginLoader, instance, desc, folder, plugin, cLoader); super(pluginLoader, instance, desc, folder, plugin, cLoader);
// TODO: switch to bukkit config file // 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 WarEntityListener entityListener = new WarEntityListener(this);
private WarBlockListener blockListener = new WarBlockListener(this); private WarBlockListener blockListener = new WarBlockListener(this);
private Logger log; private Logger log;
String name = "War"; private PluginDescriptionFile desc = null;
String version = "0.3";
String versionCodeName = "Patton";
private final List<Warzone> warzones = new ArrayList<Warzone>(); private final List<Warzone> warzones = new ArrayList<Warzone>();
private final List<String> zoneMakerNames = new ArrayList<String>(); private final List<String> zoneMakerNames = new ArrayList<String>();
@ -76,17 +75,18 @@ public class War extends JavaPlugin {
if(warHub != null) { if(warHub != null) {
warHub.getVolume().resetBlocks(); 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() { public void onEnable() {
this.log = Logger.getLogger("Minecraft"); this.log = Logger.getLogger("Minecraft");
// Register hooks // Register hooks
PluginManager pm = getServer().getPluginManager(); PluginManager pm = getServer().getPluginManager();
pm.registerEvent(Event.Type.PLAYER_LOGIN, playerListener, Priority.Normal, this); pm.registerEvent(Event.Type.PLAYER_LOGIN, playerListener, Priority.Monitor, this);
pm.registerEvent(Event.Type.PLAYER_QUIT, playerListener, Priority.Normal, 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.PLAYER_MOVE, playerListener, Priority.High, this);
pm.registerEvent(Event.Type.ENTITY_DAMAGEDBY_ENTITY, entityListener, Priority.Normal, 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.defaultLifepool = 7;
this.defaultFriendlyFire = false; this.defaultFriendlyFire = false;
this.defaultAutoAssignOnly = false; this.defaultAutoAssignOnly = false;
WarMapper.load(this, this.getServer().getWorlds()[0]); WarMapper.load(this, this.getServer().getWorlds()[0]);
this.info("War v"+ version + " (" + versionCodeName + ") is on."); this.info("War v"+ desc.getVersion() + " is on.");
} }
public boolean onCommand(Player player, Command cmd, String commandLabel, String[] args) { public boolean onCommand(Player player, Command cmd, String commandLabel, String[] args) {
@ -113,18 +113,15 @@ public class War extends JavaPlugin {
// Handle both /war <command> and /<war command>. I.e. "/war zone temple" == "/zone temple" // Handle both /war <command> and /<war command>. I.e. "/war zone temple" == "/zone temple"
if((command.equals("war") || command.equals("War")) && args.length > 1) { if((command.equals("war") || command.equals("War")) && args.length > 1) {
command = args[1]; command = args[1];
arguments = new String[args.length - 2]; arguments = new String[args.length - 1];
for(int i = 2; i <= arguments.length; i++) { 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")) { } else if (command.equals("war") || command.equals("War")) {
player.sendMessage(this.str("War is on. Please pick your battle. " + player.sendMessage(this.str("War is on. Please pick your battle. " +
"Use /warhub, /zones and /zone.")); "Use /warhub, /zones and /zone."));
} else { } else {
arguments = new String[args.length - 1]; arguments = args;
for(int i = 1; i <= arguments.length; i++) {
arguments[i-1] = args[i];
}
} }
// Player commands: /warzones, /warzone, /teams, /join, /leave // Player commands: /warzones, /warzone, /teams, /join, /leave
@ -245,10 +242,17 @@ public class War extends JavaPlugin {
playerTeam.resetSign(); playerTeam.resetSign();
Warzone zone = this.warzone(player.getLocation()); Warzone zone = this.warzone(player.getLocation());
if(zone.getLobby() != null) {
zone.getLobby().resetTeamGateSign(playerTeam);
}
player.teleportTo(zone.getTeleport()); player.teleportTo(zone.getTeleport());
player.sendMessage(this.str("Left the zone.")); if(zone.hasPlayerInventory(player.getName())) {
zone.restorePlayerInventory(player); zone.restorePlayerInventory(player);
player.sendMessage(this.str("Your inventory has (hopefully) been restored.")); }
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.")); "Saves the zone blocks if the zone if the outline is correct."));
} else { } else {
Warzone warzone = this.findWarzone(arguments[0]); Warzone warzone = this.findWarzone(arguments[0]);
String message = "";
if(warzone == null) { if(warzone == null) {
// create the warzone // create the warzone
warzone = new Warzone(this, player.getLocation().getWorld(), arguments[0]); warzone = new Warzone(this, player.getLocation().getWorld(), arguments[0]);
@ -324,12 +327,12 @@ public class War extends JavaPlugin {
WarMapper.save(this); WarMapper.save(this);
if(arguments[1].equals("northwest") || arguments[1].equals("nw")) { if(arguments[1].equals("northwest") || arguments[1].equals("nw")) {
warzone.setNorthwest(player.getLocation()); warzone.setNorthwest(player.getLocation());
player.sendMessage(this.str("Warzone " + warzone.getName() + " added. Northwesternmost point set at x=" player.sendMessage(this.str("Warzone " + warzone.getName() + " created. Northwesternmost point set to x:"
+ (int)warzone.getNorthwest().getBlockX() + " z=" + (int)warzone.getNorthwest().getBlockZ() + ".")); + (int)warzone.getNorthwest().getBlockX() + " z:" + (int)warzone.getNorthwest().getBlockZ() + "."));
} else { } else {
warzone.setSoutheast(player.getLocation()); warzone.setSoutheast(player.getLocation());
player.sendMessage(this.str("Warzone " + warzone.getName() + " added. Southeasternmost point set at x=" player.sendMessage(this.str("Warzone " + warzone.getName() + " created. Southeasternmost point set to x:"
+ (int)warzone.getSoutheast().getBlockX() + " z=" + (int)warzone.getSoutheast().getBlockZ() + ".")); + (int)warzone.getSoutheast().getBlockX() + " z:" + (int)warzone.getSoutheast().getBlockZ() + "."));
} }
WarzoneMapper.save(this, warzone, false); WarzoneMapper.save(this, warzone, false);
} else { } else {
@ -339,51 +342,93 @@ public class War extends JavaPlugin {
&& (player.getLocation().getBlockX() >= warzone.getSoutheast().getBlockX() && (player.getLocation().getBlockX() >= warzone.getSoutheast().getBlockX()
|| player.getLocation().getBlockZ() <= warzone.getSoutheast().getBlockZ())) { || player.getLocation().getBlockZ() <= warzone.getSoutheast().getBlockZ())) {
player.sendMessage(this.str("You must place that corner northwest relative to the existing southeast corner!")); player.sendMessage(this.str("You must place that corner northwest relative to the existing southeast corner!"));
} else { } else if (warzone.getSoutheast() == null){
int reset = warzone.getVolume().resetBlocks(); // just moving the single nw corner we've placed so far
warzone.setNorthwest(player.getLocation()); warzone.setNorthwest(player.getLocation());
player.sendMessage(this.str("Saving warzone " + warzone.getName() + ".")); }else {
warzone.saveState(); String msgString = "";
warzone.initializeZone(); if(warzone.getVolume().isSaved()) {
message += "Northwesternmost point set at x=" + (int)warzone.getNorthwest().getBlockX() player.sendMessage(str("Resetting " + warzone.getName() + " blocks."));
+ " z=" + (int)warzone.getNorthwest().getBlockZ() + " on warzone " + warzone.getName() + ". " + if(warzone.getLobby() != null) {
reset + " blocks reset. Zone saved. "; 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 if(warzone.getNorthwest() != null
&& (player.getLocation().getBlockX() <= warzone.getNorthwest().getBlockX() && (player.getLocation().getBlockX() <= warzone.getNorthwest().getBlockX()
|| player.getLocation().getBlockZ() >= warzone.getNorthwest().getBlockZ())) { || player.getLocation().getBlockZ() >= warzone.getNorthwest().getBlockZ())) {
player.sendMessage(this.str("You must place that corner southeast relative to the existing northwest corner! ")); player.sendMessage(this.str("You must place that corner southeast relative to the existing northwest corner! "));
} else { } else if (warzone.getNorthwest() == null){
int reset = warzone.getVolume().resetBlocks(); // just moving the single se corner we've placed so far
warzone.setSoutheast(player.getLocation()); warzone.setSoutheast(player.getLocation());
player.sendMessage(this.str("Saving warzone " + warzone.getName() + ".")); } else {
warzone.saveState(); String msgString = "";
warzone.initializeZone(); if(warzone.getVolume().isSaved()) {
player.sendMessage(str("Resetting zone " + warzone.getName() + " blocks."));
message += "Southeasternmost point set at x=" + (int)warzone.getSoutheast().getBlockX() if(warzone.getLobby() != null) {
+ " z=" + (int)warzone.getSoutheast().getBlockZ() + " on warzone " + warzone.getName() + ". " + warzone.getLobby().getVolume().resetBlocks();
reset + " blocks reset. Zone saved. "; }
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) { if(warzone.getNorthwest() == null) {
message += "Still missing northwesternmost point. "; player.sendMessage(str("Still missing northwesternmost point."));
} }
if(warzone.getSoutheast() == null) { 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.getNorthwest() != null && warzone.getSoutheast() != null) {
if(warzone.ready()) { if(warzone.ready()) {
message += "Warzone " + warzone.getName() + " outline done. Use /setteam, /setmonument and /savezone to complete the zone."; warzone.saveState(false); // we just changed the volume, cant reset walls
} else if (warzone.tooSmall()) { if(warzone.getLobby() == null) {
message += "Warzone " + warzone.getName() + " is too small. Min north-south size: 20. Min east-west size: 20."; // Set default lobby on south side
} else if (warzone.tooBig()) { ZoneLobby lobby = new ZoneLobby(this, warzone, BlockFace.SOUTH);
message += "Warzone " + warzone.getName() + " is too Big. Max north-south size: 500. Max east-west size: 500."; 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 <n/s/e/w> 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(); lobby = warzone.getLobby();
} }
player.sendMessage(this.str("Saving warzone " + warzone.getName() + ".")); player.sendMessage(this.str("Saving warzone " + warzone.getName() + "."));
int savedBlocks = warzone.saveState(); int savedBlocks = warzone.saveState(true);
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."));
}
updateZoneFromNamedParams(warzone, arguments); updateZoneFromNamedParams(warzone, arguments);
WarzoneMapper.save(this, warzone, true); WarzoneMapper.save(this, warzone, true);
warzone.getVolume().resetBlocks(); warzone.getVolume().resetBlocks();
@ -1028,7 +1062,7 @@ public class War extends JavaPlugin {
} }
public String getName() { public String getName() {
return name; return desc.getName();
} }
public Warzone zoneOfZoneWallAtProximity(Location location) { public Warzone zoneOfZoneWallAtProximity(Location location) {

View File

@ -122,7 +122,6 @@ public class WarEntityListener extends EntityListener {
// } // }
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) { public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
// BUKKIT !!
Entity attacker = event.getDamager(); Entity attacker = event.getDamager();
Entity defender = event.getEntity(); Entity defender = event.getEntity();

View File

@ -2,7 +2,6 @@ package bukkit.tommytony.war;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;
import java.util.logging.Level;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -33,15 +32,27 @@ public class WarPlayerListener extends PlayerListener {
} }
public void onPlayerJoin(PlayerEvent event) { 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) { public void onPlayerQuit(PlayerEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
Team team = war.getPlayerTeam(player.getName()); Team team = war.getPlayerTeam(player.getName());
if(team != null) { 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.removePlayer(player.getName());
team.resetSign(); 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.removePlayer(player.getName());
playerTeam.resetSign(); playerTeam.resetSign();
event.setTo(playerWarzone.getTeleport()); event.setTo(playerWarzone.getTeleport());
player.sendMessage(war.str("Left the zone."));
playerWarzone.restorePlayerInventory(player); 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);
}
} }
} }
} }

View File

@ -174,25 +174,29 @@ public class Warzone {
return this.teleport; return this.teleport;
} }
public int saveState() { public int saveState(boolean clearArtifacts) {
if(ready()){ if(ready()){
// removed everything to keep save clean if(clearArtifacts) {
volume.resetWallBlocks(BlockFace.EAST); // removed everything to keep save clean
volume.resetWallBlocks(BlockFace.WEST); volume.resetWallBlocks(BlockFace.EAST);
volume.resetWallBlocks(BlockFace.NORTH); volume.resetWallBlocks(BlockFace.WEST);
volume.resetWallBlocks(BlockFace.SOUTH); volume.resetWallBlocks(BlockFace.NORTH);
volume.resetWallBlocks(BlockFace.SOUTH);
for(Team team : teams) {
team.getVolume().resetBlocks(); 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(); int saved = volume.saveBlocks();
initializeZone(); // bring back stuff initializeZone(); // bring back stuff

View File

@ -52,7 +52,6 @@ public class ZoneLobby {
public ZoneLobby(War war, Warzone warzone, BlockFace wall, Volume volume) { public ZoneLobby(War war, Warzone warzone, BlockFace wall, Volume volume) {
this.war = war; this.war = war;
this.warzone = warzone; this.warzone = warzone;
Volume zoneVolume = warzone.getVolume();
this.wall = wall; this.wall = wall;
this.setVolume(volume); this.setVolume(volume);
// we're setting the zoneVolume directly, so we need to figure out the lobbyMiddleWallBlock on our own // 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) { public void changeWall(BlockFace newWall) {
if(this.wall != newWall) { if(volume == null) {
if(volume == null) { // no previous wall
// no previous wall this.volume = new Volume("lobby", war, warzone.getWorld());
this.volume = new Volume("lobby", war, warzone.getWorld()); } else {
} else { // move the lobby
// move the lobby // this.volume.resetBlocks(); // should be done previously thru getVolume
this.volume.resetBlocks(); }
}
this.wall = newWall;
this.wall = newWall; // find center of the wall and set the new volume corners
// find center of the wall and set the new volume corners VerticalVolume zoneVolume = warzone.getVolume();
VerticalVolume zoneVolume = warzone.getVolume();
Block corner1 = null;
Block corner1 = null; Block corner2 = null;
Block corner2 = null;
if(wall == BlockFace.NORTH) {
if(wall == BlockFace.NORTH) { int wallStart = zoneVolume.getMinZ();
int wallStart = zoneVolume.getMinZ(); int wallEnd = zoneVolume.getMaxZ();
int wallEnd = zoneVolume.getMaxZ(); int x = zoneVolume.getMinX();
int x = zoneVolume.getMinX(); int wallLength = wallEnd - wallStart + 1;
int wallLength = wallEnd - wallStart + 1; int wallCenterPos = wallStart + wallLength / 2;
int wallCenterPos = wallStart + wallLength / 2; int highestNonAirBlockAtCenter = warzone.getWorld().getHighestBlockYAt(x, wallCenterPos);
int highestNonAirBlockAtCenter = warzone.getWorld().getHighestBlockYAt(x, wallCenterPos); lobbyMiddleWallBlock = warzone.getWorld().getBlockAt(x, highestNonAirBlockAtCenter+1, wallCenterPos);
lobbyMiddleWallBlock = warzone.getWorld().getBlockAt(x, highestNonAirBlockAtCenter+1, wallCenterPos); corner1 = warzone.getWorld().getBlockAt(x, highestNonAirBlockAtCenter, wallCenterPos + lobbyHalfSide);
corner1 = warzone.getWorld().getBlockAt(x, highestNonAirBlockAtCenter, wallCenterPos + lobbyHalfSide); corner2 = warzone.getWorld().getBlockAt(x - lobbyDepth,
corner2 = warzone.getWorld().getBlockAt(x - lobbyDepth, highestNonAirBlockAtCenter + 1 + lobbyHeight, wallCenterPos - lobbyHalfSide);
highestNonAirBlockAtCenter + 1 + lobbyHeight, wallCenterPos - lobbyHalfSide); } else if (wall == BlockFace.EAST){
} else if (wall == BlockFace.EAST){ int wallStart = zoneVolume.getMinX();
int wallStart = zoneVolume.getMinX(); int wallEnd = zoneVolume.getMaxX();
int wallEnd = zoneVolume.getMaxX(); int z = zoneVolume.getMinZ();
int z = zoneVolume.getMinZ(); int wallLength = wallEnd - wallStart + 1;
int wallLength = wallEnd - wallStart + 1; int wallCenterPos = wallStart + wallLength / 2;
int wallCenterPos = wallStart + wallLength / 2; int highestNonAirBlockAtCenter = warzone.getWorld().getHighestBlockYAt(wallCenterPos, z);
int highestNonAirBlockAtCenter = warzone.getWorld().getHighestBlockYAt(wallCenterPos, z); lobbyMiddleWallBlock = warzone.getWorld().getBlockAt(wallCenterPos, highestNonAirBlockAtCenter + 1, z);
lobbyMiddleWallBlock = warzone.getWorld().getBlockAt(wallCenterPos, highestNonAirBlockAtCenter + 1, z); corner1 = warzone.getWorld().getBlockAt(wallCenterPos - lobbyHalfSide, highestNonAirBlockAtCenter, z);
corner1 = warzone.getWorld().getBlockAt(wallCenterPos - lobbyHalfSide, highestNonAirBlockAtCenter, z); corner2 = warzone.getWorld().getBlockAt(wallCenterPos + lobbyHalfSide,
corner2 = warzone.getWorld().getBlockAt(wallCenterPos + lobbyHalfSide, highestNonAirBlockAtCenter + 1 + lobbyHeight, z - lobbyDepth);
highestNonAirBlockAtCenter + 1 + lobbyHeight, z - lobbyDepth); } else if (wall == BlockFace.SOUTH){
} else if (wall == BlockFace.SOUTH){ int wallStart = zoneVolume.getMinZ();
int wallStart = zoneVolume.getMinZ(); int wallEnd = zoneVolume.getMaxZ();
int wallEnd = zoneVolume.getMaxZ(); int x = zoneVolume.getMaxX();
int x = zoneVolume.getMaxX(); int wallLength = wallEnd - wallStart + 1;
int wallLength = wallEnd - wallStart + 1; int wallCenterPos = wallStart + wallLength / 2;
int wallCenterPos = wallStart + wallLength / 2; int highestNonAirBlockAtCenter = warzone.getWorld().getHighestBlockYAt(x, wallCenterPos);
int highestNonAirBlockAtCenter = warzone.getWorld().getHighestBlockYAt(x, wallCenterPos); lobbyMiddleWallBlock = warzone.getWorld().getBlockAt(x, highestNonAirBlockAtCenter + 1, wallCenterPos);
lobbyMiddleWallBlock = warzone.getWorld().getBlockAt(x, highestNonAirBlockAtCenter + 1, wallCenterPos); corner1 = warzone.getWorld().getBlockAt(x, highestNonAirBlockAtCenter, wallCenterPos - lobbyHalfSide);
corner1 = warzone.getWorld().getBlockAt(x, highestNonAirBlockAtCenter, wallCenterPos - lobbyHalfSide); corner2 = warzone.getWorld().getBlockAt(x + lobbyDepth,
corner2 = warzone.getWorld().getBlockAt(x + lobbyDepth, highestNonAirBlockAtCenter + 1 + lobbyHeight, wallCenterPos + lobbyHalfSide);
highestNonAirBlockAtCenter + 1 + lobbyHeight, wallCenterPos + lobbyHalfSide); } else if (wall == BlockFace.WEST){
} else if (wall == BlockFace.WEST){ int wallStart = zoneVolume.getMinX();
int wallStart = zoneVolume.getMinX(); int wallEnd = zoneVolume.getMaxX();
int wallEnd = zoneVolume.getMaxX(); int z = zoneVolume.getMaxZ();
int z = zoneVolume.getMaxZ(); int wallLength = wallEnd - wallStart + 1;
int wallLength = wallEnd - wallStart + 1; int wallCenterPos = wallStart + wallLength / 2;
int wallCenterPos = wallStart + wallLength / 2; int highestNonAirBlockAtCenter = warzone.getWorld().getHighestBlockYAt(wallCenterPos, z);
int highestNonAirBlockAtCenter = warzone.getWorld().getHighestBlockYAt(wallCenterPos, z); lobbyMiddleWallBlock = warzone.getWorld().getBlockAt(wallCenterPos, highestNonAirBlockAtCenter + 1, z);
lobbyMiddleWallBlock = warzone.getWorld().getBlockAt(wallCenterPos, highestNonAirBlockAtCenter + 1, z); corner1 = warzone.getWorld().getBlockAt(wallCenterPos + lobbyHalfSide, highestNonAirBlockAtCenter, z);
corner1 = warzone.getWorld().getBlockAt(wallCenterPos + lobbyHalfSide, highestNonAirBlockAtCenter, z); corner2 = warzone.getWorld().getBlockAt(wallCenterPos - lobbyHalfSide, highestNonAirBlockAtCenter + 1 + lobbyHeight, z + lobbyDepth);
corner2 = warzone.getWorld().getBlockAt(wallCenterPos - lobbyHalfSide, highestNonAirBlockAtCenter + 1 + lobbyHeight, z + lobbyDepth); }
}
if(corner1 != null && corner2 != null) {
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.
// 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.setCornerOne(corner1); this.volume.setCornerTwo(corner2);
this.volume.setCornerTwo(corner2); this.volume.saveBlocks();
this.volume.saveBlocks(); VolumeMapper.save(volume, warzone.getName(), war);
VolumeMapper.save(volume, warzone.getName(), war);
}
} }
} }
@ -515,10 +512,6 @@ public class ZoneLobby {
} else if(team.getMaterial() == TeamMaterials.TEAMGOLD) { } else if(team.getMaterial() == TeamMaterials.TEAMGOLD) {
resetTeamGateSign(team, goldGate); resetTeamGateSign(team, goldGate);
} }
//
// if(war.getWarHub() != null) {
// war.getWarHub().resetZoneSign(warzone);
// }
} }
private void resetTeamGateSign(Team team, Block gate) { private void resetTeamGateSign(Team team, Block gate) {

View File

@ -50,7 +50,7 @@ public class WarMapper {
String warzonesStr = warConfig.getString("warzones"); String warzonesStr = warConfig.getString("warzones");
String[] warzoneSplit = warzonesStr.split(","); String[] warzoneSplit = warzonesStr.split(",");
war.getWarzones().clear(); war.getWarzones().clear();
if(warzoneSplit.length > 1) war.info("Restoring saved warzones..."); if(warzonesStr.length() > 1) war.info("Restoring warzones...");
for(String warzoneName : warzoneSplit) { for(String warzoneName : warzoneSplit) {
if(warzoneName != null && !warzoneName.equals("")){ if(warzoneName != null && !warzoneName.equals("")){
Warzone zone = WarzoneMapper.load(war, warzoneName, !newWar); // cascade load, only load blocks if warzone exists Warzone zone = WarzoneMapper.load(war, warzoneName, !newWar); // cascade load, only load blocks if warzone exists

View File

@ -1,10 +1,12 @@
name: War 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 main: bukkit.tommytony.war.War
version: 0.3
commands: commands:
# Player commands
#-Player commands- warzones:
warzones:
description: Lists the warzones on the server. Each warzone is an independent TDM arena. description: Lists the warzones on the server. Each warzone is an independent TDM arena.
usage: /warzones usage: /warzones
zones: zones:
@ -31,16 +33,12 @@ commands:
team: team:
description: Team chat. description: Team chat.
usage: /team Leeeroooy!!! usage: /team Leeeroooy!!!
# Warzone maker commands
# 1- Battle-related commands
#-Warzone maker commands-
#|-Battle-related commands-
nextbattle: 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. 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 usage: /nextbattle
# 2- Warzone creation commands
#|-Warzone creation commands-
setzone: 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. 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 <northwest/southeast/nw/se>, e.g. first, /setzone ziggy se, then, /setzone ziggy northwest usage: /setzone <northwest/southeast/nw/se>, e.g. first, /setzone ziggy se, then, /setzone ziggy northwest
@ -74,28 +72,23 @@ commands:
zonemaker: zonemaker:
description: Zone makers only. Toggles between player mode and zone maker mode. Or gives/removes access to zonemaker commands for another player. 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 <new-or-kicked-maker-name> usage: /zonemaker, /zonemaker <new-or-kicked-maker-name>
# 3- War hub
#|-War hub--
setwarhub: 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. 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 usage: /setwarhub
deletewarhub: deletewarhub:
description: War makers only. Deletes the warhub if it exists. Resets all warzone lobbies. description: War makers only. Deletes the warhub if it exists. Resets all warzone lobbies.
usage: /deletewarhub usage: /deletewarhub
# 4- Defaults
#|-Defaults--
setwarconfig: setwarconfig:
description: War makers only. Change the default warzone configuration values. 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 usage: /setwarconfig pvpinzonesonly:on lifepool:8 teamsize:5 maxscore:7 autoassign:on outline:off ff:on
# Fallback
#-Fallback-
war: 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. 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. usage: /war, /war setzone ziggy northwest, /war warhub, /war zone ziggy, etc.
War: War:
description: Same as /war. Used as fallback. 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. #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. # When you /enable War, all blocks will be loaded from disk and the War-related artifacts will reappear.

View File

@ -1,10 +1,12 @@
name: War 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 main: bukkit.tommytony.war.War
version: 0.3
commands: commands:
# Player commands
#-Player commands- warzones:
warzones:
description: Lists the warzones on the server. Each warzone is an independent TDM arena. description: Lists the warzones on the server. Each warzone is an independent TDM arena.
usage: /warzones usage: /warzones
zones: zones:
@ -31,16 +33,12 @@ commands:
team: team:
description: Team chat. description: Team chat.
usage: /team Leeeroooy!!! usage: /team Leeeroooy!!!
# Warzone maker commands
# 1- Battle-related commands
#-Warzone maker commands-
#|-Battle-related commands-
nextbattle: 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. 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 usage: /nextbattle
# 2- Warzone creation commands
#|-Warzone creation commands-
setzone: 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. 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 <northwest/southeast/nw/se>, e.g. first, /setzone ziggy se, then, /setzone ziggy northwest usage: /setzone <northwest/southeast/nw/se>, e.g. first, /setzone ziggy se, then, /setzone ziggy northwest
@ -74,28 +72,23 @@ commands:
zonemaker: zonemaker:
description: Zone makers only. Toggles between player mode and zone maker mode. Or gives/removes access to zonemaker commands for another player. 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 <new-or-kicked-maker-name> usage: /zonemaker, /zonemaker <new-or-kicked-maker-name>
# 3- War hub
#|-War hub--
setwarhub: 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. 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 usage: /setwarhub
deletewarhub: deletewarhub:
description: War makers only. Deletes the warhub if it exists. Resets all warzone lobbies. description: War makers only. Deletes the warhub if it exists. Resets all warzone lobbies.
usage: /deletewarhub usage: /deletewarhub
# 4- Defaults
#|-Defaults--
setwarconfig: setwarconfig:
description: War makers only. Change the default warzone configuration values. 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 usage: /setwarconfig pvpinzonesonly:on lifepool:8 teamsize:5 maxscore:7 autoassign:on outline:off ff:on
# Fallback
#-Fallback-
war: 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. 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. usage: /war, /war setzone ziggy northwest, /war warhub, /war zone ziggy, etc.
War: War:
description: Same as /war. Used as fallback. 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. #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. # When you /enable War, all blocks will be loaded from disk and the War-related artifacts will reappear.