diff options
author | Roman / Linnea Gräf <nea@nea.moe> | 2023-04-28 23:17:15 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-28 23:17:15 +0200 |
commit | 5985f6f22a41cfe61c6d3616f4916039e7bce459 (patch) | |
tree | 0dc6ec3ed43cb3a0000f460d03f140b591ebdc86 /src/main/java/at | |
parent | fb6ab0c95b805617898123a393347b17d7eb2bb9 (diff) | |
download | skyhanni-5985f6f22a41cfe61c6d3616f4916039e7bce459.tar.gz skyhanni-5985f6f22a41cfe61c6d3616f4916039e7bce459.tar.bz2 skyhanni-5985f6f22a41cfe61c6d3616f4916039e7bce459.zip |
Transform Main class to use kotlin (#74)
Diffstat (limited to 'src/main/java/at')
10 files changed, 344 insertions, 351 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java deleted file mode 100644 index 97e90936a..000000000 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java +++ /dev/null @@ -1,338 +0,0 @@ -package at.hannibal2.skyhanni; - -import at.hannibal2.skyhanni.api.CollectionAPI; -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.anvil.AnvilCombineHelper; -import at.hannibal2.skyhanni.features.bazaar.BazaarApi; -import at.hannibal2.skyhanni.features.bazaar.BazaarBestSellMethod; -import at.hannibal2.skyhanni.features.bazaar.BazaarCancelledBuyOrderClipboard; -import at.hannibal2.skyhanni.features.bazaar.BazaarOrderHelper; -import at.hannibal2.skyhanni.features.bingo.BingoCardDisplay; -import at.hannibal2.skyhanni.features.bingo.BingoNextStepHelper; -import at.hannibal2.skyhanni.features.bingo.CompactBingoChat; -import at.hannibal2.skyhanni.features.bingo.MinionCraftHelper; -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.PlayerChatModifier; -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.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.*; -import at.hannibal2.skyhanni.features.garden.*; -import at.hannibal2.skyhanni.features.garden.composter.ComposterDisplay; -import at.hannibal2.skyhanni.features.garden.composter.ComposterInventoryNumbers; -import at.hannibal2.skyhanni.features.garden.composter.ComposterOverlay; -import at.hannibal2.skyhanni.features.garden.composter.GardenComposterInventoryFeatures; -import at.hannibal2.skyhanni.features.garden.contest.FarmingContestAPI; -import at.hannibal2.skyhanni.features.garden.contest.JacobContestFFNeededDisplay; -import at.hannibal2.skyhanni.features.garden.contest.JacobFarmingContestsInventory; -import at.hannibal2.skyhanni.features.garden.farming.*; -import at.hannibal2.skyhanni.features.garden.inventory.*; -import at.hannibal2.skyhanni.features.garden.visitor.GardenVisitorColorNames; -import at.hannibal2.skyhanni.features.garden.visitor.GardenVisitorFeatures; -import at.hannibal2.skyhanni.features.garden.visitor.GardenVisitorTimer; -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.MinionCollectLogic; -import at.hannibal2.skyhanni.features.minion.MinionFeatures; -import at.hannibal2.skyhanni.features.misc.*; -import at.hannibal2.skyhanni.features.misc.discordrpc.DiscordRPCManager; -import at.hannibal2.skyhanni.features.misc.tiarelay.TiaRelayHelper; -import at.hannibal2.skyhanni.features.misc.tiarelay.TiaRelayWaypoints; -import at.hannibal2.skyhanni.features.misc.update.UpdateManager; -import at.hannibal2.skyhanni.features.mobs.AreaMiniBossFeatures; -import at.hannibal2.skyhanni.features.mobs.AshfangMinisNametagHider; -import at.hannibal2.skyhanni.features.mobs.MobHighlight; -import at.hannibal2.skyhanni.features.nether.ashfang.*; -import at.hannibal2.skyhanni.features.nether.reputationhelper.CrimsonIsleReputationHelper; -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.BlazeSlayerClearView; -import at.hannibal2.skyhanni.features.slayer.blaze.BlazeSlayerDaggerHelper; -import at.hannibal2.skyhanni.features.slayer.blaze.BlazeSlayerFirePitsWarning; -import at.hannibal2.skyhanni.features.slayer.blaze.HellionShieldHelper; -import at.hannibal2.skyhanni.features.summonings.SummoningMobManager; -import at.hannibal2.skyhanni.features.summonings.SummoningSoulsName; -import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper; -import at.hannibal2.skyhanni.test.LorenzTest; -import at.hannibal2.skyhanni.test.PacketTest; -import at.hannibal2.skyhanni.utils.MinecraftConsoleFilter; -import at.hannibal2.skyhanni.utils.NEUVersionCheck; -import at.hannibal2.skyhanni.utils.TabListData; -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.Loader; -import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.common.Mod.EventHandler; -import net.minecraftforge.fml.common.event.FMLInitializationEvent; -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, clientSideOnly = true, useMetadata = true, - guiFactory = "at.hannibal2.skyhanni.config.ConfigGuiForgeInterop" -) -public class SkyHanniMod { - - public static final String MODID = "skyhanni"; - - public static String getVersion() { - return Loader.instance().getIndexedModList().get(MODID).getVersion(); - } - - public static Features feature; - - public static RepoManager repo; - public static ConfigManager configManager; - private static Logger logger; - public static org.slf4j.Logger getLogger(String name) { - return org.slf4j.LoggerFactory.getLogger("SkyHanni." + name); - } - - public static List<Object> modules = 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) { - NEUVersionCheck.checkIfNeuIsLoaded(); - - logger = LogManager.getLogger("SkyHanni"); - - // utils - loadModule(this); - loadModule(new ChatManager()); - loadModule(new HypixelData()); - loadModule(new DungeonData()); - loadModule(new ScoreboardData()); - loadModule(new ApiDataLoader()); - loadModule(new SeaCreatureManager()); - loadModule(new ItemRenderBackground()); - loadModule(new EntityData()); - loadModule(new EntityMovementData()); - loadModule(new ItemClickData()); - loadModule(new MinecraftData()); - loadModule(new TitleUtils()); - loadModule(new ItemTipHelper()); - loadModule(new RenderLivingEntityHelper()); - loadModule(new SkillExperience()); - loadModule(new OtherInventoryData()); - loadModule(new TabListData()); - loadModule(new RenderGuiData()); - loadModule(new GardenCropMilestones()); - loadModule(new GardenCropUpgrades()); - loadModule(new OwnInventoryData()); - loadModule(new ToolTipData()); - loadModule(new GuiEditManager()); - loadModule(UpdateManager.INSTANCE); - loadModule(new CropAccessoryData()); - loadModule(new MayorElection()); - loadModule(new GardenComposterUpgradesData()); - loadModule(new ActionBarStatsData()); - loadModule(new GardenCropMilestoneAverage()); - loadModule(GardenCropSpeed.INSTANCE); - - // APIs - loadModule(new BazaarApi()); - loadModule(GardenAPI.INSTANCE); - loadModule(new CollectionAPI()); - loadModule(FarmingContestAPI.INSTANCE); - - // features - loadModule(new BazaarOrderHelper()); - loadModule(new AuctionsHighlighter()); - loadModule(new ChatFilter()); - loadModule(new PlayerChatModifier()); - loadModule(new DungeonChatFilter()); - loadModule(new HideNotClickableItems()); - loadModule(new ItemDisplayOverlayFeatures()); - loadModule(new CurrentPetDisplay()); - loadModule(new ExpBottleOnGroundHider()); - loadModule(new DamageIndicatorManager()); - loadModule(new ItemAbilityCooldown()); - loadModule(new DungeonHighlightClickedBlocks()); - loadModule(new DungeonMilestonesDisplay()); - loadModule(new DungeonDeathCounter()); - loadModule(new DungeonCleanEnd()); - loadModule(new DungeonBossMessages()); - loadModule(new DungeonBossHideDamageSplash()); - loadModule(new TrophyFishMessages()); - loadModule(new BazaarBestSellMethod()); - loadModule(new AnvilCombineHelper()); - loadModule(new SeaCreatureMessageShortener()); -// registerEvent(new GriffinBurrowFinder()); - loadModule(new AshfangFreezeCooldown()); - loadModule(new AshfangNextResetCooldown()); - loadModule(new SummoningSoulsName()); - loadModule(new AshfangGravityOrbs()); - loadModule(new AshfangBlazingSouls()); - loadModule(new AshfangBlazes()); - loadModule(new AshfangHideParticles()); - loadModule(new AshfangHideDamageIndicator()); - loadModule(new ItemStars()); - loadModule(new MinionFeatures()); - loadModule(new RealTime()); - loadModule(new RngMeterInventory()); - loadModule(new WikiCommand()); - loadModule(new SummoningMobManager()); - loadModule(new AreaMiniBossFeatures()); - loadModule(new MobHighlight()); - loadModule(new MarkedPlayerManager()); - loadModule(new HighlightSlayerMiniBoss()); - loadModule(new PlayerDeathMessages()); - loadModule(new HighlightDungeonDeathmite()); - loadModule(new DungeonHideItems()); - loadModule(new DungeonCopilot()); - loadModule(new EndermanSlayerBeacon()); - loadModule(new FireVeilWandParticles()); - loadModule(new HideMobNames()); - loadModule(new HideDamageSplash()); - loadModule(new ThunderSparksHighlight()); - loadModule(new BlazeSlayerDaggerHelper()); - loadModule(new HellionShieldHelper()); - loadModule(new BlazeSlayerFirePitsWarning()); - loadModule(new BlazeSlayerClearView()); - loadModule(new PlayerChatFilter()); - loadModule(new HideArmor()); - loadModule(new SlayerQuestWarning()); - loadModule(new StatsTuning()); - loadModule(new NonGodPotEffectDisplay()); - loadModule(new SoopyGuessBurrow()); - loadModule(new GriffinBurrowHelper()); - loadModule(new GriffinBurrowParticleFinder()); - loadModule(new BurrowWarpHelper()); - loadModule(new CollectionCounter()); - loadModule(new HighlightBonzoMasks()); - loadModule(new DungeonLevelColor()); - loadModule(new BazaarCancelledBuyOrderClipboard()); - loadModule(new CompactSplashPotionMessage()); - loadModule(new CroesusUnopenedChestTracker()); - loadModule(new CompactBingoChat()); - loadModule(new BrewingStandOverlay()); - loadModule(new BarnFishingTimer()); - loadModule(new CrimsonIsleReputationHelper(this)); - loadModule(new SharkFishCounter()); - loadModule(new SkyBLockLevelGuideHelper()); - loadModule(new OdgerWaypoint()); - loadModule(new TiaRelayHelper()); - loadModule(new TiaRelayWaypoints()); - loadModule(new BingoCardDisplay()); - loadModule(new BingoNextStepHelper()); - loadModule(new MinionCraftHelper()); - loadModule(new TpsCounter()); - loadModule(new ParticleHider()); - loadModule(new MiscFeatures()); - loadModule(new SkyMartCopperPrice()); - loadModule(new GardenVisitorFeatures()); - loadModule(new GardenInventoryNumbers()); - loadModule(new GardenVisitorTimer()); - loadModule(new GardenNextPlotPrice()); - loadModule(GardenCropMilestoneDisplay.INSTANCE); - loadModule(GardenCustomKeybinds.INSTANCE); - loadModule(new ChickenHeadTimer()); - loadModule(new GardenOptimalSpeed()); - loadModule(new GardenDeskInSBMenu()); - loadModule(new GardenLevelDisplay()); - loadModule(new EliteFarmingWeight()); - loadModule(new DicerRngDropCounter()); - loadModule(new CropMoneyDisplay()); - loadModule(new JacobFarmingContestsInventory()); - loadModule(new GardenNextJacobContest()); - loadModule(new WrongFungiCutterWarning()); - loadModule(new FarmingArmorDrops()); - loadModule(new JoinCrystalHollows()); - loadModule(new GardenVisitorColorNames()); - loadModule(new GardenTeleportPadCompactName()); - loadModule(new AnitaMedalProfit()); - loadModule(new ComposterDisplay()); - loadModule(new GardenComposterInventoryFeatures()); - loadModule(new MinionCollectLogic()); - loadModule(new PasteIntoSigns()); - loadModule(new EstimatedItemValue()); - loadModule(new ComposterInventoryNumbers()); - loadModule(new FarmingFortuneDisplay()); - loadModule(new ToolTooltipTweaks()); - loadModule(new CropSpeedMeter()); - loadModule(new AshfangMinisNametagHider()); - loadModule(new GardenTeleportPadInventoryNumber()); - loadModule(new ComposterOverlay()); - loadModule(new DiscordRPCManager()); - loadModule(new GardenCropMilestoneFix()); - loadModule(new GardenBurrowingSporesNotifier()); - loadModule(new WildStrawberryDyeNotification()); - loadModule(new JacobContestFFNeededDisplay()); - - Commands.INSTANCE.init(); - - loadModule(new LorenzTest()); - loadModule(new ButtonOnPause()); - loadModule(new PacketTest()); - - } - - @EventHandler - public void init(FMLInitializationEvent event) { - configManager = new ConfigManager(); - configManager.firstLoad(); - - MinecraftConsoleFilter.Companion.initLogging(); - - Runtime.getRuntime().addShutdownHook(new Thread(() -> configManager.saveConfig("shutdown-hook"))); - - repo = new RepoManager(configManager.getConfigDirectory()); - repo.loadRepoInformation(); - } - - public void loadModule(Object object) { - modules.add(object); - MinecraftForge.EVENT_BUS.register(object); - } - - 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 + ")"); - } - } -}
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt new file mode 100644 index 000000000..885a8093e --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -0,0 +1,324 @@ +package at.hannibal2.skyhanni + +import at.hannibal2.skyhanni.api.CollectionAPI +import at.hannibal2.skyhanni.config.ConfigManager +import at.hannibal2.skyhanni.config.Features +import at.hannibal2.skyhanni.config.commands.Commands.init +import at.hannibal2.skyhanni.data.* +import at.hannibal2.skyhanni.data.repo.RepoManager +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.BazaarCancelledBuyOrderClipboard +import at.hannibal2.skyhanni.features.bazaar.BazaarOrderHelper +import at.hannibal2.skyhanni.features.bingo.BingoCardDisplay +import at.hannibal2.skyhanni.features.bingo.BingoNextStepHelper +import at.hannibal2.skyhanni.features.bingo.CompactBingoChat +import at.hannibal2.skyhanni.features.bingo.MinionCraftHelper +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.PlayerChatModifier +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.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.* +import at.hannibal2.skyhanni.features.garden.* +import at.hannibal2.skyhanni.features.garden.composter.ComposterDisplay +import at.hannibal2.skyhanni.features.garden.composter.ComposterInventoryNumbers +import at.hannibal2.skyhanni.features.garden.composter.ComposterOverlay +import at.hannibal2.skyhanni.features.garden.composter.GardenComposterInventoryFeatures +import at.hannibal2.skyhanni.features.garden.contest.FarmingContestAPI +import at.hannibal2.skyhanni.features.garden.contest.JacobContestFFNeededDisplay +import at.hannibal2.skyhanni.features.garden.contest.JacobFarmingContestsInventory +import at.hannibal2.skyhanni.features.garden.farming.* +import at.hannibal2.skyhanni.features.garden.inventory.* +import at.hannibal2.skyhanni.features.garden.visitor.GardenVisitorColorNames +import at.hannibal2.skyhanni.features.garden.visitor.GardenVisitorFeatures +import at.hannibal2.skyhanni.features.garden.visitor.GardenVisitorTimer +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.MinionCollectLogic +import at.hannibal2.skyhanni.features.minion.MinionFeatures +import at.hannibal2.skyhanni.features.misc.* +import at.hannibal2.skyhanni.features.misc.discordrpc.DiscordRPCManager +import at.hannibal2.skyhanni.features.misc.tiarelay.TiaRelayHelper +import at.hannibal2.skyhanni.features.misc.tiarelay.TiaRelayWaypoints +import at.hannibal2.skyhanni.features.misc.update.UpdateManager +import at.hannibal2.skyhanni.features.mobs.AreaMiniBossFeatures +import at.hannibal2.skyhanni.features.mobs.AshfangMinisNametagHider +import at.hannibal2.skyhanni.features.mobs.MobHighlight +import at.hannibal2.skyhanni.features.nether.ashfang.* +import at.hannibal2.skyhanni.features.nether.reputationhelper.CrimsonIsleReputationHelper +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.BlazeSlayerClearView +import at.hannibal2.skyhanni.features.slayer.blaze.BlazeSlayerDaggerHelper +import at.hannibal2.skyhanni.features.slayer.blaze.BlazeSlayerFirePitsWarning +import at.hannibal2.skyhanni.features.slayer.blaze.HellionShieldHelper +import at.hannibal2.skyhanni.features.summonings.SummoningMobManager +import at.hannibal2.skyhanni.features.summonings.SummoningSoulsName +import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper +import at.hannibal2.skyhanni.test.LorenzTest +import at.hannibal2.skyhanni.test.PacketTest +import at.hannibal2.skyhanni.utils.MinecraftConsoleFilter.Companion.initLogging +import at.hannibal2.skyhanni.utils.NEUVersionCheck.checkIfNeuIsLoaded +import at.hannibal2.skyhanni.utils.TabListData +import kotlinx.coroutines.CoroutineName +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Job +import kotlinx.coroutines.SupervisorJob +import net.minecraft.client.Minecraft +import net.minecraft.client.gui.GuiScreen +import net.minecraftforge.common.MinecraftForge +import net.minecraftforge.fml.common.Loader +import net.minecraftforge.fml.common.Mod +import net.minecraftforge.fml.common.event.FMLInitializationEvent +import net.minecraftforge.fml.common.event.FMLPreInitializationEvent +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent +import org.apache.logging.log4j.Level +import org.apache.logging.log4j.LogManager +import org.apache.logging.log4j.Logger + +@Mod( + modid = SkyHanniMod.MODID, + clientSideOnly = true, + useMetadata = true, + guiFactory = "at.hannibal2.skyhanni.config.ConfigGuiForgeInterop" +) +class SkyHanniMod { + @Mod.EventHandler + fun preInit(event: FMLPreInitializationEvent?) { + checkIfNeuIsLoaded() + + // utils + loadModule(this) + loadModule(ChatManager()) + loadModule(HypixelData()) + loadModule(DungeonData()) + loadModule(ScoreboardData()) + loadModule(ApiDataLoader()) + loadModule(SeaCreatureManager()) + loadModule(ItemRenderBackground()) + loadModule(EntityData()) + loadModule(EntityMovementData()) + loadModule(ItemClickData()) + loadModule(MinecraftData()) + loadModule(TitleUtils()) + loadModule(ItemTipHelper()) + loadModule(RenderLivingEntityHelper()) + loadModule(SkillExperience()) + loadModule(OtherInventoryData()) + loadModule(TabListData()) + loadModule(RenderGuiData()) + loadModule(GardenCropMilestones()) + loadModule(GardenCropUpgrades()) + loadModule(OwnInventoryData()) + loadModule(ToolTipData()) + loadModule(GuiEditManager()) + loadModule(UpdateManager) + loadModule(CropAccessoryData()) + loadModule(MayorElection()) + loadModule(GardenComposterUpgradesData()) + loadModule(ActionBarStatsData()) + loadModule(GardenCropMilestoneAverage()) + loadModule(GardenCropSpeed) + + // APIs + loadModule(BazaarApi()) + loadModule(GardenAPI) + loadModule(CollectionAPI()) + loadModule(FarmingContestAPI) + + // features + loadModule(BazaarOrderHelper()) + loadModule(AuctionsHighlighter()) + loadModule(ChatFilter()) + loadModule(PlayerChatModifier()) + loadModule(DungeonChatFilter()) + loadModule(HideNotClickableItems()) + loadModule(ItemDisplayOverlayFeatures()) + loadModule(CurrentPetDisplay()) + loadModule(ExpBottleOnGroundHider()) + loadModule(DamageIndicatorManager()) + loadModule(ItemAbilityCooldown()) + loadModule(DungeonHighlightClickedBlocks()) + loadModule(DungeonMilestonesDisplay()) + loadModule(DungeonDeathCounter()) + loadModule(DungeonCleanEnd()) + loadModule(DungeonBossMessages()) + loadModule(DungeonBossHideDamageSplash()) + loadModule(TrophyFishMessages()) + loadModule(BazaarBestSellMethod()) + loadModule(AnvilCombineHelper()) + loadModule(SeaCreatureMessageShortener()) + // registerEvent(new GriffinBurrowFinder()); + loadModule(AshfangFreezeCooldown()) + loadModule(AshfangNextResetCooldown()) + loadModule(SummoningSoulsName()) + loadModule(AshfangGravityOrbs()) + loadModule(AshfangBlazingSouls()) + loadModule(AshfangBlazes()) + loadModule(AshfangHideParticles()) + loadModule(AshfangHideDamageIndicator()) + loadModule(ItemStars()) + loadModule(MinionFeatures()) + loadModule(RealTime()) + loadModule(RngMeterInventory()) + loadModule(WikiCommand()) + loadModule(SummoningMobManager()) + loadModule(AreaMiniBossFeatures()) + loadModule(MobHighlight()) + loadModule(MarkedPlayerManager()) + loadModule(HighlightSlayerMiniBoss()) + loadModule(PlayerDeathMessages()) + loadModule(HighlightDungeonDeathmite()) + loadModule(DungeonHideItems()) + loadModule(DungeonCopilot()) + loadModule(EndermanSlayerBeacon()) + loadModule(FireVeilWandParticles()) + loadModule(HideMobNames()) + loadModule(HideDamageSplash()) + loadModule(ThunderSparksHighlight()) + loadModule(BlazeSlayerDaggerHelper()) + loadModule(HellionShieldHelper()) + loadModule(BlazeSlayerFirePitsWarning()) + loadModule(BlazeSlayerClearView()) + loadModule(PlayerChatFilter()) + loadModule(HideArmor()) + loadModule(SlayerQuestWarning()) + loadModule(StatsTuning()) + loadModule(NonGodPotEffectDisplay()) + loadModule(SoopyGuessBurrow()) + loadModule(GriffinBurrowHelper()) + loadModule(GriffinBurrowParticleFinder()) + loadModule(BurrowWarpHelper()) + loadModule(CollectionCounter()) + loadModule(HighlightBonzoMasks()) + loadModule(DungeonLevelColor()) + loadModule(BazaarCancelledBuyOrderClipboard()) + loadModule(CompactSplashPotionMessage()) + loadModule(CroesusUnopenedChestTracker()) + loadModule(CompactBingoChat()) + loadModule(BrewingStandOverlay()) + loadModule(BarnFishingTimer()) + loadModule(CrimsonIsleReputationHelper(this)) + loadModule(SharkFishCounter()) + loadModule(SkyBLockLevelGuideHelper()) + loadModule(OdgerWaypoint()) + loadModule(TiaRelayHelper()) + loadModule(TiaRelayWaypoints()) + loadModule(BingoCardDisplay()) + loadModule(BingoNextStepHelper()) + loadModule(MinionCraftHelper()) + loadModule(TpsCounter()) + loadModule(ParticleHider()) + loadModule(MiscFeatures()) + loadModule(SkyMartCopperPrice()) + loadModule(GardenVisitorFeatures()) + loadModule(GardenInventoryNumbers()) + loadModule(GardenVisitorTimer()) + loadModule(GardenNextPlotPrice()) + loadModule(GardenCropMilestoneDisplay) + loadModule(GardenCustomKeybinds) + loadModule(ChickenHeadTimer()) + loadModule(GardenOptimalSpeed()) + loadModule(GardenDeskInSBMenu()) + loadModule(GardenLevelDisplay()) + loadModule(EliteFarmingWeight()) + loadModule(DicerRngDropCounter()) + loadModule(CropMoneyDisplay()) + loadModule(JacobFarmingContestsInventory()) + loadModule(GardenNextJacobContest()) + loadModule(WrongFungiCutterWarning()) + loadModule(FarmingArmorDrops()) + loadModule(JoinCrystalHollows()) + loadModule(GardenVisitorColorNames()) + loadModule(GardenTeleportPadCompactName()) + loadModule(AnitaMedalProfit()) + loadModule(ComposterDisplay()) + loadModule(GardenComposterInventoryFeatures()) + loadModule(MinionCollectLogic()) + loadModule(PasteIntoSigns()) + loadModule(EstimatedItemValue()) + loadModule(ComposterInventoryNumbers()) + loadModule(FarmingFortuneDisplay()) + loadModule(ToolTooltipTweaks()) + loadModule(CropSpeedMeter()) + loadModule(AshfangMinisNametagHider()) + loadModule(GardenTeleportPadInventoryNumber()) + loadModule(ComposterOverlay()) + loadModule(DiscordRPCManager()) + loadModule(GardenCropMilestoneFix()) + loadModule(GardenBurrowingSporesNotifier()) + loadModule(WildStrawberryDyeNotification()) + loadModule(JacobContestFFNeededDisplay()) + init() + loadModule(LorenzTest()) + loadModule(ButtonOnPause()) + loadModule(PacketTest()) + } + + @Mod.EventHandler + fun init(event: FMLInitializationEvent?) { + configManager = ConfigManager() + configManager.firstLoad() + initLogging() + Runtime.getRuntime().addShutdownHook(Thread { configManager.saveConfig("shutdown-hook") }) + repo = RepoManager(configManager.configDirectory) + repo.loadRepoInformation() + } + + fun loadModule(obj: Any) { + modules.add(obj) + MinecraftForge.EVENT_BUS.register(obj) + } + + @SubscribeEvent + fun onClientTick(event: ClientTickEvent?) { + if (screenToOpen != null) { + screenTicks++ + if (screenTicks == 5) { + Minecraft.getMinecraft().displayGuiScreen(screenToOpen) + screenTicks = 0 + screenToOpen = null + } + } + } + + companion object { + const val MODID = "skyhanni" + + @JvmStatic + val version: String + get() = Loader.instance().indexedModList[MODID]!!.version + + @JvmStatic + val feature: Features get() = configManager.features + lateinit var repo: RepoManager + lateinit var configManager: ConfigManager + val logger: Logger = LogManager.getLogger("SkyHanni") + fun getLogger(name: String): Logger { + return LogManager.getLogger("SkyHanni.$name") + } + + val modules: MutableList<Any> = ArrayList() + val globalJob: Job = Job(null) + val coroutineScope = CoroutineScope( + CoroutineName("SkyHanni") + SupervisorJob(globalJob) + ) + var screenToOpen: GuiScreen? = null + private var screenTicks = 0 + fun consoleLog(message: String) { + logger.log(Level.INFO, message) + } + } +}
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt b/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt index 4218eabc5..0855a4855 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt @@ -22,13 +22,18 @@ class ConfigManager { .create() } - val logger = LorenzLogger("config_manager") + lateinit var features: Features + private set + private val logger = LorenzLogger("config_manager") var configDirectory = File("config/skyhanni") private var configFile: File? = null lateinit var processor: MoulConfigProcessor<Features> fun firstLoad() { + if (::features.isInitialized) { + logger.log("Loading config despite config being already loaded?") + } configDirectory.mkdir() configFile = File(configDirectory, "config.json") @@ -52,7 +57,7 @@ class ConfigManager { logger.log("load-config-now") - SkyHanniMod.feature = gson.fromJson( + features = gson.fromJson( builder.toString(), Features::class.java ) @@ -72,9 +77,9 @@ class ConfigManager { } } - if (SkyHanniMod.feature == null) { + if (::features.isInitialized) { logger.log("Creating blank config and saving to file") - SkyHanniMod.feature = Features() + features = Features() saveConfig("blank config") } diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordRPCManager.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordRPCManager.kt index c5dfcdff2..7b4ded2a2 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordRPCManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordRPCManager.kt @@ -2,7 +2,9 @@ package at.hannibal2.skyhanni.features.misc.discordrpc // This entire file was taken from SkyblockAddons code, ported to SkyHanni -import at.hannibal2.skyhanni.SkyHanniMod.* +import at.hannibal2.skyhanni.SkyHanniMod.Companion.consoleLog +import at.hannibal2.skyhanni.SkyHanniMod.Companion.coroutineScope +import at.hannibal2.skyhanni.SkyHanniMod.Companion.feature import at.hannibal2.skyhanni.events.ConfigLoadEvent import at.hannibal2.skyhanni.utils.LorenzUtils import com.google.gson.JsonObject diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/update/UpdateManager.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/update/UpdateManager.kt index 10a93753a..fc97a4b51 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/update/UpdateManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/update/UpdateManager.kt @@ -49,7 +49,7 @@ object UpdateManager { } fun getCurrentVersion(): String { - return SkyHanniMod.getVersion() + return SkyHanniMod.version } fun injectConfigProcessor(processor: MoulConfigProcessor<*>) { @@ -114,7 +114,7 @@ object UpdateManager { val context = UpdateContext( UpdateSource.githubUpdateSource("hannibal002", "Skyhanni"), UpdateTarget.deleteAndSaveInTheSameFolder(UpdateManager::class.java), - CurrentVersion.ofTag(SkyHanniMod.getVersion()), + CurrentVersion.ofTag(SkyHanniMod.version), SkyHanniMod.MODID, ) diff --git a/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinBlockFire.java b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinBlockFire.java index 0d043ad0d..3dfc0c22f 100644 --- a/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinBlockFire.java +++ b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinBlockFire.java @@ -13,7 +13,7 @@ public class MixinBlockFire { @Redirect(method = "randomDisplayTick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;spawnParticle(Lnet/minecraft/util/EnumParticleTypes;DDDDDD[I)V")) private void onLivingUpdate(World world, EnumParticleTypes particleType, double x, double y, double z, double xOffset, double yOffset, double zOffset, int[] p_175688_14_) { - if (!SkyHanniMod.feature.misc.hideFireBlockParticles) { + if (!SkyHanniMod.getFeature().misc.hideFireBlockParticles) { world.spawnParticle(particleType, x, y, z, xOffset, yOffset, zOffset, p_175688_14_); } } diff --git a/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinEntityBlaze.java b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinEntityBlaze.java index 60dd87e83..7c21efa9f 100644 --- a/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinEntityBlaze.java +++ b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinEntityBlaze.java @@ -13,7 +13,7 @@ public class MixinEntityBlaze { @Redirect(method = "onLivingUpdate", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;spawnParticle(Lnet/minecraft/util/EnumParticleTypes;DDDDDD[I)V")) private void onLivingUpdate(World world, EnumParticleTypes particleType, double x, double y, double z, double xOffset, double yOffset, double zOffset, int[] p_175688_14_) { - if (!SkyHanniMod.feature.misc.hideBlazeParticles) { + if (!SkyHanniMod.getFeature().misc.hideBlazeParticles) { world.spawnParticle(particleType, x, y, z, xOffset, yOffset, zOffset, p_175688_14_); } } diff --git a/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinEntityFireball.java b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinEntityFireball.java index 1783cd791..bf4f48171 100644 --- a/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinEntityFireball.java +++ b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinEntityFireball.java @@ -13,7 +13,7 @@ public class MixinEntityFireball { @Redirect(method = "onUpdate", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;spawnParticle(Lnet/minecraft/util/EnumParticleTypes;DDDDDD[I)V")) private void onLivingUpdate(World world, EnumParticleTypes particleType, double x, double y, double z, double xOffset, double yOffset, double zOffset, int[] p_175688_14_) { - if (!SkyHanniMod.feature.misc.hideFireballParticles) { + if (!SkyHanniMod.getFeature().misc.hideFireballParticles) { world.spawnParticle(particleType, x, y, z, xOffset, yOffset, zOffset, p_175688_14_); } } diff --git a/src/main/java/at/hannibal2/skyhanni/mixins/transformers/gui/MixinGuiNewChat.java b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/gui/MixinGuiNewChat.java index bdc0b01c2..380963554 100644 --- a/src/main/java/at/hannibal2/skyhanni/mixins/transformers/gui/MixinGuiNewChat.java +++ b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/gui/MixinGuiNewChat.java @@ -14,9 +14,9 @@ public class MixinGuiNewChat { @Inject(method = "getChatOpen", at = @At("HEAD"), cancellable = true) public void onIsOpen(CallbackInfoReturnable<Boolean> cir) { - if (SkyHanniMod.feature.chat.peekChat > Keyboard.KEY_NONE + if (SkyHanniMod.getFeature().chat.peekChat > Keyboard.KEY_NONE && Minecraft.getMinecraft().thePlayer != null - && Keyboard.isKeyDown(SkyHanniMod.feature.chat.peekChat)) + && Keyboard.isKeyDown(SkyHanniMod.getFeature().chat.peekChat)) cir.setReturnValue(true); } } diff --git a/src/main/java/at/hannibal2/skyhanni/utils/APIUtil.kt b/src/main/java/at/hannibal2/skyhanni/utils/APIUtil.kt index 4ad48b40d..e1763f7d5 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/APIUtil.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/APIUtil.kt @@ -22,7 +22,7 @@ object APIUtil { private var showApiErrors = false val builder: HttpClientBuilder = - HttpClients.custom().setUserAgent("SkyHanni/${SkyHanniMod.getVersion()}") + HttpClients.custom().setUserAgent("SkyHanni/${SkyHanniMod.version}") .setDefaultHeaders( mutableListOf( BasicHeader("Pragma", "no-cache"), |