From e887067b7ecfa9d8e040008cca8d26c194f8c1a5 Mon Sep 17 00:00:00 2001 From: nea Date: Sat, 21 Oct 2023 17:28:00 +0200 Subject: Add tab completion to /warp --- .../kotlin/moe/nea/firmament/events/CommandEvent.kt | 6 ++++++ .../kotlin/moe/nea/firmament/events/MaskCommands.kt | 17 +++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 src/main/kotlin/moe/nea/firmament/events/MaskCommands.kt (limited to 'src/main/kotlin/moe/nea/firmament/events') diff --git a/src/main/kotlin/moe/nea/firmament/events/CommandEvent.kt b/src/main/kotlin/moe/nea/firmament/events/CommandEvent.kt index c291ca4..5710245 100644 --- a/src/main/kotlin/moe/nea/firmament/events/CommandEvent.kt +++ b/src/main/kotlin/moe/nea/firmament/events/CommandEvent.kt @@ -16,9 +16,15 @@ import moe.nea.firmament.commands.literal data class CommandEvent( val dispatcher: CommandDispatcher, val ctx: CommandRegistryAccess, + val serverCommands: CommandDispatcher<*>?, ) : FirmamentEvent() { companion object : FirmamentEventBus() + fun deleteCommand(name: String) { + dispatcher.root.children.removeIf { it.name.equals(name, ignoreCase = false) } + serverCommands?.root?.children?.removeIf { it.name.equals(name, ignoreCase = false) } + } + fun register( name: String, block: CaseInsensitiveLiteralCommandNode.Builder.() -> Unit diff --git a/src/main/kotlin/moe/nea/firmament/events/MaskCommands.kt b/src/main/kotlin/moe/nea/firmament/events/MaskCommands.kt new file mode 100644 index 0000000..0ac0dde --- /dev/null +++ b/src/main/kotlin/moe/nea/firmament/events/MaskCommands.kt @@ -0,0 +1,17 @@ +/* + * SPDX-FileCopyrightText: 2023 Linnea Gräf + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +package moe.nea.firmament.events + +import com.mojang.brigadier.CommandDispatcher + +data class MaskCommands(val dispatcher: CommandDispatcher<*>) : FirmamentEvent() { + companion object : FirmamentEventBus() + + fun mask(name: String) { + dispatcher.root.children.removeIf { it.name.equals(name, ignoreCase = true) } + } +} -- cgit