aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornea <nea@nea.moe>2023-02-06 23:00:22 +0100
committernea <nea@nea.moe>2023-02-06 23:00:22 +0100
commit8d2e0c985334fc90a1da1a1a8a5693da61c1e1de (patch)
treea78c0e04c2613838b823549a2fa664961ed3c7b5
parentdc355f2989b03551744aaa5d6fe7a5b11ff69990 (diff)
downloadNotEnoughUpdates-8d2e0c985334fc90a1da1a1a8a5693da61c1e1de.tar.gz
NotEnoughUpdates-8d2e0c985334fc90a1da1a1a8a5693da61c1e1de.tar.bz2
NotEnoughUpdates-8d2e0c985334fc90a1da1a1a8a5693da61c1e1de.zip
Send usage on invalid command
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/brigadier/NEUBrigadierHook.kt9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/brigadier/NEUBrigadierHook.kt b/src/main/java/io/github/moulberry/notenoughupdates/util/brigadier/NEUBrigadierHook.kt
index 4b5935ce..abe13be0 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/util/brigadier/NEUBrigadierHook.kt
+++ b/src/main/java/io/github/moulberry/notenoughupdates/util/brigadier/NEUBrigadierHook.kt
@@ -22,13 +22,13 @@ package io.github.moulberry.notenoughupdates.util.brigadier
import com.mojang.brigadier.ParseResults
import com.mojang.brigadier.exceptions.CommandSyntaxException
import com.mojang.brigadier.suggestion.Suggestions
-import com.mojang.brigadier.tree.ArgumentCommandNode
import com.mojang.brigadier.tree.CommandNode
import net.minecraft.command.CommandBase
import net.minecraft.command.ICommandSender
import net.minecraft.util.BlockPos
import net.minecraft.util.ChatComponentText
-import net.minecraft.util.EnumChatFormatting
+import net.minecraft.util.EnumChatFormatting.RED
+import net.minecraft.util.EnumChatFormatting.YELLOW
import java.util.concurrent.CompletableFuture
import java.util.function.Predicate
@@ -72,7 +72,10 @@ class NEUBrigadierHook(
try {
brigadierRoot.dispatcher.execute(results)
} catch (syntax: CommandSyntaxException) {
- sender.addChatMessage(ChatComponentText("${EnumChatFormatting.RED}${syntax.message}"))
+ sender.addChatMessage(ChatComponentText("${YELLOW}[NEU] $RED${syntax.message}"))
+ brigadierRoot.getAllUsages("/$commandName", commandNode, mutableSetOf()).forEach {
+ sender.addChatMessage(ChatComponentText("${YELLOW}[NEU] ${it.path} - ${it.help}"))
+ }
}
}