From dfbb9305d26a6e83bcc19f99abba0eec78f4d0a3 Mon Sep 17 00:00:00 2001 From: Bukkit/Spigot <noreply+git-bukkit@papermc.io> Date: Mon, 3 Jan 2011 21:31:15 +0000 Subject: [PATCH] Fixed Colors + moved to enum By: Dinnerbone <dinnerbone@dinnerbone.com> --- paper-api/src/main/java/org/bukkit/Color.java | 62 ++++++++++++++----- 1 file changed, 45 insertions(+), 17 deletions(-) diff --git a/paper-api/src/main/java/org/bukkit/Color.java b/paper-api/src/main/java/org/bukkit/Color.java index d751f122c8..4ef73ce6a3 100644 --- a/paper-api/src/main/java/org/bukkit/Color.java +++ b/paper-api/src/main/java/org/bukkit/Color.java @@ -1,20 +1,48 @@ package org.bukkit; -public class Color { - public static final String BLACK = "�0"; - public static final String DARK_BLUE = "�1"; - public static final String DARK_GREEN = "�2"; - public static final String DARK_AQUA = "�3"; - public static final String DARK_RED = "�4"; - public static final String DARK_PURPLE = "�5"; - public static final String GOLD = "�6"; - public static final String GRAY = "�7"; - public static final String DARK_GRAY = "�8"; - public static final String BLUE = "�9"; - public static final String GREEN = "�a"; - public static final String AQUA = "�b"; - public static final String RED = "�c"; - public static final String LIGHT_PURPLE = "�d"; - public static final String YELLOW = "�e"; - public static final String WHITE = "�f"; +import java.util.HashMap; +import java.util.Map; + +/** + * All supported color values + */ +public enum Color { + BLACK(0x0), + DARK_BLUE(0x1), + DARK_GREEN(0x2), + DARK_AQUA(0x3), + DARK_RED(0x4), + DARK_PURPLE(0x5), + GOLD(0x6), + GRAY(0x7), + DARK_GRAY(0x8), + BLUE(0x9), + GREEN(0xa), + AQUA(0xb), + RED(0xc), + LIGHT_PURPLE(0xd), + YELLOW(0xe), + WHITE(0xf); + + private final int code; + private final static Map<Integer, Color> colors = new HashMap<Integer, Color>(); + + private Color(final int code) { + this.code = code; + } + + public int getCode() { + return code; + } + + @Override + public String toString() { + return "\u00A7" + code; + } + + static { + for (Color color : Color.values()) { + colors.put(color.getCode(), color); + } + } } \ No newline at end of file