aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJ10a1n15 <45315647+j10a1n15@users.noreply.github.com>2024-09-11 23:24:00 +0200
committerGitHub <noreply@github.com>2024-09-11 23:24:00 +0200
commit5151e1a0a73e9e194f0b5ec06c49be2c853cc23f (patch)
tree09578f03cff8eb081ab3af1ff39247535005f6bb
parentc48d82d06f375139f1e0a0a32ffd6d2f4aa98546 (diff)
downloadskyhanni-5151e1a0a73e9e194f0b5ec06c49be2c853cc23f.tar.gz
skyhanni-5151e1a0a73e9e194f0b5ec06c49be2c853cc23f.tar.bz2
skyhanni-5151e1a0a73e9e194f0b5ec06c49be2c853cc23f.zip
Technical: Make HandleEvent Islands take in a vararg (#2502)
-rw-r--r--src/main/java/at/hannibal2/skyhanni/api/event/EventHandler.kt7
-rw-r--r--src/main/java/at/hannibal2/skyhanni/api/event/HandleEvent.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/combat/mobs/ArachneSpawnTimer.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonShadowAssassinNotification.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowParticleFinder.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/event/diana/InquisitorWaypointShare.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestAPI.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestParticleWaypoint.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorListener.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt4
11 files changed, 18 insertions, 15 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/api/event/EventHandler.kt b/src/main/java/at/hannibal2/skyhanni/api/event/EventHandler.kt
index cfc8e63b8..78769060a 100644
--- a/src/main/java/at/hannibal2/skyhanni/api/event/EventHandler.kt
+++ b/src/main/java/at/hannibal2/skyhanni/api/event/EventHandler.kt
@@ -5,7 +5,7 @@ import at.hannibal2.skyhanni.data.IslandType
import at.hannibal2.skyhanni.test.command.ErrorManager
import at.hannibal2.skyhanni.utils.ChatUtils
import at.hannibal2.skyhanni.utils.LorenzUtils
-import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland
+import at.hannibal2.skyhanni.utils.LorenzUtils.inAnyIsland
import at.hannibal2.skyhanni.utils.chat.Text
import java.lang.invoke.LambdaMetafactory
import java.lang.invoke.MethodHandles
@@ -113,7 +113,7 @@ class EventHandler<T : SkyHanniEvent> private constructor(val name: String, priv
private fun shouldInvoke(event: SkyHanniEvent, listener: Listener): Boolean {
if (SkyHanniEvents.isDisabledInvoker(listener.name)) return false
if (listener.options.onlyOnSkyblock && !LorenzUtils.inSkyBlock) return false
- if (listener.options.onlyOnIsland != IslandType.ANY && !listener.options.onlyOnIsland.isInIsland()) return false
+ if (IslandType.ANY !in listener.onlyOnIslandTypes && !inAnyIsland(listener.onlyOnIslandTypes)) return false
if (event.isCancelled && !listener.options.receiveCancelled) return false
if (
event is GenericSkyHanniEvent<*> &&
@@ -129,6 +129,7 @@ class EventHandler<T : SkyHanniEvent> private constructor(val name: String, priv
val name: String,
val invoker: Consumer<Any>,
val options: HandleEvent,
- val generic: Class<*>?
+ val generic: Class<*>?,
+ val onlyOnIslandTypes: Set<IslandType> = options.onlyOnIslands.toSet(),
)
}
diff --git a/src/main/java/at/hannibal2/skyhanni/api/event/HandleEvent.kt b/src/main/java/at/hannibal2/skyhanni/api/event/HandleEvent.kt
index 39b047a6e..c07239dc2 100644
--- a/src/main/java/at/hannibal2/skyhanni/api/event/HandleEvent.kt
+++ b/src/main/java/at/hannibal2/skyhanni/api/event/HandleEvent.kt
@@ -13,7 +13,7 @@ annotation class HandleEvent(
/**
* If the event should only be received while on a specific skyblock island.
*/
- val onlyOnIsland: IslandType = IslandType.ANY,
+ vararg val onlyOnIslands: IslandType = [IslandType.ANY],
/**
* The priority of when the event will be called, lower priority will be called first, see the companion object.
diff --git a/src/main/java/at/hannibal2/skyhanni/features/combat/mobs/ArachneSpawnTimer.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/mobs/ArachneSpawnTimer.kt
index 2fee0577e..b3c9be188 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/combat/mobs/ArachneSpawnTimer.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/combat/mobs/ArachneSpawnTimer.kt
@@ -80,7 +80,7 @@ object ArachneSpawnTimer {
}
}
- @HandleEvent(onlyOnIsland = IslandType.SPIDER_DEN, priority = HandleEvent.LOW, receiveCancelled = true)
+ @HandleEvent(onlyOnIslands = [IslandType.SPIDER_DEN], priority = HandleEvent.LOW, receiveCancelled = true)
fun onPacketReceive(event: PacketReceivedEvent) {
if (!saveNextTickParticles) return
if (searchTime.passedSince() < 3.seconds) return
diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonShadowAssassinNotification.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonShadowAssassinNotification.kt
index ca888392f..abe83df8c 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonShadowAssassinNotification.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonShadowAssassinNotification.kt
@@ -16,7 +16,7 @@ object DungeonShadowAssassinNotification {
private val config get() = SkyHanniMod.feature.dungeon
- @HandleEvent(onlyOnIsland = IslandType.CATACOMBS)
+ @HandleEvent(onlyOnIslands = [IslandType.CATACOMBS])
fun onWorldBorderChange(event: PacketReceivedEvent) {
if (!isEnabled()) return
if (DungeonAPI.dungeonFloor?.contains("3") == true && DungeonAPI.inBossRoom) return
diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowParticleFinder.kt b/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowParticleFinder.kt
index 80d6ea0e0..0f0220a76 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowParticleFinder.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowParticleFinder.kt
@@ -58,7 +58,7 @@ object GriffinBurrowParticleFinder {
}
}
- @HandleEvent(onlyOnIsland = IslandType.HUB, priority = HandleEvent.LOW, receiveCancelled = true)
+ @HandleEvent(onlyOnIslands = [IslandType.HUB], priority = HandleEvent.LOW, receiveCancelled = true)
fun onPacketReceive(event: PacketReceivedEvent) {
if (!isEnabled()) return
if (!config.burrowsSoopyGuess) return
diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/diana/InquisitorWaypointShare.kt b/src/main/java/at/hannibal2/skyhanni/features/event/diana/InquisitorWaypointShare.kt
index 2d0e2a809..fbb599d68 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/event/diana/InquisitorWaypointShare.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/event/diana/InquisitorWaypointShare.kt
@@ -222,7 +222,7 @@ object InquisitorWaypointShare {
HypixelCommands.partyChat("x: $x, y: $y, z: $z ")
}
- @HandleEvent(onlyOnIsland = IslandType.HUB, priority = HandleEvent.LOW, receiveCancelled = true)
+ @HandleEvent(onlyOnIslands = [IslandType.HUB], priority = HandleEvent.LOW, receiveCancelled = true)
fun onFirstChatEvent(event: PacketReceivedEvent) {
if (!isEnabled()) return
val packet = event.packet
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt
index ba8b6bb70..e188dcfd0 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt
@@ -87,10 +87,10 @@ object GardenAPI {
"BASIC_GARDENING_AXE",
"ADVANCED_GARDENING_HOE",
"ROOKIE_HOE",
- "BINGHOE"
+ "BINGHOE",
)
- @HandleEvent(onlyOnIsland = IslandType.GARDEN)
+ @HandleEvent(onlyOnIslands = [IslandType.GARDEN])
fun onSendPacket(event: PacketSentEvent) {
if (event.packet !is C09PacketHeldItemChange) return
checkItemInHand()
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestAPI.kt
index d49de324c..7aefb74cd 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestAPI.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestAPI.kt
@@ -158,7 +158,7 @@ object PestAPI {
PestUpdateEvent().post()
}
- @HandleEvent(onlyOnIsland = IslandType.GARDEN)
+ @HandleEvent(onlyOnIslands = [IslandType.GARDEN])
fun onPestSpawn(event: PestSpawnEvent) {
PestSpawnTimer.lastSpawnTime = SimpleTimeMark.now()
val plotNames = event.plotNames
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestParticleWaypoint.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestParticleWaypoint.kt
index 23ead6f91..d3dd8a27b 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestParticleWaypoint.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestParticleWaypoint.kt
@@ -121,7 +121,7 @@ object PestParticleWaypoint {
++particles
}
- @HandleEvent(onlyOnIsland = IslandType.GARDEN)
+ @HandleEvent(onlyOnIslands = [IslandType.GARDEN])
fun onFireWorkSpawn(event: PacketReceivedEvent) {
if (event.packet !is S0EPacketSpawnObject) return
if (!config.hideParticles) return
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorListener.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorListener.kt
index 66d03745f..e709fcda7 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorListener.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorListener.kt
@@ -56,7 +56,7 @@ object VisitorListener {
}
// TODO make event
- @HandleEvent(onlyOnIsland = IslandType.GARDEN)
+ @HandleEvent(onlyOnIslands = [IslandType.GARDEN])
fun onSendEvent(event: PacketSentEvent) {
val packet = event.packet
if (packet !is C02PacketUseEntity) return
@@ -136,7 +136,7 @@ object VisitorListener {
inventory.handleMouseClick_skyhanni(slot, slot.slotIndex, 0, 0)
}
- @HandleEvent(onlyOnIsland = IslandType.GARDEN)
+ @HandleEvent(onlyOnIslands = [IslandType.GARDEN])
fun onTooltip(event: ItemHoverEvent) {
if (!GardenAPI.onBarnPlot) return
if (!VisitorAPI.inInventory) return
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
index 3c97919fc..1fd5419d9 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
@@ -300,7 +300,8 @@ object LorenzUtils {
fun IslandType.isInIsland() = inSkyBlock && skyBlockIsland == this
- fun inAnyIsland(vararg islandTypes: IslandType) = inSkyBlock && islandTypes.any { it.isInIsland() }
+ fun inAnyIsland(vararg islandTypes: IslandType) = inSkyBlock && HypixelData.skyBlockIsland in islandTypes
+ fun inAnyIsland(islandTypes: Collection<IslandType>) = inSkyBlock && HypixelData.skyBlockIsland in islandTypes
fun GuiContainerEvent.SlotClickEvent.makeShiftClick() {
if (this.clickedButton == 1 && slot?.stack?.getItemCategoryOrNull() == ItemCategory.SACK) return
@@ -315,6 +316,7 @@ object LorenzUtils {
this.cancel()
}
}
+
// TODO move into mayor api
val isDerpy by RecalculatingValue(1.seconds) { Perk.DOUBLE_MOBS_HP.isActive }