diff options
author | Linnea Gräf <nea@nea.moe> | 2024-10-13 21:46:46 +0200 |
---|---|---|
committer | Linnea Gräf <nea@nea.moe> | 2024-10-13 21:46:46 +0200 |
commit | 4e9b0ded27df8b6ce7f5b2fa1b4b1ddbc1cbd452 (patch) | |
tree | a489fdd97e6c4dde1bd77bf216ed9c2ec2657db3 /src/main/kotlin/features/chat | |
parent | 0cc77949c907d38497f8cdf6fd8198fe5f0a9440 (diff) | |
download | Firmament-4e9b0ded27df8b6ce7f5b2fa1b4b1ddbc1cbd452.tar.gz Firmament-4e9b0ded27df8b6ce7f5b2fa1b4b1ddbc1cbd452.tar.bz2 Firmament-4e9b0ded27df8b6ce7f5b2fa1b4b1ddbc1cbd452.zip |
Add config categories
Diffstat (limited to 'src/main/kotlin/features/chat')
-rw-r--r-- | src/main/kotlin/features/chat/AutoCompletions.kt | 76 | ||||
-rw-r--r-- | src/main/kotlin/features/chat/ChatLinks.kt | 2 |
2 files changed, 38 insertions, 40 deletions
diff --git a/src/main/kotlin/features/chat/AutoCompletions.kt b/src/main/kotlin/features/chat/AutoCompletions.kt index 9144898..9e0de40 100644 --- a/src/main/kotlin/features/chat/AutoCompletions.kt +++ b/src/main/kotlin/features/chat/AutoCompletions.kt @@ -1,5 +1,3 @@ - - package moe.nea.firmament.features.chat import com.mojang.brigadier.arguments.StringArgumentType.string @@ -17,41 +15,41 @@ import moe.nea.firmament.util.MC object AutoCompletions : FirmamentFeature { - object TConfig : ManagedConfig(identifier) { - val provideWarpTabCompletion by toggle("warp-complete") { true } - val replaceWarpIsByWarpIsland by toggle("warp-is") { true } - } - - override val config: ManagedConfig? - get() = TConfig - override val identifier: String - get() = "auto-completions" - - @Subscribe - fun onMaskCommands(event: MaskCommands) { - if (TConfig.provideWarpTabCompletion) { - event.mask("warp") - } - } - - @Subscribe - fun onCommandEvent(event: CommandEvent) { - if (!TConfig.provideWarpTabCompletion) return - event.deleteCommand("warp") - event.register("warp") { - thenArgument("to", string()) { toArg -> - suggestsList { - RepoManager.neuRepo.constants?.islands?.warps?.flatMap { listOf(it.warp) + it.aliases } ?: listOf() - } - thenExecute { - val warpName = get(toArg) - if (warpName == "is" && TConfig.replaceWarpIsByWarpIsland) { - MC.sendServerCommand("warp island") - } else { - MC.sendServerCommand("warp $warpName") - } - } - } - } - } + object TConfig : ManagedConfig(identifier, Category.CHAT) { + val provideWarpTabCompletion by toggle("warp-complete") { true } + val replaceWarpIsByWarpIsland by toggle("warp-is") { true } + } + + override val config: ManagedConfig? + get() = TConfig + override val identifier: String + get() = "auto-completions" + + @Subscribe + fun onMaskCommands(event: MaskCommands) { + if (TConfig.provideWarpTabCompletion) { + event.mask("warp") + } + } + + @Subscribe + fun onCommandEvent(event: CommandEvent) { + if (!TConfig.provideWarpTabCompletion) return + event.deleteCommand("warp") + event.register("warp") { + thenArgument("to", string()) { toArg -> + suggestsList { + RepoManager.neuRepo.constants?.islands?.warps?.flatMap { listOf(it.warp) + it.aliases } ?: listOf() + } + thenExecute { + val warpName = get(toArg) + if (warpName == "is" && TConfig.replaceWarpIsByWarpIsland) { + MC.sendServerCommand("warp island") + } else { + MC.sendServerCommand("warp $warpName") + } + } + } + } + } } diff --git a/src/main/kotlin/features/chat/ChatLinks.kt b/src/main/kotlin/features/chat/ChatLinks.kt index f2cb78a..0681f57 100644 --- a/src/main/kotlin/features/chat/ChatLinks.kt +++ b/src/main/kotlin/features/chat/ChatLinks.kt @@ -35,7 +35,7 @@ object ChatLinks : FirmamentFeature { override val identifier: String get() = "chat-links" - object TConfig : ManagedConfig(identifier) { + object TConfig : ManagedConfig(identifier, Category.CHAT) { val enableLinks by toggle("links-enabled") { true } val imageEnabled by toggle("image-enabled") { true } val allowAllHosts by toggle("allow-all-hosts") { false } |