/** * Get formated text. * * @param keys * @return */ public String getText(Object... keys) { if (keys.length == 0) return TextFormat.colorize("&" + c1 + this.message); String str = this.message; boolean noColors = false; boolean skipDefaultColors = false; boolean fullFloat = false; String prefix = ""; int count = 1; char[] colors = new char[] {c1, c2}; int c = 0; DecimalFormat fmt = new DecimalFormat("####0.##"); for (int i = 0; i < keys.length; i++) { String s = keys[i].toString(); if (c < 2 && keys[i] instanceof Character) { colors[c] = (Character) keys[i]; c++; continue; } else if (s.startsWith("prefix:")) { prefix = s.replace("prefix:", ""); continue; } else if (s.equals("SKIPCOLOR")) { skipDefaultColors = true; continue; } else if (s.equals("NOCOLORS") || s.equals("NOCOLOR")) { noColors = true; continue; } else if (s.equals("FULLFLOAT")) { fullFloat = true; continue; } else if (keys[i] instanceof Location) { Location loc = (Location) keys[i]; if (fullFloat) s = loc.getLevel().getName() + "[" + loc.getX() + ", " + loc.getY() + ", " + loc.getZ() + "]"; else s = loc.getLevel().getName() + "[" + fmt.format(loc.getX()) + ", " + fmt.format(loc.getY()) + ", " + fmt.format(loc.getZ()) + "]"; } else if (keys[i] instanceof Double || keys[i] instanceof Float) { if (!fullFloat) s = fmt.format((Double) keys[i]); } String from = (new StringBuilder("%").append(count).append("%")).toString(); String to = skipDefaultColors ? s : (new StringBuilder("&").append(colors[1]).append(s).append("&").append(colors[0])) .toString(); str = str.replace(from, to); count++; } str = TextFormat.colorize( prefix.isEmpty() ? "&" + colors[0] + str : prefix + " " + "&" + colors[0] + str); if (noColors) str = TextFormat.clean(str); return str; }
public static boolean debugMessage(Object... s) { if (debugMode) plugin.getLogger().info(TextFormat.clean(join(s))); return true; }
/** * Same as log, but will printout nothing if debug mode is disabled * * @param s * @return */ public boolean debug(Object... s) { if (debugMode) plugin.getLogger().info(TextFormat.clean(getText(s))); return true; }