Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backend: Event Objects #2744

Merged
merged 4 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class SkyHanniMod {

CommandRegistrationEvent.post()

PreInitFinishedEvent().post()
PreInitFinishedEvent.post()
}

@Mod.EventHandler
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/at/hannibal2/skyhanni/api/CollectionAPI.kt
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ object CollectionAPI {
val internalName = incorrectCollectionNames[name] ?: NEUInternalName.fromItemName(name)
collectionValue[internalName] = counter
}
CollectionUpdateEvent().postAndCatch()
CollectionUpdateEvent.post()
}

if (inventoryName.endsWith(" Collections")) {
Expand All @@ -83,7 +83,7 @@ object CollectionAPI {
collectionValue[internalName] = counter
}
}
CollectionUpdateEvent().postAndCatch()
CollectionUpdateEvent.post()
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/at/hannibal2/skyhanni/api/FmlEventApi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ object FmlEventApi {

@SubscribeEvent
fun onDisconnect(event: FMLNetworkEvent.ClientDisconnectionFromServerEvent) {
ClientDisconnectEvent().post()
ClientDisconnectEvent.post()
}

@SubscribeEvent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import at.hannibal2.skyhanni.events.EntityMoveEvent
import at.hannibal2.skyhanni.events.IslandChangeEvent
import at.hannibal2.skyhanni.events.LorenzChatEvent
import at.hannibal2.skyhanni.events.LorenzTickEvent
import at.hannibal2.skyhanni.events.LorenzWarpEvent
import at.hannibal2.skyhanni.events.SkyHanniWarpEvent
import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import at.hannibal2.skyhanni.utils.DelayedRun
Expand Down Expand Up @@ -104,7 +104,7 @@ object EntityMovementData {
if (!LorenzUtils.inSkyBlock) return
if (!warpingPattern.matches(event.message)) return
DelayedRun.runNextTick {
LorenzWarpEvent().postAndCatch()
SkyHanniWarpEvent.post()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ object GardenCropMilestones {
crop.setCounter(amount)
}
}
CropMilestoneUpdateEvent().postAndCatch()
CropMilestoneUpdateEvent.post()
GardenCropMilestonesCommunityFix.openInventory(event.inventoryItems)
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/at/hannibal2/skyhanni/data/GuiData.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ object GuiData {

var preDrawEventCancelled = false

@SubscribeEvent(priority = EventPriority.HIGH)
@HandleEvent(priority = HandleEvent.HIGH)
fun onNeuRenderEvent(event: NEURenderEvent) {
if (preDrawEventCancelled) event.cancel()
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ object SackAPI {
ProfileStorageData.sackProfiles?.sackContents = sackData
SkyHanniMod.configManager.saveConfig(ConfigFileType.SACKS, "saving-data")

SackDataUpdateEvent().postAndCatch()
SackDataUpdateEvent.post()
}

data class SackGemstone(
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/at/hannibal2/skyhanni/data/SlayerAPI.kt
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ object SlayerAPI {
}

if (event.message == " §r§a§lSLAYER QUEST COMPLETE!") {
SlayerQuestCompleteEvent().postAndCatch()
SlayerQuestCompleteEvent.post()
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package at.hannibal2.skyhanni.events

class CollectionUpdateEvent : LorenzEvent()
import at.hannibal2.skyhanni.api.event.SkyHanniEvent

object CollectionUpdateEvent : SkyHanniEvent()
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package at.hannibal2.skyhanni.events

class CropMilestoneUpdateEvent : LorenzEvent()
import at.hannibal2.skyhanni.api.event.SkyHanniEvent

object CropMilestoneUpdateEvent : SkyHanniEvent()
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package at.hannibal2.skyhanni.events

class DungeonBossRoomEnterEvent : LorenzEvent()
import at.hannibal2.skyhanni.api.event.SkyHanniEvent

object DungeonBossRoomEnterEvent : SkyHanniEvent()
3 changes: 0 additions & 3 deletions src/main/java/at/hannibal2/skyhanni/events/LorenzWarpEvent.kt

This file was deleted.

5 changes: 2 additions & 3 deletions src/main/java/at/hannibal2/skyhanni/events/NEURenderEvent.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package at.hannibal2.skyhanni.events

import net.minecraftforge.fml.common.eventhandler.Cancelable
import at.hannibal2.skyhanni.api.event.CancellableSkyHanniEvent

@Cancelable
class NEURenderEvent : LorenzEvent()
class NEURenderEvent : CancellableSkyHanniEvent()
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package at.hannibal2.skyhanni.events

class SackDataUpdateEvent : LorenzEvent()
import at.hannibal2.skyhanni.api.event.SkyHanniEvent

object SackDataUpdateEvent : SkyHanniEvent()
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package at.hannibal2.skyhanni.events

import at.hannibal2.skyhanni.api.event.SkyHanniEvent

object SkyHanniWarpEvent : SkyHanniEvent()
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package at.hannibal2.skyhanni.events

class SlayerQuestCompleteEvent : LorenzEvent()
import at.hannibal2.skyhanni.api.event.SkyHanniEvent

object SlayerQuestCompleteEvent : SkyHanniEvent()
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ package at.hannibal2.skyhanni.events.bingo

import at.hannibal2.skyhanni.api.event.SkyHanniEvent

class BingoCardUpdateEvent : SkyHanniEvent()
object BingoCardUpdateEvent : SkyHanniEvent()
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ package at.hannibal2.skyhanni.events.garden.pests

import at.hannibal2.skyhanni.api.event.SkyHanniEvent

class PestUpdateEvent : SkyHanniEvent()
object PestUpdateEvent : SkyHanniEvent()
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ package at.hannibal2.skyhanni.events.minecraft

import at.hannibal2.skyhanni.api.event.SkyHanniEvent

class ClientDisconnectEvent : SkyHanniEvent()
object ClientDisconnectEvent : SkyHanniEvent()
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ package at.hannibal2.skyhanni.events.utils

import at.hannibal2.skyhanni.api.event.SkyHanniEvent

class PreInitFinishedEvent : SkyHanniEvent()
object PreInitFinishedEvent : SkyHanniEvent()
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ object BingoCardReader {
}
BingoAPI.lastBingoCardOpenTime = SimpleTimeMark.now()

BingoCardUpdateEvent().post()
BingoCardUpdateEvent.post()
}

private fun bingoGoalDifference(bingoGoal: BingoGoal, new: Double) {
Expand Down Expand Up @@ -163,7 +163,7 @@ object BingoCardReader {
val goal = BingoAPI.personalGoals.firstOrNull { it.displayName == name } ?: return
goal.done = true
BingoGoalReachedEvent(goal).post()
BingoCardUpdateEvent().post()
BingoCardUpdateEvent.post()
}

private fun BingoData.getDescriptionLine() = "§7" + note.joinToString(" ")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ object DungeonAPI {
val message = rawMessage.removeColor()
val bossName = message.substringAfter("[BOSS] ").substringBefore(":").trim()
if ((bossName != "The Watcher") && dungeonFloor != null && checkBossName(bossName) && !inBossRoom) {
DungeonBossRoomEnterEvent().postAndCatch()
DungeonBossRoomEnterEvent.post()
inBossRoom = true
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package at.hannibal2.skyhanni.features.dungeon

import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.api.event.HandleEvent
import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator
import at.hannibal2.skyhanni.events.CheckRenderEntityEvent
import at.hannibal2.skyhanni.events.DungeonBossRoomEnterEvent
Expand Down Expand Up @@ -133,7 +134,7 @@ object DungeonCopilot {
searchForKey = true
}

@SubscribeEvent
@HandleEvent
fun onDungeonBossRoomEnter(event: DungeonBossRoomEnterEvent) {
changeNextStep("Defeat the boss! Good luck :)")
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package at.hannibal2.skyhanni.features.garden.farming

import at.hannibal2.skyhanni.api.event.HandleEvent
import at.hannibal2.skyhanni.data.GardenCropMilestones.getCounter
import at.hannibal2.skyhanni.events.CropClickEvent
import at.hannibal2.skyhanni.events.CropMilestoneUpdateEvent
Expand Down Expand Up @@ -76,7 +77,7 @@ object CropSpeedMeter {
return list
}

@SubscribeEvent
@HandleEvent
fun onCropMilestoneUpdate(event: CropMilestoneUpdateEvent) {
if (!isEnabled()) return
val counters = mutableMapOf<CropType, Long>()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package at.hannibal2.skyhanni.features.garden.farming

import at.hannibal2.skyhanni.api.event.HandleEvent
import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator
import at.hannibal2.skyhanni.config.features.garden.cropmilestones.CropMilestonesConfig.MilestoneTextEntry
import at.hannibal2.skyhanni.config.features.garden.cropmilestones.CropMilestonesConfig.TimeFormatEntry
Expand Down Expand Up @@ -99,7 +100,7 @@ object GardenCropMilestoneDisplay {
}
}

@SubscribeEvent
@HandleEvent
fun onCropMilestoneUpdate(event: CropMilestoneUpdateEvent) {
needsInventory = false
GardenBestCropTime.updateTimeTillNextCrop()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package at.hannibal2.skyhanni.features.garden.inventory

import at.hannibal2.skyhanni.api.event.HandleEvent
import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator
import at.hannibal2.skyhanni.data.GardenCropMilestones
import at.hannibal2.skyhanni.data.GardenCropMilestones.getCounter
Expand All @@ -24,7 +25,7 @@ object GardenCropMilestoneInventory {
private var average = -1.0
private val config get() = GardenAPI.config

@SubscribeEvent
@HandleEvent
fun onCropMilestoneUpdate(event: CropMilestoneUpdateEvent) {
if (!config.number.averageCropMilestone) return

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ object PestAPI {
private fun updatePests() {
if (!firstScoreboardCheck) return
fixPests()
PestUpdateEvent().post()
PestUpdateEvent.post()
}

@HandleEvent(onlyOnIsland = IslandType.GARDEN)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package at.hannibal2.skyhanni.features.garden.visitor

import at.hannibal2.skyhanni.api.event.HandleEvent
import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator
import at.hannibal2.skyhanni.config.features.garden.visitor.VisitorConfig.HighlightMode
import at.hannibal2.skyhanni.data.IslandType
Expand Down Expand Up @@ -336,7 +337,7 @@ object GardenVisitorFeatures {
}
}

@SubscribeEvent
@HandleEvent
fun onSackUpdate(event: SackDataUpdateEvent) {
update()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import at.hannibal2.skyhanni.events.LorenzKeyPressEvent
import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent
import at.hannibal2.skyhanni.events.LorenzTickEvent
import at.hannibal2.skyhanni.events.LorenzToolTipEvent
import at.hannibal2.skyhanni.events.LorenzWarpEvent
import at.hannibal2.skyhanni.events.SkyHanniWarpEvent
import at.hannibal2.skyhanni.events.RepositoryReloadEvent
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import at.hannibal2.skyhanni.test.command.ErrorManager
Expand Down Expand Up @@ -502,8 +502,8 @@ object TunnelsMaps {
}
}

@SubscribeEvent
fun onLorenzWarp(event: LorenzWarpEvent) {
@HandleEvent
fun onWarp(event: SkyHanniWarpEvent) {
if (!isEnabled()) return
if (goal != null) {
DelayedRun.runNextTick {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package at.hannibal2.skyhanni.features.slayer

import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.api.event.HandleEvent
import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator
import at.hannibal2.skyhanni.config.storage.ProfileSpecificStorage
import at.hannibal2.skyhanni.data.ItemAddManager
Expand Down Expand Up @@ -143,7 +144,7 @@ object SlayerProfitTracker {
}
}

@SubscribeEvent
@HandleEvent
fun onQuestComplete(event: SlayerQuestCompleteEvent) {
getTracker()?.modify {
it.slayerCompletedCount++
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class MixinNEUOverlay {

@Inject(method = "render", at = @At("HEAD"), cancellable = true, remap = false)
private void render(boolean hoverInv, CallbackInfo ci) {
if (new NEURenderEvent().postAndCatch()) {
if (new NEURenderEvent().post()) {
ci.cancel();
}
}
Expand Down
Loading