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
	{
		private Map<ThemeElement, String> elements = new HashMap<>();

		protected VanillaTheme()
		{
			elements.put(ThemeElement.CHAT_MESSAGE_FORMAT, "<${name}> ${message}");
		}

		@Override
		public String getID()
		{
			return "vanilla";
		}

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

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

		@Override
		public String getElement(ThemeElement element)
		{
			return elements.get(element);
		}
	}
}

@@ -388,16 +388,27 @@
 %7B%0A%09%09add(
+%22vanilla%22, 
 defaultT
@@ -435,16 +435,27 @@
 oid add(
+String ID, 
 Theme th
@@ -471,24 +471,56 @@
 %09themes.put(
+ID, theme);%0A%09%09themesByClass.put(
 theme.getID(
@@ -516,18 +516,21 @@
 heme.get
-ID
+Class
 (), them
@@ -526,33 +526,164 @@
 ass(), theme);%0A%09
-%09
+%7D%0A%0A%09public void addAll(Map%3CString, Theme%3E themes)%0A%09%7B%0A%09%09this.themes.putAll(themes);%0A%09%09themes.values().stream().forEach(theme -%3E this.
 themesByClass.pu
@@ -700,32 +700,33 @@
 tClass(), theme)
+)
 ;%0A%09%7D%0A%0A%09public Th

replace add(Theme) with add(String, Theme) and also added addAll() method