package com.hyperfresh.mchyperchat;

import java.util.HashMap;
import java.util.Map;

public class ThemeManager
{
	private final Map<String, Theme> themes = new HashMap<>();

	private final Map<Class<? extends Theme>, Theme> themesByClass = new HashMap<>();

	/**
	 * The theme to use as the default.
	 */
	private final Theme defaultTheme = new VanillaTheme();

	public ThemeManager()
	{
		add(defaultTheme);
	}

	public void add(Theme theme)
	{
		themes.put(theme.getID(), theme);
		themesByClass.put(theme.getClass(), theme);
	}

	public Theme get(String id)
	{
		return themes.get(id);
	}

	public Theme getDefaultTheme()
	{
		return defaultTheme;
	}

	public <E extends Theme> E get(Class<E> themeClass)
	{
		return (E)themesByClass.get(themeClass);
	}

	public static class VanillaTheme implements Theme
	{
		@Override
		public String getID()
		{
			return "vanilla";
		}

		@Override
		public String getName()
		{
			return "Vanilla Classic";
		}

		@Override
		public String getAuthor()
		{
			return "Mojang";
		}

		@Override
		public String getChatHeaderFormat()
		{
			return "";
		}

		@Override
		public String getChatMessageFormat()
		{
			return "<${name}> ${message}";
		}

		@Override
		public String getChatFooterFormat()
		{
			return null;
		}
	}
}

@@ -806,16 +806,192 @@
 heme%0A%09%7B%0A
+%09%09private Map%3CThemeElement, String%3E elements = new HashMap%3C%3E();%0A%0A%09%09protected VanillaTheme()%0A%09%09%7B%0A%09%09%09elements.put(ThemeElement.CHAT_MESSAGE_FORMAT, %22%3C$%7Bname%7D%3E $%7Bmessage%7D%22);%0A%09%09%7D%0A%0A
 %09%09@Overr
@@ -1228,212 +1228,73 @@
  get
-ChatHeaderFormat()%0A%09%09%7B%0A%09%09%09return %22%22;%0A%09%09%7D%0A%0A%09%09@Override%0A%09%09public String getChatMessageFormat()%0A%09%09%7B%0A%09%09%09return %22%3C$%7Bname%7D%3E $%7Bmessage%7D%22;%0A%09%09%7D%0A%0A%09%09@Override%0A%09%09public String getChatFooterFormat()%0A%09%09%7B%0A%09%09%09return null
+Element(ThemeElement element)%0A%09%09%7B%0A%09%09%09return elements.get(element)
 ;%0A%09%09

change VanillaTheme to use the new Theme interface