aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/me/Danker/features/loot/MythologicalTracker.java
blob: 9a98466ca6ff6e51edb829607b7dcbd5c1dad930 (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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
package me.Danker.features.loot;

import me.Danker.handlers.ConfigHandler;
import me.Danker.utils.Utils;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.Entity;
import net.minecraft.util.StringUtils;
import net.minecraftforge.client.event.ClientChatReceivedEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;

import java.util.List;

public class MythologicalTracker {

    public static double mythCoins;
    public static int griffinFeathers;
    public static int crownOfGreeds;
    public static int washedUpSouvenirs;
    public static int minosHunters;
    public static int siameseLynxes;
    public static int minotaurs;
    public static int gaiaConstructs;
    public static int minosChampions;
    public static int minosInquisitors;

    public static double mythCoinsSession = 0;
    public static int griffinFeathersSession = 0;
    public static int crownOfGreedsSession = 0;
    public static int washedUpSouvenirsSession = 0;
    public static int minosHuntersSession = 0;
    public static int siameseLynxesSession = 0;
    public static int minotaursSession = 0;
    public static int gaiaConstructsSession = 0;
    public static int minosChampionsSession = 0;
    public static int minosInquisitorsSession = 0;

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

        if (!Utils.inSkyblock) return;
        if (event.type == 2) return;
        if (message.contains(":")) return;

        if (message.contains("You dug out")) {
            if (message.contains(" coins!")) {
                double coinsEarned = Double.parseDouble(message.replaceAll("[^\\d]", ""));
                mythCoins += coinsEarned;
                mythCoinsSession += coinsEarned;
                ConfigHandler.writeDoubleConfig("mythological", "coins", mythCoins);
            } else if (message.contains("a Griffin Feather!")) {
                griffinFeathers++;
                griffinFeathersSession++;
                ConfigHandler.writeIntConfig("mythological", "griffinFeather", griffinFeathers);
            } else if (message.contains("a Crown of Greed!")) {
                crownOfGreeds++;
                crownOfGreedsSession++;
                ConfigHandler.writeIntConfig("mythological", "crownOfGreed", crownOfGreeds);
            } else if (message.contains("a Washed-up Souvenir!")) {
                washedUpSouvenirs++;
                washedUpSouvenirsSession++;
                ConfigHandler.writeIntConfig("mythological", "washedUpSouvenir", washedUpSouvenirs);
            } else if (message.contains("a Minos Hunter!")) {
                minosHunters++;
                minosHuntersSession++;
                ConfigHandler.writeIntConfig("mythological", "minosHunter", minosHunters);
            } else if (message.contains("Siamese Lynxes!")) {
                siameseLynxes++;
                siameseLynxesSession++;
                ConfigHandler.writeIntConfig("mythological", "siameseLynx", siameseLynxes);
            } else if (message.contains("a Minotaur!")) {
                minotaurs++;
                minotaursSession++;
                ConfigHandler.writeIntConfig("mythological", "minotaur", minotaurs);
            } else if (message.contains("a Gaia Construct!")) {
                gaiaConstructs++;
                gaiaConstructsSession++;
                ConfigHandler.writeIntConfig("mythological", "gaiaConstruct", gaiaConstructs);
            } else if (message.contains("a Minos Champion!")) {
                Minecraft mc = Minecraft.getMinecraft();
                List<Entity> listWorldEntity = mc.theWorld.getLoadedEntityList();
                for (Entity entity : listWorldEntity) {
                    if (entity.getName().contains("Minos Champion")) {
                        minosChampions++;
                        minosChampionsSession++;
                        ConfigHandler.writeIntConfig("mythological", "minosChampion", minosChampions);
                    } else if (entity.getName().contains("Minos Inquisitor")) {
                        minosInquisitors++;
                        minosInquisitorsSession++;
                        ConfigHandler.writeIntConfig("mythological", "minosInquisitor", minosInquisitors);
                    }
                }
            } else if (message.contains("a Minos Inquisitor!")) {
                minosInquisitors++;
                minosInquisitorsSession++;
                ConfigHandler.writeIntConfig("mythological", "minosInquisitor", minosInquisitors);
            }
        }
    }

}