diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2024-09-18 09:50:08 +0200 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2024-09-18 09:50:08 +0200 |
commit | c614724dd0a92d89fa96c3468be156a407f924db (patch) | |
tree | 6a8fd48d739f707cd6576497b1cbc72498cdafed /src | |
parent | ff1d69d6238b6898dfe4f7c9986661a0737a2100 (diff) | |
download | skyhanni-c614724dd0a92d89fa96c3468be156a407f924db.tar.gz skyhanni-c614724dd0a92d89fa96c3468be156a407f924db.tar.bz2 skyhanni-c614724dd0a92d89fa96c3468be156a407f924db.zip |
stop initializing the map on every function call
Co-authored-by: Empa <42304516+itsempa@users.noreply.github.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/commands/tabcomplete/PlayerTabComplete.kt | 48 |
1 files changed, 23 insertions, 25 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/commands/tabcomplete/PlayerTabComplete.kt b/src/main/java/at/hannibal2/skyhanni/features/commands/tabcomplete/PlayerTabComplete.kt index bf4428211..070ab478e 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/commands/tabcomplete/PlayerTabComplete.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/commands/tabcomplete/PlayerTabComplete.kt @@ -15,6 +15,24 @@ object PlayerTabComplete { private val config get() = SkyHanniMod.feature.misc.commands.tabComplete private var vipVisits = listOf<String>() + private val ignoredCommandCategories = mapOf( + "f" to listOf(PlayerCategory.FRIENDS), + "friend" to listOf(PlayerCategory.FRIENDS), + + "msg" to listOf(), + "w" to listOf(), + "tell" to listOf(), + "boop" to listOf(), + + "visit" to listOf(), + "invite" to listOf(), + "ah" to listOf(), + + "pv" to listOf(), // NEU's Profile Viewer + "shmarkplayer" to listOf(), // SkyHanni's Mark Player + + "trade" to listOf(PlayerCategory.FRIENDS, PlayerCategory.PARTY), + ) @SubscribeEvent fun onRepoReload(event: RepositoryReloadEvent) { @@ -34,41 +52,21 @@ object PlayerTabComplete { } fun handleTabComplete(command: String): List<String>? { - val commands = mapOf( - "f" to listOf(PlayerCategory.FRIENDS), - "friend" to listOf(PlayerCategory.FRIENDS), - - "msg" to listOf(), - "w" to listOf(), - "tell" to listOf(), - "boop" to listOf(), - - "visit" to listOf(), - "invite" to listOf(), - "ah" to listOf(), - - "pv" to listOf(), // NEU's Profile Viewer - "shmarkplayer" to listOf(), // SkyHanni's Mark Player - - "trade" to listOf(PlayerCategory.FRIENDS, PlayerCategory.PARTY) - ) - val ignored = commands[command] ?: return null + val ignoredCategories = ignoredCommandCategories[command] ?: return null return buildList { - if (config.friends && PlayerCategory.FRIENDS !in ignored) { - FriendAPI.getAllFriends() - .filter { it.bestFriend || !config.onlyBestFriends } - .forEach { add(it.name) } + if (config.friends && PlayerCategory.FRIENDS !in ignoredCategories) { + FriendAPI.getAllFriends().filter { it.bestFriend || !config.onlyBestFriends }.forEach { add(it.name) } } - if (config.islandPlayers && PlayerCategory.ISLAND_PLAYERS !in ignored) { + if (config.islandPlayers && PlayerCategory.ISLAND_PLAYERS !in ignoredCategories) { for (entity in EntityUtils.getPlayerEntities()) { add(entity.name) } } - if (config.party && PlayerCategory.PARTY !in ignored) { + if (config.party && PlayerCategory.PARTY !in ignoredCategories) { for (member in PartyAPI.partyMembers) { add(member) } |