}
if (!world.isUsingTowny()) {
TownyMessaging.sendErrorMsg(player, "This world is not using towny.");
return;
}
Coord pos = Coord.parseCoord(plugin.getCache(player).getLastLocation());
// Generate Map
int halfLineHeight = lineHeight / 2;
String[][] townyMap = new String[lineWidth][lineHeight];
int x, y = 0;
for (int tby = pos.getX() + (lineWidth-halfLineWidth-1); tby >= pos.getX() - halfLineWidth; tby--) {
x = 0;
for (int tbx = pos.getZ() - halfLineHeight; tbx <= pos.getZ() + (lineHeight-halfLineHeight-1); tbx++) {
try {
TownBlock townblock = world.getTownBlock(tby, tbx);
//TODO: possibly claim outside of towns
if (!townblock.hasTown())
throw new TownyException();
if (x == halfLineHeight && y == halfLineWidth)
// location
townyMap[y][x] = Colors.Gold;
else if (hasTown) {
if (resident.getTown() == townblock.getTown()) {
// own town
townyMap[y][x] = Colors.LightGreen;
try {
if (resident == townblock.getResident())
//own plot
townyMap[y][x] = Colors.Yellow;
} catch(NotRegisteredException e) {
}
} else if (resident.hasNation()) {
if (resident.getTown().getNation().hasTown(townblock.getTown()))
// towns
townyMap[y][x] = Colors.Green;
else if (townblock.getTown().hasNation()) {
Nation nation = resident.getTown().getNation();
if (nation.hasAlly(townblock.getTown().getNation()))
townyMap[y][x] = Colors.Green;
else if (nation.hasEnemy(townblock.getTown().getNation()))
// towns
townyMap[y][x] = Colors.Red;
else
townyMap[y][x] = Colors.White;
} else
townyMap[y][x] = Colors.White;
} else
townyMap[y][x] = Colors.White;
} else
townyMap[y][x] = Colors.White;
// Registered town block
if (townblock.getPlotPrice() != -1) {
// override the colour if it's a shop plot for sale
if (townblock.getType().equals(TownBlockType.COMMERCIAL))
townyMap[y][x] = Colors.Blue;
townyMap[y][x] += "$";
} else if (townblock.isHomeBlock())
townyMap[y][x] += "H";
else
townyMap[y][x] += townblock.getType().getAsciiMapKey();
} catch (TownyException e) {
if (x == halfLineHeight && y == halfLineWidth)
townyMap[y][x] = Colors.Gold;
else
townyMap[y][x] = Colors.Gray;
// Unregistered town block
townyMap[y][x] += "-";
}
x++;
}
y++;
}
String[] compass = generateCompass(player);
// Output
player.sendMessage(ChatTools.formatTitle("Towny Map " + Colors.White + "(" + pos.toString() + ")"));
String line;
int lineCount = 0;
// Variables have been rotated to fit N/S/E/W properly
for (int my = 0; my < lineHeight; my++) {
line = compass[0];