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];
if (lineCount < compass.length)
line = compass[lineCount];
for (int mx = lineWidth-1; mx >= 0; mx--)
line += townyMap[mx][my];
if (lineCount < help.length)
line += help[lineCount];
player.sendMessage(line);
lineCount++;
}
// Current town block data
try {
TownBlock townblock = world.getTownBlock(pos);
TownyMessaging.sendMsg(player, ("Town: " + (townblock.hasTown() ? townblock.getTown().getName() : "None") + " : "
+ "Owner: " + (townblock.hasResident() ? townblock.getResident().getName() : "None")));
} catch (TownyException e) {
//plugin.sendErrorMsg(player, e.getError());
// Send a blank line instead of an error, to keep the map position tidy.
player.sendMessage ("");
}