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: Replace lorenevent with skyhanni event #2750

Closed
wants to merge 46 commits into from
Closed
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
fcb5be6
Changes by Cal
NopoTheGamer Oct 17, 2024
31653e3
Changes by Cal
NopoTheGamer Oct 17, 2024
d00522b
fix more
NopoTheGamer Oct 17, 2024
240335e
Changes by Cal
NopoTheGamer Oct 17, 2024
782e8df
cal made my game not launch
NopoTheGamer Oct 17, 2024
f1e787b
2
NopoTheGamer Oct 17, 2024
8be81df
make the game launch
NopoTheGamer Oct 17, 2024
7f218d1
remove loren event
NopoTheGamer Oct 17, 2024
7d0155b
imports
CalMWolfs Oct 17, 2024
27c4831
imports x2
CalMWolfs Oct 17, 2024
6d3897b
moon
NopoTheGamer Oct 17, 2024
bdcfee0
imports x3
CalMWolfs Oct 17, 2024
a283e31
imports x4 (the final one)
CalMWolfs Oct 17, 2024
4417e1a
fix pre process
NopoTheGamer Oct 17, 2024
2ba9736
use in dev env from platform utils
NopoTheGamer Oct 17, 2024
181f841
use in dev env from platform utils
NopoTheGamer Oct 17, 2024
4a32cdf
change comment back
NopoTheGamer Oct 17, 2024
2d1f231
Backend: Migrate some events to be GenericSkyHanniEvent
CalMWolfs Oct 17, 2024
9d19202
EntityMoveEvent
CalMWolfs Oct 17, 2024
94c574e
wrongly removed
CalMWolfs Oct 17, 2024
99e7dbe
EntityEquipmentChangeEvent
CalMWolfs Oct 18, 2024
6ba4e5d
EntityDisplayNameEvent & EntityCustomNameUpdateEvent & DataWatcherUpd…
CalMWolfs Oct 18, 2024
0818741
formatting
CalMWolfs Oct 18, 2024
a40c62c
maerge
NopoTheGamer Oct 18, 2024
2924ec4
localPlayer
CalMWolfs Oct 18, 2024
3c014d9
Merge branch 'refs/heads/generic-event' into events
CalMWolfs Oct 18, 2024
897cc79
Backend: Add in event handler check to SkyHanni Events
CalMWolfs Oct 18, 2024
e5be14c
Merge branch 'refs/heads/in-event-handler' into events
CalMWolfs Oct 18, 2024
ddf5c3c
fix 1 thing
CalMWolfs Oct 20, 2024
c0d4dfa
Merge remote-tracking branch 'refs/remotes/hannibald/beta' into events
NopoTheGamer Oct 22, 2024
f79e605
fix merge
NopoTheGamer Oct 22, 2024
5947475
fix merge 2
NopoTheGamer Oct 22, 2024
e5b2015
fix merge 3
NopoTheGamer Oct 22, 2024
da94e83
fix update manaer
NopoTheGamer Oct 22, 2024
71c8bf3
remove string
NopoTheGamer Oct 22, 2024
3eda840
Merge remote-tracking branch 'refs/remotes/hannibald/beta' into events
NopoTheGamer Oct 23, 2024
52c3776
fix yap bot 50000
NopoTheGamer Oct 23, 2024
0ecedb4
fix yap bot 50001
NopoTheGamer Oct 23, 2024
22fec7a
fix yap bot 60000
NopoTheGamer Oct 23, 2024
7724a83
Merge remote-tracking branch 'refs/remotes/hannibald/beta' into events
NopoTheGamer Oct 23, 2024
9c6c00d
yap bot 198274901
CalMWolfs Oct 23, 2024
a223ea2
Merge remote-tracking branch 'refs/remotes/hannibald/beta' into events
NopoTheGamer Oct 26, 2024
dc601c0
Merge remote-tracking branch 'refs/remotes/hannibald/beta' into events
NopoTheGamer Oct 27, 2024
6fb8be9
fix merge
NopoTheGamer Oct 27, 2024
3ac3944
Merge remote-tracking branch 'refs/remotes/hannibald/beta' into events
NopoTheGamer Oct 27, 2024
5e53a40
fix merge
NopoTheGamer Oct 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
8 changes: 4 additions & 4 deletions src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package at.hannibal2.skyhanni

