From 208fc04e7db767abda24fdbae141d60898371d61 Mon Sep 17 00:00:00 2001 From: Empa <42304516+ItsEmpa@users.noreply.github.com> Date: Sat, 21 Sep 2024 11:18:41 +0200 Subject: Backend: AreaChangeEvent and Islands in HandleEvent (#2535) Co-authored-by: ItsEmpa Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- src/main/java/at/hannibal2/skyhanni/api/event/EventHandler.kt | 11 +++++++++-- src/main/java/at/hannibal2/skyhanni/api/event/HandleEvent.kt | 9 ++++++++- 2 files changed, 17 insertions(+), 3 deletions(-) (limited to 'src/main/java/at/hannibal2/skyhanni/api') 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 private constructor(val name: String, priv val invoker: Consumer, val options: HandleEvent, val generic: Class<*>?, - val onlyOnIslandTypes: Set = options.onlyOnIslands.toSet(), - ) + ) { + val onlyOnIslandTypes: Set = getIslands(options) + + companion object { + private fun getIslands(options: HandleEvent): Set = + 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. -- cgit