Mapping bugs. Monument bugs still ongoing. Lobby is borked.

This commit is contained in:
taoneill 2011-01-14 17:04:06 -05:00
parent 40f14a7bb0
commit 1723aae771
6 changed files with 45 additions and 35 deletions

View File

@ -379,8 +379,9 @@ public class WarPlayerListener extends PlayerListener {
lobby.initialize();
player.sendMessage(war.str("Default lobby created on south side of zone."));
}
player.sendMessage(war.str("Warzone " + warzone.getName() + " initial state changed. Saved " + savedBlocks + " blocks."));
WarzoneMapper.save(war, warzone, true);
warzone.initializeZone(); // bring back team spawns etc
player.sendMessage(war.str("Warzone " + warzone.getName() + " initial state changed. Saved " + savedBlocks + " blocks."));
}
event.setCancelled(true);
}
@ -431,8 +432,12 @@ public class WarPlayerListener extends PlayerListener {
t.getVolume().resetBlocks();
}
for(Monument m : warzone.getMonuments()) {
m.remove();
m.getVolume().resetBlocks();
}
if(warzone.getLobby() != null) {
warzone.getLobby().getVolume().resetBlocks();
}
warzone.getVolume().resetBlocks();
war.getWarzones().remove(warzone);
WarMapper.save(war);
WarzoneMapper.delete(war, warzone.getName());
@ -509,6 +514,7 @@ public class WarPlayerListener extends PlayerListener {
if(warzone.hasMonument(monumentName)) {
// move the existing monument
Monument monument = warzone.getMonument(monumentName);
monument.getVolume().resetBlocks();
monument.setLocation(player.getLocation());
player.sendMessage(war.str("Monument " + monument.getName() + " was moved."));
} else {
@ -533,7 +539,7 @@ public class WarPlayerListener extends PlayerListener {
Warzone warzone = war.warzone(player.getLocation());
Monument monument = warzone.getMonument(name);
if(monument != null) {
monument.remove();
monument.getVolume().resetBlocks();
warzone.getMonuments().remove(monument);
WarzoneMapper.save(war, warzone, false);
player.sendMessage(war.str("Monument " + name + " removed."));

View File

@ -25,11 +25,12 @@ public class Monument {
this.name = name;
this.location = location;
this.warzone = warzone;
volume = new CenteredVolume("name",
volume = new CenteredVolume(name,
warzone.getWorld().getBlockAt(location.getBlockX(),
location.getBlockY() + 2,
location.getBlockZ()),
7, war, warzone.getWorld());
volume.calculateCorners();
volume.saveBlocks();
this.addMonumentBlocks();
}
@ -44,16 +45,16 @@ public class Monument {
warzone.getWorld().getBlockAt(x, y-1, z).getState().setType(Material.OBSIDIAN);
// inner ring
warzone.getWorld().getBlockAt(x+1, y-1, z+1).setType(Material.GLOWSTONE);
warzone.getWorld().getBlockAt(x+1, y-1, z+1).setType(Material.OBSIDIAN);
warzone.getWorld().getBlockAt(x+1, y-1, z).setType(Material.OBSIDIAN);
warzone.getWorld().getBlockAt(x+1, y-1, z-1).setType(Material.GLOWSTONE);
warzone.getWorld().getBlockAt(x+1, y-1, z-1).setType(Material.OBSIDIAN);
warzone.getWorld().getBlockAt(x, y-1, z+1).setType(Material.OBSIDIAN);
warzone.getWorld().getBlockAt(x, y-1, z-1).setType(Material.OBSIDIAN);
warzone.getWorld().getBlockAt(x-1, y-1, z+1).setType(Material.GLOWSTONE);
warzone.getWorld().getBlockAt(x-1, y-1, z+1).setType(Material.OBSIDIAN);
warzone.getWorld().getBlockAt(x-1, y-1, z).setType(Material.OBSIDIAN);
warzone.getWorld().getBlockAt(x-1, y-1, z-1).setType(Material.GLOWSTONE);
warzone.getWorld().getBlockAt(x-1, y-1, z-1).setType(Material.OBSIDIAN);
// outer ring
@ -129,10 +130,6 @@ public class Monument {
warzone.getWorld().getBlockAt(location.getBlockX(), location.getBlockY(), location.getBlockZ()).setType(Material.OBSIDIAN);
}
public void remove() {
volume.resetBlocks();
}
public Location getLocation() {
return location;
@ -150,6 +147,7 @@ public class Monument {
public void setLocation(Location location) {
volume.changeCenter(location);
this.addMonumentBlocks();
this.location = location;
}
public CenteredVolume getVolume() {

View File

@ -156,8 +156,9 @@ public class Warzone {
}
for(Monument monument : monuments) {
monument.remove();
monument.getVolume().resetBlocks();
}
int saved = volume.saveBlocks();
initializeZone(); // bring back stuff
return saved;
@ -193,7 +194,7 @@ public class Warzone {
// reset monuments
for(Monument monument : monuments) {
monument.remove();
monument.getVolume().resetBlocks();
monument.addMonumentBlocks();
}

View File

@ -48,7 +48,7 @@ public class VolumeMapper {
public static void load(Volume volume, String zoneName, War war, World world) {
BufferedReader in = null;
try {
if(zoneName.equals("")) in = new BufferedReader(new FileReader(new File("War/volume-" + volume.getName() + ".dat")));
if(zoneName.equals("")) in = new BufferedReader(new FileReader(new File("War/volume-" + volume.getName() + ".dat"))); // for the warhub
else in = new BufferedReader(new FileReader(new File("War/warzone-" + zoneName + "/volume-" + volume.getName() + ".dat")));
String firstLine = in.readLine();
if(firstLine != null && !firstLine.equals("")) {
@ -74,26 +74,27 @@ public class VolumeMapper {
for(int k = 0; k < volume.getSizeZ(); k++) {
String blockLine = in.readLine();
String[] blockSplit = blockLine.split(",");
int typeID = Integer.parseInt(blockSplit[0]);
byte data = Byte.parseByte(blockSplit[1]);
String[] lines = null;
if(typeID == Material.SIGN.getID() || typeID == Material.SIGN_POST.getID()) {
String signLines = blockSplit[2];
if(blockSplit.length > 3) {
// sign includes commas
for(int splitI = 3; splitI < blockSplit.length; splitI++) {
signLines.concat(blockSplit[splitI]);
if(blockLine != null && !blockLine.equals("")) {
int typeID = Integer.parseInt(blockSplit[0]);
byte data = Byte.parseByte(blockSplit[1]);
String[] lines = null;
if(typeID == Material.SIGN.getID() || typeID == Material.SIGN_POST.getID()) {
String signLines = blockSplit[2];
if(blockSplit.length > 3) {
// sign includes commas
for(int splitI = 3; splitI < blockSplit.length; splitI++) {
signLines.concat(blockSplit[splitI]);
}
}
String[] signLinesSplit = signLines.split("[line]");
lines = new String[4];
lines[0] = signLinesSplit[0];
lines[1] = signLinesSplit[1];
lines[2] = signLinesSplit[2];
lines[3] = signLinesSplit[3];
}
String[] signLinesSplit = signLines.split("[line]");
lines = new String[4];
lines[0] = signLinesSplit[0];
lines[1] = signLinesSplit[1];
lines[2] = signLinesSplit[2];
lines[3] = signLinesSplit[3];
volume.getBlockInfos()[i][j][k] = new BlockInfo(typeID, data, lines);
}
volume.getBlockInfos()[i][j][k] = new BlockInfo(typeID, data, lines);
}
}
}

View File

@ -317,10 +317,14 @@ public class WarzoneMapper {
for(File file : files) {
boolean deletedData = file.delete();
if(!deletedData) {
war.getLogger().warning(file.getName());
war.getLogger().warning("Failed to delete file " + file.getName());
}
}
zoneFolder.delete();
;
boolean deletedData = zoneFolder.delete();
if(!deletedData) {
war.getLogger().warning("Failed to delete file " + zoneFolder.getName());
}
}
}

View File

@ -271,7 +271,7 @@ public class Volume {
}
public Block getCornerTwo() {
return cornerOne;
return cornerTwo;
}
public boolean contains(Location location) {