import at.hannibal2.skyhanni.api.event.HandleEvent
import at.hannibal2.skyhanni.api.event.SkyHanniEvents
import at.hannibal2.skyhanni.config.ConfigFileType
import at.hannibal2.skyhanni.config.ConfigManager
Expand All @@ -12,7 +13,7 @@ import at.hannibal2.skyhanni.data.jsonobjects.local.JacobContestsJson
import at.hannibal2.skyhanni.data.jsonobjects.local.KnownFeaturesJson
import at.hannibal2.skyhanni.data.jsonobjects.local.VisualWordsJson
import at.hannibal2.skyhanni.data.repo.RepoManager
import at.hannibal2.skyhanni.events.LorenzTickEvent
import at.hannibal2.skyhanni.events.SkyHanniTickEvent
import at.hannibal2.skyhanni.events.utils.PreInitFinishedEvent
import at.hannibal2.skyhanni.features.nether.reputationhelper.CrimsonIsleReputationHelper
import at.hannibal2.skyhanni.skyhannimodule.LoadedModules
Expand All @@ -32,7 +33,6 @@ 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 org.apache.logging.log4j.Level
import org.apache.logging.log4j.LogManager
import org.apache.logging.log4j.Logger
Expand Down Expand Up @@ -90,8 +90,8 @@ class SkyHanniMod {
MinecraftForge.EVENT_BUS.register(obj)
}

