Add config categories
This commit is contained in:
@@ -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 }
|
||||
}
|
||||
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"
|
||||
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 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")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@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")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user