aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/features/chat/AutoCompletions.kt
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/kotlin/features/chat/AutoCompletions.kt')
-rw-r--r--src/main/kotlin/features/chat/AutoCompletions.kt33
1 files changed, 25 insertions, 8 deletions
diff --git a/src/main/kotlin/features/chat/AutoCompletions.kt b/src/main/kotlin/features/chat/AutoCompletions.kt
index 9e0de40..f13fe7e 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.commands.BrigadierExceptions
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.commands.get
import moe.nea.firmament.commands.suggestsList
@@ -8,21 +17,21 @@ import moe.nea.firmament.commands.thenArgument
import moe.nea.firmament.commands.thenExecute
import moe.nea.firmament.events.CommandEvent
import moe.nea.firmament.events.MaskCommands
-import moe.nea.firmament.features.FirmamentFeature
-import moe.nea.firmament.gui.config.ManagedConfig
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 : FirmamentFeature {
+object AutoCompletions {
+ @Config
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
+ val identifier: String
get() = "auto-completions"
@Subscribe
@@ -44,12 +53,20 @@ object AutoCompletions : FirmamentFeature {
thenExecute {
val warpName = get(toArg)
if (warpName == "is" && TConfig.replaceWarpIsByWarpIsland) {
- MC.sendServerCommand("warp island")
+ MC.sendCommand("warp island")
} else {
- MC.sendServerCommand("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)
+ }
}