aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/api
diff options
context:
space:
mode:
authorEmpa <42304516+ItsEmpa@users.noreply.github.com>2024-09-21 11:18:41 +0200
committerGitHub <noreply@github.com>2024-09-21 11:18:41 +0200
commit208fc04e7db767abda24fdbae141d60898371d61 (patch)
tree1f40e682a3dec8d6ee673672ca9a0ba493e183a5 /src/main/java/at/hannibal2/skyhanni/api
parentf298d65f6b3029474f6695ccf3cb6ac5f0400e42 (diff)
downloadskyhanni-208fc04e7db767abda24fdbae141d60898371d61.tar.gz
skyhanni-208fc04e7db767abda24fdbae141d60898371d61.tar.bz2
skyhanni-208fc04e7db767abda24fdbae141d60898371d61.zip
Backend: AreaChangeEvent and Islands in HandleEvent (#2535)
Co-authored-by: ItsEmpa <itsempa@users.noreply.github.com> Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/api')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/api/event/EventHandler.kt11
-rw-r--r--src/main/java/at/hannibal2/skyhanni/api/event/HandleEvent.kt9
2 files changed, 17 insertions, 3 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 78769060a..4b4c00852 100644
--- a/src/main/java/at/hannibal2/skyhanni/api/event/EventHandler.kt
+++ b/src/main/java/at/hannibal2/skyhanni/api/event/EventHandler.kt
@@ -130,6 +130,13 @@ class EventHandler<T : SkyHanniEvent> private constructor(val name: String, priv
val invoker: Consumer<Any>,
val options: HandleEvent,
val generic: Class<*>?,
- val onlyOnIslandTypes: Set<IslandType> = options.onlyOnIslands.toSet(),
- )
+ ) {
+ val onlyOnIslandTypes: Set<IslandType> = getIslands(options)
+
+ companion object {
+ private fun getIslands(options: HandleEvent): Set<IslandType> =
+ if (options.onlyOnIslands.isEmpty()) setOf(options.onlyOnIsland)
+ else 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 c07239dc2..a88f7f337 100644
--- a/src/main/java/at/hannibal2/skyhanni/api/event/HandleEvent.kt
+++ b/src/main/java/at/hannibal2/skyhanni/api/event/HandleEvent.kt
@@ -12,8 +12,15 @@ annotation class HandleEvent(
/**
* If the event should only be received while on a specific skyblock island.
+ * To specify multiple islands, use [onlyOnIslands] instead.
*/
- vararg val onlyOnIslands: IslandType = [IslandType.ANY],
+ val onlyOnIsland: IslandType = IslandType.ANY,
+
+ /**
+ * If the event should only be received while being on specific skyblock islands.
+ * To specify only one island, use [onlyOnIsland] instead.
+ */
+ vararg val onlyOnIslands: IslandType = [],
/**
* The priority of when the event will be called, lower priority will be called first, see the companion object.