aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/me/Danker/features/GpartyNotifications.java
blob: f3aec69439566fe42f9d820073e0f44445303d28 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package me.Danker.features;

import me.Danker.commands.ToggleCommand;
import me.Danker.utils.Utils;
import net.minecraft.util.StringUtils;
import net.minecraftforge.client.event.ClientChatReceivedEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;

import java.awt.*;

public class GpartyNotifications {

    @SubscribeEvent
    public void onChat(ClientChatReceivedEvent event) {
        String message = StringUtils.stripControlCodes(event.message.getUnformattedText());

        if (!Utils.inSkyblock) return;
        if (message.contains(":")) return;

        if (ToggleCommand.gpartyToggled) {
            if (message.contains(" has invited all members of ")) {
                try {
                    final SystemTray tray = SystemTray.getSystemTray();
                    final Image image = Toolkit.getDefaultToolkit().createImage("icon.png");
                    final TrayIcon trayIcon = new TrayIcon(image, "Guild Party Notifier");
                    trayIcon.setImageAutoSize(true);
                    trayIcon.setToolTip("Guild Party Notifier");
                    tray.add(trayIcon);
                    trayIcon.displayMessage("Guild Party", message, TrayIcon.MessageType.INFO);
                    tray.remove(trayIcon);
                } catch (Exception ex) {
                    ex.printStackTrace();
                }
            }
        }
    }

}