Skip to content

Commit

Permalink
Crude json matching
Browse files Browse the repository at this point in the history
  • Loading branch information
fullwall committed Mar 25, 2023
1 parent ade115c commit 95a36a4
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/main/java/net/citizensnpcs/api/command/CommandContext.java
Expand Up @@ -32,6 +32,7 @@
import org.bukkit.entity.Player;
import org.bukkit.util.EulerAngle;

import com.google.common.base.CharMatcher;
import com.google.common.base.Joiner;
import com.google.common.base.Splitter;
import com.google.common.collect.Iterables;
Expand Down Expand Up @@ -60,6 +61,15 @@ public CommandContext(boolean clearFlags, CommandSender sender, String[] args) {
if (args[i].length() == 0) {
// Ignore this
continue;
} else if (args[i].charAt(0) == '{') {
String json = args[i];
for (int inner = i + 1; inner < args.length; inner++) {
if (CharMatcher.is('{').countIn(json) - CharMatcher.is('}').countIn(json) == 0)
break;
json += " " + args[inner];
args[inner] = "";
}
args[i] = json;
} else if (args[i].charAt(0) == '\'' || args[i].charAt(0) == '"' || args[i].charAt(0) == '`') {
char quote = args[i].charAt(0);
String quoted = args[i].substring(1); // remove initial quote
Expand Down

0 comments on commit 95a36a4

Please sign in to comment.