@SubscribeEvent
fun onTick(event: LorenzTickEvent) {
@HandleEvent
fun onTick(event: SkyHanniTickEvent) {
if (screenToOpen != null) {
screenTicks++
if (screenTicks == 5) {
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/at/hannibal2/skyhanni/api/CollectionAPI.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package at.hannibal2.skyhanni.api

import at.hannibal2.skyhanni.api.event.HandleEvent
import at.hannibal2.skyhanni.data.ItemAddManager
import at.hannibal2.skyhanni.events.CollectionUpdateEvent
import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent
Expand All @@ -19,7 +20,6 @@ import at.hannibal2.skyhanni.utils.RegexUtils.matchFirst
import at.hannibal2.skyhanni.utils.RegexUtils.matches
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent

@SkyHanniModule
object CollectionAPI {
Expand All @@ -44,12 +44,12 @@ object CollectionAPI {
"Mushroom" to "RED_MUSHROOM".asInternalName()
)

@SubscribeEvent
@HandleEvent
fun onProfileJoin(event: ProfileJoinEvent) {
collectionValue.clear()
}

@SubscribeEvent
@HandleEvent
fun onInventoryOpen(event: InventoryFullyOpenedEvent) {
val inventoryName = event.inventoryName
if (inventoryName.endsWith(" Collection")) {
Expand Down Expand Up @@ -87,7 +87,7 @@ object CollectionAPI {
}
}

@SubscribeEvent
@HandleEvent
fun onItemAdd(event: ItemAddEvent) {
if (event.source == ItemAddManager.Source.COMMAND) return
val internalName = event.internalName
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/at/hannibal2/skyhanni/api/DataWatcherAPI.kt
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
package at.hannibal2.skyhanni.api

import at.hannibal2.skyhanni.api.event.HandleEvent
import at.hannibal2.skyhanni.events.DataWatcherUpdatedEvent
import at.hannibal2.skyhanni.events.EntityCustomNameUpdateEvent
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent

@SkyHanniModule
object DataWatcherAPI {

private const val DATA_VALUE_CUSTOM_NAME = 2

@SubscribeEvent
@HandleEvent
fun onDataWatcherUpdate(event: DataWatcherUpdatedEvent) {
for (updatedEntry in event.updatedEntries) {
if (updatedEntry.dataValueId == DATA_VALUE_CUSTOM_NAME) {
EntityCustomNameUpdateEvent(event.entity.customNameTag, event.entity).postAndCatch()
EntityCustomNameUpdateEvent(event.entity.customNameTag, event.entity).post()
}
}
}
Expand Down
30 changes: 15 additions & 15 deletions src/main/java/at/hannibal2/skyhanni/api/GetFromSackAPI.kt
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package at.hannibal2.skyhanni.api

import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.api.event.HandleEvent
import at.hannibal2.skyhanni.data.SackAPI
import at.hannibal2.skyhanni.events.GuiContainerEvent
import at.hannibal2.skyhanni.events.InventoryCloseEvent
import at.hannibal2.skyhanni.events.LorenzChatEvent
import at.hannibal2.skyhanni.events.LorenzTickEvent
import at.hannibal2.skyhanni.events.LorenzToolTipEvent
import at.hannibal2.skyhanni.events.MessageSendToServerEvent
import at.hannibal2.skyhanni.events.SkyHanniChatEvent
import at.hannibal2.skyhanni.events.SkyHanniTickEvent
import at.hannibal2.skyhanni.events.SkyHanniToolTipEvent
import at.hannibal2.skyhanni.features.commands.tabcomplete.GetFromSacksTabComplete
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import at.hannibal2.skyhanni.test.command.ErrorManager
Expand All @@ -27,7 +28,6 @@ import at.hannibal2.skyhanni.utils.SimpleTimeMark
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import net.minecraft.inventory.Slot
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import java.util.Deque
import java.util.LinkedList
import kotlin.time.Duration.Companion.seconds
Expand Down Expand Up @@ -86,8 +86,8 @@ object GetFromSackAPI {

private fun addToInventory(items: List<PrimitiveItemStack>, slotId: Int) = inventoryMap.put(slotId, items)

@SubscribeEvent
fun onTick(event: LorenzTickEvent) {
@HandleEvent
fun onTick(event: SkyHanniTickEvent) {
if (!LorenzUtils.inSkyBlock) return
if (queue.isNotEmpty() && lastTimeOfCommand.passedSince() >= minimumDelay) {
val item = queue.poll()
Expand All @@ -97,12 +97,12 @@ object GetFromSackAPI {
}
}

@SubscribeEvent
@HandleEvent
fun onInventoryClose(event: InventoryCloseEvent) {
inventoryMap.clear()
}

@SubscribeEvent
@HandleEvent
fun onSlotClicked(event: GuiContainerEvent.SlotClickEvent) {
if (!LorenzUtils.inSkyBlock) return
if (event.clickedButton != 1) return // filter none right clicks
Expand All @@ -111,8 +111,8 @@ object GetFromSackAPI {
event.cancel()
}

@SubscribeEvent
fun onTooltip(event: LorenzToolTipEvent) {
@HandleEvent
fun onTooltip(event: SkyHanniToolTipEvent) {
if (!LorenzUtils.inSkyBlock) return
val list = inventoryMap[event.slot.slotIndex] ?: return
event.toolTip.let { tip ->
Expand All @@ -122,15 +122,15 @@ object GetFromSackAPI {
}
}

@SubscribeEvent
@HandleEvent
fun onMessageToServer(event: MessageSendToServerEvent) {
if (!LorenzUtils.inSkyBlock) return
if (!config.queuedGFS && !config.bazaarGFS) return
if (!event.isCommand(commandsWithSlash)) return
val replacedEvent = GetFromSacksTabComplete.handleUnderlineReplace(event)
queuedHandler(replacedEvent)
bazaarHandler(replacedEvent)
if (replacedEvent.isCanceled) {
if (replacedEvent.isCancelled) {
event.cancel()
return
}
Expand All @@ -157,7 +157,7 @@ object GetFromSackAPI {
}

private fun bazaarHandler(event: MessageSendToServerEvent) {
if (event.isCanceled) return
if (event.isCancelled) return
if (!config.bazaarGFS || LorenzUtils.noTradeMode) return
lastItemStack = commandValidator(event.splitMessage.drop(1)).second
}
Expand Down Expand Up @@ -201,8 +201,8 @@ object GetFromSackAPI {
return CommandResult.VALID to PrimitiveItemStack(item, amountString.toDouble().toInt())
}

@SubscribeEvent
fun onChat(event: LorenzChatEvent) {
@HandleEvent
fun onChat(event: SkyHanniChatEvent) {
if (!LorenzUtils.inSkyBlock) return
if (!config.bazaarGFS || LorenzUtils.noTradeMode) return
val stack = lastItemStack ?: return
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/at/hannibal2/skyhanni/api/ReforgeAPI.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package at.hannibal2.skyhanni.api

import at.hannibal2.skyhanni.api.event.HandleEvent
import at.hannibal2.skyhanni.data.jsonobjects.repo.neu.NeuReforgeJson
import at.hannibal2.skyhanni.data.model.SkyblockStat
import at.hannibal2.skyhanni.data.model.SkyblockStatList
Expand All @@ -20,7 +21,6 @@ import com.google.gson.TypeAdapter
import com.google.gson.stream.JsonReader
import com.google.gson.stream.JsonWriter
import net.minecraft.item.ItemStack
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent

@SkyHanniModule
object ReforgeAPI {
Expand Down Expand Up @@ -151,7 +151,7 @@ object ReforgeAPI {
override fun toString(): String = "Reforge $name"
}

@SubscribeEvent
@HandleEvent
fun onNeuRepoReload(event: NeuRepositoryReloadEvent) {
val reforgeStoneData = event.readConstant<Map<String, NeuReforgeJson>>("reforgestones", reforgeGson).values
val reforgeData = event.readConstant<Map<String, NeuReforgeJson>>("reforges", reforgeGson).values
Expand Down
16 changes: 8 additions & 8 deletions src/main/java/at/hannibal2/skyhanni/api/SkillAPI.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package at.hannibal2.skyhanni.api

import at.hannibal2.skyhanni.api.event.HandleEvent
import at.hannibal2.skyhanni.data.ProfileStorageData
import at.hannibal2.skyhanni.data.jsonobjects.repo.neu.NeuSkillLevelJson
import at.hannibal2.skyhanni.events.ActionBarUpdateEvent
Expand Down Expand Up @@ -35,7 +36,6 @@ import at.hannibal2.skyhanni.utils.TabListData
import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import com.google.gson.annotations.Expose
import net.minecraft.command.CommandBase
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import java.util.LinkedList
import java.util.regex.Matcher
import kotlin.time.Duration.Companion.seconds
Expand Down Expand Up @@ -86,7 +86,7 @@ object SkillAPI {
var showDisplay = false
var lastUpdate = SimpleTimeMark.farPast()

@SubscribeEvent
@HandleEvent
fun onSecondPassed(event: SecondPassedEvent) {
val activeSkill = activeSkill ?: return
val info = skillXPInfoMap[activeSkill] ?: return
Expand All @@ -108,7 +108,7 @@ object SkillAPI {
}
}

@SubscribeEvent
@HandleEvent
fun onActionBarUpdate(event: ActionBarUpdateEvent) {
val actionBar = event.actionBar.removeColor()
val components = SPACE_SPLITTER.splitToList(actionBar)
Expand All @@ -129,7 +129,7 @@ object SkillAPI {
skillMultiplierPattern -> handleSkillPatternMultiplier(matcher, skillType, skillInfo)
}

SkillExpGainEvent(skillType, matcher.group("gained").formatDouble()).postAndCatch()
SkillExpGainEvent(skillType, matcher.group("gained").formatDouble()).post()

showDisplay = true
lastUpdate = SimpleTimeMark.now()
Expand All @@ -142,14 +142,14 @@ object SkillAPI {
}
}

@SubscribeEvent
@HandleEvent
fun onNEURepoReload(event: NeuRepositoryReloadEvent) {
levelArray = event.readConstant<NeuSkillLevelJson>("leveling").levelingXp
levelingMap = levelArray.withIndex().associate { (index, xp) -> index to xp }
exactLevelingMap = levelArray.withIndex().associate { (index, xp) -> xp to index }
}

@SubscribeEvent
@HandleEvent
fun onInventoryOpen(event: InventoryFullyOpenedEvent) {
val inventoryName = event.inventoryName
for (stack in event.inventoryItems.values) {
Expand Down Expand Up @@ -213,7 +213,7 @@ object SkillAPI {
}
}

@SubscribeEvent
@HandleEvent
fun onDebugDataCollect(event: DebugDataCollectEvent) {
event.title("Skills")
val storage = storage
Expand Down Expand Up @@ -266,7 +266,7 @@ object SkillAPI {
currentXp
)
if (skillInfo.overflowLevel > 60 && levelOverflow == skillInfo.overflowLevel + 1)
SkillOverflowLevelUpEvent(skillType, skillInfo.overflowLevel, levelOverflow).postAndCatch()
SkillOverflowLevelUpEvent(skillType, skillInfo.overflowLevel, levelOverflow).post()

skillInfo.apply {
this.level = level
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package at.hannibal2.skyhanni.api.event

import at.hannibal2.skyhanni.api.event.HandleEvent
import at.hannibal2.skyhanni.data.MinecraftData
import at.hannibal2.skyhanni.data.jsonobjects.repo.DisabledEventsJson
import at.hannibal2.skyhanni.events.DebugDataCollectEvent
import at.hannibal2.skyhanni.events.RepositoryReloadEvent
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import java.lang.reflect.Method

@SkyHanniModule
Expand Down Expand Up @@ -46,14 +46,14 @@ object SkyHanniEvents {
.addListener(method, instance, options)
}

@SubscribeEvent
@HandleEvent
fun onRepoLoad(event: RepositoryReloadEvent) {
val data = event.getConstant<DisabledEventsJson>("DisabledEvents")
disabledHandlers = data.disabledHandlers
disabledHandlerInvokers = data.disabledInvokers
}

@SubscribeEvent
@HandleEvent
fun onDebug(event: DebugDataCollectEvent) {
event.title("Events")
event.addIrrelevant {
Expand Down
4 changes: 1 addition & 3 deletions src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import at.hannibal2.skyhanni.data.jsonobjects.local.FriendsJson
import at.hannibal2.skyhanni.data.jsonobjects.local.JacobContestsJson
import at.hannibal2.skyhanni.data.jsonobjects.local.KnownFeaturesJson
import at.hannibal2.skyhanni.data.jsonobjects.local.VisualWordsJson
import at.hannibal2.skyhanni.events.LorenzEvent
import at.hannibal2.skyhanni.features.misc.update.UpdateManager
import at.hannibal2.skyhanni.test.command.ErrorManager
import at.hannibal2.skyhanni.utils.ChatUtils
Expand Down Expand Up @@ -95,8 +94,7 @@ class ConfigManager {

try {
findPositionLinks(features, mutableSetOf())
} catch (e: Exception) {
if (LorenzEvent.isInGuardedEventHandler) throw e
} catch (_: Exception) {
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package at.hannibal2.skyhanni.config

import at.hannibal2.skyhanni.events.LorenzEvent
import at.hannibal2.skyhanni.api.event.SkyHanniEvent
import at.hannibal2.skyhanni.features.misc.limbo.LimboTimeTracker
import at.hannibal2.skyhanni.utils.LorenzLogger
import at.hannibal2.skyhanni.utils.LorenzUtils.asIntOrNull
Expand Down Expand Up @@ -30,7 +30,7 @@ object ConfigUpdaterMigrator {
val oldVersion: Int,
var movesPerformed: Int,
val dynamicPrefix: Map<String, List<String>>,
) : LorenzEvent() {
) : SkyHanniEvent() {

init {
dynamicPrefix.entries
Expand Down Expand Up @@ -143,7 +143,7 @@ object ConfigUpdaterMigrator {
it.add("lastVersion", JsonPrimitive(i + 1))
},
i, 0, dynamicPrefix
).also { it.postAndCatch() }
).also { it.post() }
logger.log("Transformations scheduled: ${migration.new}")
val mergesPerformed = merge(migration.old, migration.new)
logger.log("Migration done with $mergesPerformed merges and ${migration.movesPerformed} moves performed")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
import at.hannibal2.skyhanni.config.FeatureToggle;
import com.google.gson.annotations.Expose;
import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorBoolean;
import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorButton;
import io.github.notenoughupdates.moulconfig.annotations.ConfigOption;
import io.github.notenoughupdates.moulconfig.observer.Property;
import net.minecraft.client.Minecraft;

public class LavaReplacementConfig {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
package at.hannibal2.skyhanni.config.features.itemability;

import at.hannibal2.skyhanni.config.FeatureToggle;
import at.hannibal2.skyhanni.config.core.config.Position;
import com.google.gson.annotations.Expose;
import io.github.notenoughupdates.moulconfig.annotations.Accordion;
import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorBoolean;
import io.github.notenoughupdates.moulconfig.annotations.ConfigLink;
import io.github.notenoughupdates.moulconfig.annotations.ConfigOption;

public class ItemAbilityConfig {
Expand Down
Loading
Loading