package com.cldfire.xenforonotifier.util;

import java.awt.Image;
import java.awt.SystemTray;
import java.awt.Toolkit;
import java.awt.TrayIcon;
import java.awt.TrayIcon.MessageType;

public class NotificationUtils {
    private static Image image = Toolkit.getDefaultToolkit().getImage(""); // TODO: Get this working
    private static TrayIcon trayIcon = new TrayIcon(image, "Spigot Notifier");

    public static void createNotification(String mainText, String message) { // TODO: Make sure this is thread-safe, use TrayNotification notifications for OS other than Windows
        if (SystemTray.isSupported()) {
            try {
                SystemTray.getSystemTray().add(trayIcon); // TODO: Prevent this from duplicating
            } catch (Exception e) {
                e.printStackTrace();
            }
            trayIcon.displayMessage(mainText, message, MessageType.NONE);
        }
    }

}

@@ -375,14 +375,15 @@
 e, %22
-Spigot
+XenForo
  Not
@@ -606,24 +606,65 @@
 ported()) %7B%0A
+            if (!trayIconExists()) %7B%0A    
             
@@ -685,16 +685,20 @@
         
+   
+ 
 SystemTr
@@ -734,48 +734,13 @@
 on);
- // TODO: Prevent this from duplicating%0A
+%0A    
     
@@ -787,16 +787,20 @@
         
+    
 e.printS
@@ -812,16 +812,34 @@
 race();%0A
+                %7D%0A
         
@@ -935,10 +935,258 @@
 %0A    %7D%0A%0A
+    private static boolean trayIconExists() %7B%0A        for (TrayIcon _trayIcon : SystemTray.getSystemTray().getTrayIcons()) %7B%0A            if (trayIcon == _trayIcon) %7B%0A                return true;%0A            %7D%0A        %7D%0A        return false;%0A    %7D%0A%0A
 %7D%0A

Rename Spigot to XenForo and fix duplicating the TrayIcon