mirror of
https://hub.spigotmc.org/stash/scm/spigot/bukkit.git
synced 2025-08-21 05:44:17 +00:00
[Bleeding] Implement escape sequence for aliases.
This commit is contained in:
parent
4c35c61ca9
commit
bab6db48cc
1 changed files with 13 additions and 1 deletions
|
@ -65,6 +65,12 @@ public class FormattedCommandAlias extends Command {
|
||||||
while (index != -1) {
|
while (index != -1) {
|
||||||
int start = index;
|
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;
|
boolean required = false;
|
||||||
if (formatString.charAt(index + 1) == '$') {
|
if (formatString.charAt(index + 1) == '$') {
|
||||||
required = true;
|
required = true;
|
||||||
|
@ -74,10 +80,16 @@ public class FormattedCommandAlias extends Command {
|
||||||
|
|
||||||
// Move index past the $
|
// Move index past the $
|
||||||
index++;
|
index++;
|
||||||
int position = Character.getNumericValue(formatString.charAt(index)) - 1;
|
int position = Character.getNumericValue(formatString.charAt(index));
|
||||||
// Move index past the position
|
// Move index past the position
|
||||||
index++;
|
index++;
|
||||||
|
|
||||||
|
if (position == -1) {
|
||||||
|
throw new IllegalArgumentException("Invalid replacement token");
|
||||||
|
}
|
||||||
|
// Convert position to 0 index
|
||||||
|
position--;
|
||||||
|
|
||||||
boolean rest = false;
|
boolean rest = false;
|
||||||
if (index < formatString.length() && formatString.charAt(index) == '-') {
|
if (index < formatString.length() && formatString.charAt(index) == '-') {
|
||||||
rest = true;
|
rest = true;
|
||||||
|
|
Loading…
Add table
Reference in a new issue