aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java
blob: 57e23487f08c28c00ed80c6e03eca5107bec48ee (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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
package at.hannibal2.skyhanni;

import at.hannibal2.skyhanni.config.ConfigManager;
import at.hannibal2.skyhanni.config.Features;
import at.hannibal2.skyhanni.config.commands.Commands;
import at.hannibal2.skyhanni.data.*;
import at.hannibal2.skyhanni.data.repo.RepoManager;
import at.hannibal2.skyhanni.features.*;
import at.hannibal2.skyhanni.features.anvil.AnvilCombineHelper;
import at.hannibal2.skyhanni.features.bazaar.BazaarApi;
import at.hannibal2.skyhanni.features.bazaar.BazaarBestSellMethod;
import at.hannibal2.skyhanni.features.bazaar.BazaarOrderHelper;
import at.hannibal2.skyhanni.features.chat.ChatFilter;
import at.hannibal2.skyhanni.features.chat.PlayerDeathMessages;
import at.hannibal2.skyhanni.features.chat.playerchat.PlayerChatFilter;
import at.hannibal2.skyhanni.features.chat.playerchat.PlayerChatFormatter;
import at.hannibal2.skyhanni.features.commands.WikiCommand;
import at.hannibal2.skyhanni.features.damageindicator.DamageIndicatorManager;
import at.hannibal2.skyhanni.features.dungeon.*;
import at.hannibal2.skyhanni.features.end.VoidlingExtremistColor;
import at.hannibal2.skyhanni.features.event.diana.BurrowWarpHelper;
import at.hannibal2.skyhanni.features.event.diana.GriffinBurrowHelper;
import at.hannibal2.skyhanni.features.event.diana.GriffinBurrowParticleFinder;
import at.hannibal2.skyhanni.features.event.diana.SoopyGuessBurrow;
import at.hannibal2.skyhanni.features.fishing.SeaCreatureManager;
import at.hannibal2.skyhanni.features.fishing.SeaCreatureMessageShortener;
import at.hannibal2.skyhanni.features.fishing.TrophyFishMessages;
import at.hannibal2.skyhanni.features.inventory.*;
import at.hannibal2.skyhanni.features.itemabilities.FireVeilWandParticles;
import at.hannibal2.skyhanni.features.itemabilities.abilitycooldown.ItemAbilityCooldown;
import at.hannibal2.skyhanni.features.minion.MinionFeatures;
import at.hannibal2.skyhanni.features.nether.MilleniaAgedBlazeColor;
import at.hannibal2.skyhanni.features.nether.ashfang.*;
import at.hannibal2.skyhanni.features.slayer.EndermanSlayerBeacon;
import at.hannibal2.skyhanni.features.slayer.HideMobNames;
import at.hannibal2.skyhanni.features.slayer.HighlightSlayerMiniboss;
import at.hannibal2.skyhanni.features.slayer.SlayerQuestWarning;
import at.hannibal2.skyhanni.features.slayer.blaze.*;
import at.hannibal2.skyhanni.features.summonings.SummoningMobManager;
import at.hannibal2.skyhanni.features.summonings.SummoningSoulsName;
import at.hannibal2.skyhanni.test.LorenzTest;
import at.hannibal2.skyhanni.utils.MinecraftConsoleFilter;
import kotlin.coroutines.EmptyCoroutineContext;
import kotlinx.coroutines.*;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.util.ArrayList;
import java.util.List;

@Mod(modid = SkyHanniMod.MODID, version = SkyHanniMod.VERSION)
public class SkyHanniMod {

    public static final String MODID = "skyhanni";
    public static final String VERSION = "0.12.1";

    public static Features feature;

    public static RepoManager repo;
    public static ConfigManager configManager;
    private static Logger logger;

    public static List<Object> listenerClasses = new ArrayList<>();
    public static Job globalJob = JobKt.Job(null);
    public static CoroutineScope coroutineScope =
            CoroutineScopeKt.CoroutineScope(
                    EmptyCoroutineContext.INSTANCE
                            .plus(new CoroutineName("SkyHanni")) // I love calling KotLin from JaVa
                            .plus(SupervisorKt.SupervisorJob(globalJob)));

    @EventHandler
    public void preInit(FMLPreInitializationEvent event) {
        logger = LogManager.getLogger("SkyHanni");

        //API and utils
        new BazaarApi();
        registerEvent(this);
        registerEvent(new ChatManager());
        registerEvent(new HypixelData());
        registerEvent(new DungeonData());
        registerEvent(new ScoreboardData());
        registerEvent(new ApiKeyGrabber());
        registerEvent(new SeaCreatureManager());
        registerEvent(new ItemRenderBackground());
        registerEvent(new EntityData());
        registerEvent(new EntityMovementData());
        registerEvent(new ItemClickData());
        registerEvent(new MinecraftData());
        registerEvent(new SendTitleHelper());
        registerEvent(new ItemTipHelper());

        //features
        registerEvent(new BazaarOrderHelper());
        registerEvent(new ChatFilter());
        registerEvent(new PlayerChatFormatter());
        registerEvent(new DungeonChatFilter());
        registerEvent(new HideNotClickableItems());
        registerEvent(new ItemDisplayOverlayFeatures());
        registerEvent(new CurrentPetDisplay());
        registerEvent(new ExpBottleOnGroundHider());
        registerEvent(new DamageIndicatorManager());
        registerEvent(new ItemAbilityCooldown());
        registerEvent(new DungeonHighlightClickedBlocks());
        registerEvent(new DungeonMilestonesDisplay());
        registerEvent(new DungeonDeathCounter());
        registerEvent(new DungeonCleanEnd());
        registerEvent(new DungeonBossMessages());
        registerEvent(new DungeonBossHideDamageSplash());
        registerEvent(new TrophyFishMessages());
        registerEvent(new BazaarBestSellMethod());
        registerEvent(new AnvilCombineHelper());
        registerEvent(new SeaCreatureMessageShortener());
//        registerEvent(new GriffinBurrowFinder());
        registerEvent(new AshfangFreezeCooldown());
        registerEvent(new AshfangNextResetCooldown());
        registerEvent(new SummoningSoulsName());
        registerEvent(new AshfangGravityOrbs());
        registerEvent(new AshfangBlazingSouls());
        registerEvent(new AshfangBlazes());
        registerEvent(new AshfangHideParticles());
        registerEvent(new AshfangHideDamageIndicator());
        registerEvent(new ItemStars());
        registerEvent(new MinionFeatures());
        registerEvent(new RealTime());
        registerEvent(new RngMeterInventory());
        registerEvent(new WikiCommand());
        registerEvent(new SummoningMobManager());
        registerEvent(new VoidlingExtremistColor());
        registerEvent(new MilleniaAgedBlazeColor());
        registerEvent(new CorruptedMobHighlight());
        registerEvent(new MarkedPlayerManager());
        registerEvent(new HighlightSlayerMiniboss());
        registerEvent(new PlayerDeathMessages());
        registerEvent(new HighlightDungeonDeathmite());
        registerEvent(new DungeonHideItems());
        registerEvent(new DungeonCopilot());
        registerEvent(new EndermanSlayerBeacon());
        registerEvent(new FireVeilWandParticles());
        registerEvent(new HideMobNames());
        registerEvent(new HideDamageSplash());
        registerEvent(new ThunderSparksHighlight());
        registerEvent(new BlazeSlayerPillar());
        registerEvent(new BlazeSlayerDaggerHelper());
        registerEvent(new HellionShieldHelper());
        registerEvent(new BlazeSlayerFirePitsWarning());
        registerEvent(new BlazeSlayerClearView());
        registerEvent(new PlayerChatFilter());
        registerEvent(new HideArmor());
        registerEvent(new SlayerQuestWarning());
        registerEvent(new StatsTuning());
        registerEvent(new NonGodPotEffectDisplay());
        registerEvent(new HideBlazeParticles());
        registerEvent(new SoopyGuessBurrow());
        registerEvent(new GriffinBurrowHelper());
        registerEvent(new GriffinBurrowParticleFinder());
        registerEvent(new BurrowWarpHelper());

        Commands.INSTANCE.init();

        registerEvent(new LorenzTest());
        registerEvent(new ButtonOnPause());

        configManager = new ConfigManager();
        configManager.firstLoad();
        MinecraftConsoleFilter.Companion.initLogging();

        Runtime.getRuntime().addShutdownHook(new Thread(configManager::saveConfig));

        repo = new RepoManager(configManager.getConfigDirectory());
        repo.loadRepoInformation();
    }

    private void registerEvent(Object object) {
        listenerClasses.add(object);
        String simpleName = object.getClass().getSimpleName();
        consoleLog("SkyHanni registering '" + simpleName + "'");
        long start = System.currentTimeMillis();
        MinecraftForge.EVENT_BUS.register(object);
        long duration = System.currentTimeMillis() - start;
        consoleLog("Done after " + duration + " ms!");
    }

    public static GuiScreen screenToOpen = null;
    private static int screenTicks = 0;

    @SubscribeEvent
    public void onClientTick(TickEvent.ClientTickEvent event) {
        if (screenToOpen != null) {
            screenTicks++;
            if (screenTicks == 5) {
                Minecraft.getMinecraft().displayGuiScreen(screenToOpen);
                screenTicks = 0;
                screenToOpen = null;
            }
        }
    }

    public static void consoleLog(String message) {
        if (logger != null) {
            logger.log(Level.INFO, message);
        } else {
            System.out.println("consoleLog: (" + message + ")");
        }
    }
}