Fix command usage message ignoring color tags#8623
Open
mvanhorn wants to merge 2 commits intoSkriptLang:masterfrom
Open
Fix command usage message ignoring color tags#8623mvanhorn wants to merge 2 commits intoSkriptLang:masterfrom
mvanhorn wants to merge 2 commits intoSkriptLang:masterfrom
Conversation
The "incorrect usage" message printed when a player runs a command with the wrong argument types went through CommandSender.sendMessage(String), which does not understand Skript's <red>-style color tags (those are Adventure / TextComponentParser syntax, not Bukkit & codes). Cooldown messages already round-trip through TextComponentParser via their Component-converted expression, which is why they render correctly. Add CommandUsage.getUsageComponent(Event) that parses the resolved usage string with TextComponentParser, and use it in ScriptCommand's invalid-argument path. Bukkit's PluginCommand.setUsage(String) is left unchanged because the Bukkit registry takes plain text. Fixes SkriptLang#8616
ShaneBeee
reviewed
May 3, 2026
Per @ShaneBeee and @sovdeeth review: command usage strings are 100% Skripter-controlled, so parseSafe() restricts unsafe color tags from ever working in usage entries. Switch to TextComponentParser#parse() to allow the full tag set, matching the precedent in SkriptUpdater / SkriptLogger / Skript admin output paths. Updated the Javadoc to document why unsafe parsing is appropriate for server-controlled text. Verified locally with `./gradlew compileJava` (BUILD SUCCESSFUL).
Author
|
Switched to |
APickledWalrus
approved these changes
May 5, 2026
Member
|
You'll need to update this to target |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #8616. When a Skript command defines a
usage:value with color tags (e.g.<red>Test), the "incorrect usage" message shown to players runs throughCommandSender.sendMessage(String), which does not parse Skript's Adventure-style tags. The cooldown-message path atScriptCommand.java:296already converts to aComponentviaTextComponentParser, so colors render correctly there.Reproduction (from the issue):
/test foo(wrong arg type) prints the literal<red>Test./test 1then immediately again shows the cooldown message in red as expected.Change
CommandUsage.getUsageComponent(Event)— new method that resolves the usageVariableStringand runs the result throughTextComponentParser.instance().parseSafe(...), returning an AdventureComponent.ScriptCommand.java:340— useusage.getUsageComponent(event)sosender.sendMessage(...)takes the Adventure overload that honors<red>and&ctags.bukkitCommand.setUsage(usage.getUsage())(line 245) is left unchanged: Bukkit'sPluginCommand.setUsagetakes a plainStringand is wired into the Bukkit registry, not into our send-to-player path.The help-topic output at line 378 (
ChatColor.GOLD + "Usage" + ChatColor.RESET + ": " + usage.getUsage()) is intentionally out of scope. It mixes BukkitChatColorlegacy codes with the usage string and would require a separate Component-prefix refactor; the user's report was specifically about the invalid-argument feedback path.Validation
./gradlew compileJava✅./gradlew compileTestJava✅sender.sendMessage(Component)resolves on Paper / Bukkit's Adventure-awareCommandSender.The runtime color render itself can only be exercised on a Minecraft server, which is what Skript's
.sktest harness already does for the cooldown path. Happy to add a runtime.skregression forusage:if reviewers prefer.AI assistance disclosure
Per
.github/CONTRIBUTING.md, disclosing AI assistance:Fixes #8616