diff options
| author | Linnea Gräf <nea@nea.moe> | 2025-10-13 18:59:48 +0200 |
|---|---|---|
| committer | Linnea Gräf <nea@nea.moe> | 2025-10-13 18:59:48 +0200 |
| commit | f73a0e4e8e7c4306cdaf0ed163d312c6a0b2c1d5 (patch) | |
| tree | ce0f1b13e8cc852a76d834a9d1d221dcf8a4f591 /src/main/kotlin/features | |
| parent | 584955e8f857f1f919bc1485d811ee5d6dbd688c (diff) | |
| download | Firmament-f73a0e4e8e7c4306cdaf0ed163d312c6a0b2c1d5.tar.gz Firmament-f73a0e4e8e7c4306cdaf0ed163d312c6a0b2c1d5.tar.bz2 Firmament-f73a0e4e8e7c4306cdaf0ed163d312c6a0b2c1d5.zip | |
fix: /warp autocompletion breaking all warps
Diffstat (limited to 'src/main/kotlin/features')
| -rw-r--r-- | src/main/kotlin/features/chat/AutoCompletions.kt | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/src/main/kotlin/features/chat/AutoCompletions.kt b/src/main/kotlin/features/chat/AutoCompletions.kt index b48069d..c9fd133 100644 --- a/src/main/kotlin/features/chat/AutoCompletions.kt +++ b/src/main/kotlin/features/chat/AutoCompletions.kt @@ -1,6 +1,15 @@ package moe.nea.firmament.features.chat +import com.mojang.brigadier.Message import com.mojang.brigadier.arguments.StringArgumentType.string +import com.mojang.brigadier.context.CommandContext +import com.mojang.brigadier.exceptions.BuiltInExceptions +import com.mojang.brigadier.exceptions.CommandExceptionType +import com.mojang.brigadier.exceptions.CommandSyntaxException +import com.mojang.brigadier.exceptions.SimpleCommandExceptionType +import kotlin.concurrent.thread +import net.minecraft.SharedConstants +import net.minecraft.command.TranslatableBuiltInExceptions import moe.nea.firmament.annotations.Subscribe import moe.nea.firmament.commands.get import moe.nea.firmament.commands.suggestsList @@ -12,6 +21,7 @@ import moe.nea.firmament.repo.RepoManager import moe.nea.firmament.util.MC import moe.nea.firmament.util.data.Config import moe.nea.firmament.util.data.ManagedConfig +import moe.nea.firmament.util.tr object AutoCompletions { @@ -45,10 +55,18 @@ object AutoCompletions { if (warpName == "is" && TConfig.replaceWarpIsByWarpIsland) { MC.sendCommand("warp island") } else { - MC.sendCommand("warp $warpName") + redirectToServer() } } } } } + + fun CommandContext<*>.redirectToServer() { + val message = tr( + "firmament.warp.auto-complete.internal-throw", + "This is an internal syntax exception that should not show up in gameplay, used to pass on a command to the server" + ) + throw CommandSyntaxException(CommandSyntaxException.BUILT_IN_EXCEPTIONS.dispatcherUnknownCommand(), message) + } } |
