mRDTE9Kyfv
AL_1

/**
	 * Centers a string for the default chat window
	 * 
	 * @author DiamondDeveloper
	 * @since 1.0
	 * 
	 * @param message
	 *            Message you want to center
	 * @return The centered message
	 * @throws StringToLongExpectation
	 */
	public static String centerMessageNoBreak(String message) {
		return centerMessage(message.replaceAll(":", "\\;")).replaceAll("\\;", ":");
	}

	/**
	 * Centers a string for the default chat window
	 * 
	 * @author DiamondDeveloper
	 * @since 1.0
	 * 
	 * @param message
	 *            Message you want to center
	 * @return The centered message
	 * @throws StringToLongExpectation
	 */
	public static String centerMessage(String message) {

		message = Plugin.replacePH(message);
		message = Plugin.replacePH(message);

		if (message.contains(":")) {
			String[] strs = message.split(":");
			String strR = centerMessage(strs[0]) + "\n";
			for (int i = 1; i < strs.length; i++) {
				String end = "";
				if (i != strs.length) {
					end = "\n";
				}
				strR = strR + centerMessage(strs[i]) + end;
			}
			return strR;
		}

		String messageNC = ChatColor.translateAlternateColorCodes('&', message);
		messageNC = ChatColor.stripColor(messageNC);
		double msgL = length.getLength(messageNC);
		int mccL = 53 * 6;
		int addR;
		int addL;
		double math;
		String send;

		try {
			if (msgL > mccL) {
				throw new StringToLongExpectation("String to long!");

			}
		} catch (StringToLongExpectation e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		math = mccL - msgL;
		math = math / 8;

		addL = (int) Math.floor(math);
		addR = (int) Math.round(math);

		String L = "";
		String R = "";

		for (int i = 0; i < addL; i++) {
			L = L + " ";
		}
		for (int i = 0; i < addR; i++) {
			R = R + " ";
		}
		send = L + message;
		return send;
	}

	private enum length {
		AZ(6), SPACE(2), IL(1);

		double ln = 0;

		private length(double length) {
			ln = length;
		}

		private double getLength() {
			return ln;
		}

		private static double getLength(String str) {
			char[] arr = str.toCharArray();
			double total = 0;
			for (int i = 0; i < arr.length; i++) {
				total = total + getLength(arr[i]);
			}
			return total;
		}

		private static double getLength(char ch) {
			Character[] aTOz = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q',
					'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'j', 'k', 'm',
					'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' };
			Character[] iTOl = { 'i', 'l', ',', '\'', '.', '|', '!', '*', ';', ':' };
			Character[] spaceTO = { ' ', '(', ')' };
			List<Character> az = Arrays.asList(aTOz);
			List<Character> il = Arrays.asList(iTOl);
			List<Character> space = Arrays.asList(spaceTO);
			if (az.contains(ch)) {
				return length.AZ.getLength();
			} else if (il.contains(ch)) {
				return length.IL.getLength();
			} else if (space.contains(ch)) {
				return length.SPACE.getLength();
			}

			return length.AZ.getLength();
		}

	}