Skip to content

Commit

Permalink
band-aid fix for single quotes in commands
Browse files Browse the repository at this point in the history
  • Loading branch information
sovdeeth committed Jul 21, 2024
1 parent 7b2dcd9 commit 4faf259
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/main/java/ch/njol/skript/command/CommandUsage.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ public class CommandUsage {
*/
public CommandUsage(@Nullable VariableString usage, String defaultUsage) {
if (usage == null) {
// Manually escape quotes. This is not a good solution, as it doesn't handle many other issues, like % in
// commands, but in lieu of re-writing the argument parser and command logic completely, I believe this is
// a decent stop-gap measure for using " in commands.
defaultUsage = defaultUsage.replaceAll("\"", "\"\"");
usage = VariableString.newInstance(defaultUsage);
assert usage != null;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
command single-quotes-in-commands ["<text="success 2">"]:
trigger:
broadcast arg

test "single-quotes-in-commands":
execute console command "single-quotes-in-commands ""success 1"""
execute console command "single-quotes-in-commands"

0 comments on commit 4faf259

Please sign in to comment.