From 1b03e64387e7a195b1498866c4cec89f30b0348e Mon Sep 17 00:00:00 2001 From: ulumulu1510 Date: Fri, 26 Feb 2016 19:04:18 +0100 Subject: [PATCH] 3h - Add more Characters to the Map-Chars. --- src/com/massivecraft/factions/Const.java | 8 ++++- .../massivecraft/factions/entity/Board.java | 36 +++++++++++-------- 2 files changed, 29 insertions(+), 15 deletions(-) diff --git a/src/com/massivecraft/factions/Const.java b/src/com/massivecraft/factions/Const.java index a0d0d8a6..0f1f9750 100644 --- a/src/com/massivecraft/factions/Const.java +++ b/src/com/massivecraft/factions/Const.java @@ -1,5 +1,7 @@ package com.massivecraft.factions; +import org.bukkit.ChatColor; + public class Const { // Collections & Aspects @@ -20,7 +22,11 @@ public class Const public static final int MAP_HEIGHT = 8; public static final int MAP_HEIGHT_FULL = 17; - public static final char[] MAP_KEY_CHARS = "\\/#?$%=&^ABCDEFGHJKLMNOPQRSTUVWXYZ1234567890abcdeghjmnopqrsuvwxyz".toCharArray(); + public static final char[] MAP_KEY_CHARS = "\\/#?笣$%=&^ABCDEFGHJKLMNOPQRSTUVWXYZÄÖÜÆØÅ1234567890abcdeghjmnopqrsuvwxyÿzäöüæøåâêîûô".toCharArray(); + public static final String MAP_KEY_WILDERNESS = ChatColor.GRAY.toString() + "-"; + public static final String MAP_KEY_SEPARATOR = ChatColor.AQUA.toString() + "+"; + public static final String MAP_KEY_OVERFLOW = ChatColor.MAGIC.toString() + "-" + ChatColor.RESET.toString(); + public static final String MAP_OVERFLOW_MESSAGE = MAP_KEY_OVERFLOW + ": Too Many Factions (>" + MAP_KEY_CHARS.length + ") on this Map."; // SHOW diff --git a/src/com/massivecraft/factions/entity/Board.java b/src/com/massivecraft/factions/entity/Board.java index 8a265f21..ceefc5db 100644 --- a/src/com/massivecraft/factions/entity/Board.java +++ b/src/com/massivecraft/factions/entity/Board.java @@ -355,7 +355,7 @@ public class Board extends Entity implements BoardInterface ArrayList ret = new ArrayList(); Faction centerFaction = this.getFactionAt(centerPs); - ret.add(Txt.titleize("("+centerPs.getChunkX() + "," + centerPs.getChunkZ()+") "+centerFaction.getName(observer))); + ret.add(Txt.titleize("(" + centerPs.getChunkX() + "," + centerPs.getChunkZ() + ") " + centerFaction.getName(observer))); int halfWidth = width / 2; int halfHeight = height / 2; @@ -369,50 +369,58 @@ public class Board extends Entity implements BoardInterface Map fList = new HashMap(); int chrIdx = 0; + boolean overflown = false; // For each row for (int dz = 0; dz < height; dz++) { // Draw and add that row - String row = ""; + StringBuilder row = new StringBuilder(); for (int dx = 0; dx < width; dx++) { - if(dx == halfWidth && dz == halfHeight) + if (dx == halfWidth && dz == halfHeight) { - row += ChatColor.AQUA+"+"; + row.append(Const.MAP_KEY_SEPARATOR); continue; } - + + if ( ! overflown && chrIdx >= Const.MAP_KEY_CHARS.length) overflown = true; + PS herePs = topLeftPs.plusChunkCoords(dx, dz); Faction hereFaction = this.getFactionAt(herePs); + boolean contains = fList.containsKey(hereFaction); if (hereFaction.isNone()) { - row += ChatColor.GRAY+"-"; + row.append(Const.MAP_KEY_WILDERNESS); + } + else if ( ! contains && overflown) + { + row.append(Const.MAP_KEY_OVERFLOW); } else { - if (!fList.containsKey(hereFaction)) - fList.put(hereFaction, Const.MAP_KEY_CHARS[chrIdx++]); + if ( ! contains) fList.put(hereFaction, Const.MAP_KEY_CHARS[chrIdx++]); char fchar = fList.get(hereFaction); - row += hereFaction.getColorTo(observer) + "" + fchar; + row.append(hereFaction.getColorTo(observer).toString()).append(fchar); } } - ret.add(row); + ret.add(row.toString()); } // Get the compass ArrayList asciiCompass = AsciiCompass.getAsciiCompass(inDegrees, ChatColor.RED, Txt.parse("")); // Add the compass - ret.set(1, asciiCompass.get(0)+ret.get(1).substring(3*3)); - ret.set(2, asciiCompass.get(1)+ret.get(2).substring(3*3)); - ret.set(3, asciiCompass.get(2)+ret.get(3).substring(3*3)); + ret.set(1, asciiCompass.get(0) + ret.get(1).substring(3*3)); + ret.set(2, asciiCompass.get(1) + ret.get(2).substring(3*3)); + ret.set(3, asciiCompass.get(2) + ret.get(3).substring(3*3)); String fRow = ""; for (Faction keyfaction : fList.keySet()) { - fRow += ""+keyfaction.getColorTo(observer) + fList.get(keyfaction) + ": " + keyfaction.getName() + " "; + fRow += keyfaction.getColorTo(observer).toString() + fList.get(keyfaction) + ": " + keyfaction.getName() + " "; } + if (overflown) fRow += Const.MAP_OVERFLOW_MESSAGE; fRow = fRow.trim(); ret.add(fRow);