summaryrefslogtreecommitdiffstats
path: root/EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/Colors.java
blob: 053b177e58dc08d3e1967939033537f2ccbf643f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package com.earth2me.essentials.anticheat;

import org.bukkit.ChatColor;


/**
 * Manages color codes in NoCheat
 *
 */
public class Colors
{
	/**
	 * Replace instances of &X with a color
	 *
	 * @param text
	 * @return
	 */
	public static String replaceColors(String text)
	{
		for (ChatColor c : ChatColor.values())
		{
			text = text.replace("&" + c.getChar(), c.toString());
		}

		return text;
	}

	/**
	 * Remove instances of &X
	 *
	 * @param text
	 * @return
	 */
	public static String removeColors(String text)
	{
		for (ChatColor c : ChatColor.values())
		{
			text = text.replace("&" + c.getChar(), "");
		}
		return text;
	}
}