package uk.co.drnaylor.minecraft.hammer.bukkit.text;

import org.bukkit.ChatColor;
import uk.co.drnaylor.minecraft.hammer.core.text.HammerText;
import uk.co.drnaylor.minecraft.hammer.core.text.HammerTextColours;
import uk.co.drnaylor.minecraft.hammer.core.text.HammerTextFormats;

public final class HammerTextConverter {

    private HammerTextConverter() { }

    /**
     * Constructs a message from the collection of {@link HammerText} messages.
     *
     * @param message The {@link HammerText} messages.
     * @return The completed message.
     */
    public static String constructMessage(HammerText message) {
        StringBuilder sb = new StringBuilder();

        for (HammerText.Element t : message.getElements()) {
            if (sb.length() > 0) {
                sb.append(ChatColor.RESET);
            }

            convertColour(t.colour, sb);
            convertFormats(t.formats, sb);

            sb.append(t.message);
        }

        return sb.toString();
    }

    private static void convertColour(HammerTextColours colour, StringBuilder sb) {
        ChatColor c = HammerTextToCodeConverter.getCodeFromHammerText(colour);
        if (c != null) {
            sb.append(c);
        }
    }

    private static void convertFormats(HammerTextFormats[] formats, StringBuilder sb) {
        for (HammerTextFormats f : formats) {
            sb.append(HammerTextToCodeConverter.getCodeFromHammerText(f));
        }
    }
}

@@ -1347,24 +1347,57 @@
  formats) %7B%0A
+            if (f != null) %7B%0A    
             
@@ -1459,16 +1459,30 @@
 xt(f));%0A
+            %7D%0A
         

Add null check to format builder