summaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
authort00thpick1 <t00thpick1dirko@gmail.com>2014-02-09 19:25:27 -0500
committert00thpick1 <t00thpick1dirko@gmail.com>2014-02-09 19:25:46 -0500
commitbab6db48cca78ce9f39a24bd77a3a56a4c2364f5 (patch)
tree142a798bdf3cb9603ca1a166f1ab786d91398c02 /src/main
parent4c35c61ca913b7fcee89a7444218c923d9b37ab1 (diff)
downloadbukkit-bab6db48cca78ce9f39a24bd77a3a56a4c2364f5.tar
bukkit-bab6db48cca78ce9f39a24bd77a3a56a4c2364f5.tar.gz
bukkit-bab6db48cca78ce9f39a24bd77a3a56a4c2364f5.tar.lz
bukkit-bab6db48cca78ce9f39a24bd77a3a56a4c2364f5.tar.xz
bukkit-bab6db48cca78ce9f39a24bd77a3a56a4c2364f5.zip
[Bleeding] Implement escape sequence for aliases.
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;