mirror of
https://github.com/taoneill/war.git
synced 2025-02-13 09:51:19 +01:00
Closes gh-69. Damn this was a bitch to fix. /setzone code is much clearer and less crazy now.
This commit is contained in:
parent
31e4f3cb38
commit
fc1621f4c6
@ -774,6 +774,10 @@ 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 msgString = "";
|
||||||
|
Location oldSoutheast = null;
|
||||||
|
Location oldNorthwest = null;
|
||||||
|
boolean fail = false;
|
||||||
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]);
|
||||||
@ -800,7 +804,6 @@ public class War extends JavaPlugin {
|
|||||||
// just moving the single nw corner we've placed so far
|
// just moving the single nw corner we've placed so far
|
||||||
warzone.setNorthwest(player.getLocation());
|
warzone.setNorthwest(player.getLocation());
|
||||||
}else {
|
}else {
|
||||||
String msgString = "";
|
|
||||||
if(warzone.getVolume().isSaved()) {
|
if(warzone.getVolume().isSaved()) {
|
||||||
msg(player, "Resetting " + warzone.getName() + " blocks.");
|
msg(player, "Resetting " + warzone.getName() + " blocks.");
|
||||||
if(warzone.getLobby() != null) {
|
if(warzone.getLobby() != null) {
|
||||||
@ -809,35 +812,22 @@ public class War extends JavaPlugin {
|
|||||||
int reset = warzone.getVolume().resetBlocks();
|
int reset = warzone.getVolume().resetBlocks();
|
||||||
|
|
||||||
msgString = reset + " blocks reset. ";
|
msgString = reset + " blocks reset. ";
|
||||||
} else {
|
oldNorthwest = warzone.getNorthwest();
|
||||||
this.addWarzone(warzone);
|
}
|
||||||
this.incompleteZones.remove(warzone);
|
|
||||||
WarMapper.save(this);
|
|
||||||
}
|
|
||||||
warzone.setNorthwest(player.getLocation());
|
warzone.setNorthwest(player.getLocation());
|
||||||
if(warzone.tooSmall()) {
|
|
||||||
badMsg(player, "Warzone " + warzone.getName() + " is too small. Min north-south size: 20. Min east-west size: 20.");
|
|
||||||
} else if (warzone.tooBig()) {
|
|
||||||
badMsg(player, "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...";
|
|
||||||
msg(player, msgString);
|
|
||||||
WarzoneMapper.save(this, warzone, false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else if(arguments[1].equals("southeast") || arguments[1].equals("se")) {
|
} 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())) {
|
||||||
this.badMsg(player, "You must place that corner southeast relative to the existing northwest corner! ");
|
this.badMsg(player, "You must place that corner southeast relative to the existing northwest corner! ");
|
||||||
|
fail = true;
|
||||||
} else if (warzone.getNorthwest() == null){
|
} else if (warzone.getNorthwest() == null){
|
||||||
// just moving the single se corner we've placed so far
|
// just moving the single se corner we've placed so far
|
||||||
warzone.setSoutheast(player.getLocation());
|
warzone.setSoutheast(player.getLocation());
|
||||||
} else {
|
} else {
|
||||||
String msgString = "";
|
|
||||||
if(warzone.getVolume().isSaved()) {
|
if(warzone.getVolume().isSaved()) {
|
||||||
|
// we're resizing a zone
|
||||||
msg(player, "Resetting zone " + warzone.getName() + " blocks.");
|
msg(player, "Resetting zone " + warzone.getName() + " blocks.");
|
||||||
if(warzone.getLobby() != null) {
|
if(warzone.getLobby() != null) {
|
||||||
warzone.getLobby().getVolume().resetBlocks();
|
warzone.getLobby().getVolume().resetBlocks();
|
||||||
@ -845,54 +835,62 @@ public class War extends JavaPlugin {
|
|||||||
int reset = warzone.getVolume().resetBlocks();
|
int reset = warzone.getVolume().resetBlocks();
|
||||||
|
|
||||||
msgString = reset + " blocks reset. ";
|
msgString = reset + " blocks reset. ";
|
||||||
} else {
|
oldSoutheast = warzone.getSoutheast();
|
||||||
this.addWarzone(warzone);
|
|
||||||
this.incompleteZones.remove(warzone);
|
|
||||||
WarMapper.save(this);
|
|
||||||
}
|
}
|
||||||
warzone.setSoutheast(player.getLocation());
|
warzone.setSoutheast(player.getLocation());
|
||||||
if(warzone.tooSmall()) {
|
|
||||||
badMsg(player, "Warzone " + warzone.getName() + " is too small. Min north-south size: 20. Min east-west size: 20.");
|
|
||||||
} else if (warzone.tooBig()) {
|
|
||||||
badMsg(player, "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...";
|
|
||||||
msg(player, msgString);
|
|
||||||
WarzoneMapper.save(this, warzone, false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(warzone.getNorthwest() == null) {
|
if(warzone.getNorthwest() == null) {
|
||||||
msg(player, "Still missing northwesternmost point.");
|
msg(player, msgString + "Still missing northwesternmost point.");
|
||||||
}
|
} else if(warzone.getSoutheast() == null) {
|
||||||
if(warzone.getSoutheast() == null) {
|
msg(player, msgString + "Still missing southeasternmost point.");
|
||||||
msg(player, "Still missing southeasternmost point.");
|
} else if (warzone.tooBig()) {
|
||||||
}
|
badMsg(player, msgString + "Warzone " + warzone.getName() + " is too Big. Max north-south size: 500. Max east-west size: 500.");
|
||||||
if(warzone.getNorthwest() != null && warzone.getSoutheast() != null) {
|
} else if (warzone.tooSmall()) {
|
||||||
if(warzone.ready()) {
|
badMsg(player, msgString + "Warzone " + warzone.getName() + " is too small. Min north-south size: 20. Min east-west size: 20.");
|
||||||
warzone.saveState(false); // we just changed the volume, cant reset walls
|
} else if(!fail && warzone.ready()) {
|
||||||
if(warzone.getLobby() == null) {
|
if(!this.warzones.contains(warzone)) {
|
||||||
// Set default lobby on south side
|
this.addWarzone(warzone);
|
||||||
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();
|
|
||||||
}
|
|
||||||
this.msg(player, "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);
|
|
||||||
this.msg(player, "Warzone saved. Use /setteam, /setmonument and /savezone to configure the zone.");
|
|
||||||
}
|
}
|
||||||
|
if(this.incompleteZones.contains(warzone)) {
|
||||||
|
this.incompleteZones.remove(warzone);
|
||||||
|
}
|
||||||
|
WarMapper.save(this);
|
||||||
|
msgString += "New zone outline ok. Saving new warzone blocks...";
|
||||||
|
msg(player, msgString);
|
||||||
|
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);
|
||||||
|
if(warHub != null) { // warhub has to change
|
||||||
|
warHub.getVolume().resetBlocks();
|
||||||
|
warHub.initialize();
|
||||||
|
}
|
||||||
|
this.msg(player, "Default lobby created on south side of zone. Use /setzonelobby <n/s/e/w> to change its position.");
|
||||||
|
} else {
|
||||||
|
// gotta move the lobby
|
||||||
|
warzone.getLobby().changeWall(warzone.getLobby().getWall());
|
||||||
|
}
|
||||||
|
warzone.initializeZone();
|
||||||
|
WarzoneMapper.save(this, warzone, true);
|
||||||
|
this.msg(player, "Warzone saved. Use /setteam, /setmonument and /savezone to configure the zone.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(warzone.getVolume().isSaved()
|
||||||
|
&& (warzone.tooBig() || warzone.tooSmall())
|
||||||
|
&& (oldNorthwest != null || oldSoutheast != null) )
|
||||||
|
{
|
||||||
|
// we resized but the result is too small or too big. Restore the old corner and reinit the zone.
|
||||||
|
if(oldNorthwest != null) {
|
||||||
|
warzone.setNorthwest(oldNorthwest);
|
||||||
|
} else if (oldSoutheast != null) {
|
||||||
|
warzone.setSoutheast(oldSoutheast);
|
||||||
|
}
|
||||||
|
warzone.initializeZone();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,7 +42,6 @@ public class ZoneLobby {
|
|||||||
public ZoneLobby(War war, Warzone warzone, BlockFace wall) {
|
public ZoneLobby(War war, Warzone warzone, BlockFace wall) {
|
||||||
this.war = war;
|
this.war = war;
|
||||||
this.warzone = warzone;
|
this.warzone = warzone;
|
||||||
//this.changeWall(wall, false);
|
|
||||||
this.changeWall(wall);
|
this.changeWall(wall);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,16 +68,9 @@ public class ZoneLobby {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void changeWall(BlockFace newWall) {
|
public void changeWall(BlockFace newWall) {
|
||||||
// changeWall(newWall, true);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public void changeWall(BlockFace newWall, boolean save) {
|
|
||||||
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 {
|
|
||||||
// move the lobby
|
|
||||||
// this.volume.resetBlocks(); // should be done previously thru getVolume
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.wall = newWall;
|
this.wall = newWall;
|
||||||
@ -133,12 +125,12 @@ public class ZoneLobby {
|
|||||||
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/* && save*/) {
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user