summaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/org/bukkit/command/FormattedCommandAlias.java14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/main/java/org/bukkit/command/FormattedCommandAlias.java b/src/main/java/org/bukkit/command/FormattedCommandAlias.java
index 7e5df7cd..bb46a4da 100644
--- a/src/main/java/org/bukkit/command/FormattedCommandAlias.java
+++ b/src/main/java/org/bukkit/command/FormattedCommandAlias.java
@@ -65,6 +65,12 @@ public class FormattedCommandAlias extends Command {
while (index != -1) {
int start = index;
+ if (index > 0 && formatString.charAt(start - 1) == '\\') {
+ formatString = formatString.substring(0, start - 1) + formatString.substring(start);
+ index = formatString.indexOf("$", index);
+ continue;
+ }
+
boolean required = false;
if (formatString.charAt(index + 1) == '$') {
required = true;
@@ -74,10 +80,16 @@ public class FormattedCommandAlias extends Command {
// Move index past the $
index++;
- int position = Character.getNumericValue(formatString.charAt(index)) - 1;
+ int position = Character.getNumericValue(formatString.charAt(index));
// Move index past the position
index++;
+ if (position == -1) {
+ throw new IllegalArgumentException("Invalid replacement token");
+ }
+ // Convert position to 0 index
+ position--;
+
boolean rest = false;
if (index < formatString.length() && formatString.charAt(index) == '-') {
rest = true;