This commit is contained in:
Jesse Boyd 2017-05-26 17:54:07 +10:00
parent 31d43b27d8
commit bb92a64be3
No known key found for this signature in database
GPG Key ID: 59F1DE6293AF6E1F
4 changed files with 47 additions and 49 deletions

View File

@ -351,7 +351,7 @@ public class MainUtil {
return new FaweInputStream(is);
}
boolean legacy;
if (mode > 10) {
if (mode >= 10) {
legacy = false;
mode = -mode + 10;
} else {

View File

@ -71,7 +71,7 @@ public class DefaultMaskParser extends FaweParser<Mask> {
Mask mask = null;
if (command.isEmpty()) {
mask = parseFromInput(StringMan.join(entry.getValue(), ','), context);
} if (dispatcher.get(command) == null) {
} else if (dispatcher.get(command) == null) {
// Legacy patterns
char char0 = command.charAt(0);
boolean charMask = input.length() > 1 && input.charAt(1) != '[';

View File

@ -68,7 +68,7 @@ public class DefaultTransformParser extends FaweParser<ResettableExtent> {
double chance = 1;
if (command.isEmpty()) {
transform = parseFromInput(StringMan.join(entry.getValue(), ','), context);
} if (dispatcher.get(command) == null) {
} else if (dispatcher.get(command) == null) {
// Legacy syntax
int percentIndex = command.indexOf('%');
if (percentIndex != -1) { // Legacy percent pattern

View File

@ -62,53 +62,51 @@ public class HashTagPatternParser extends FaweParser<Pattern> {
double chance = 1;
if (command.isEmpty()) {
pattern = parseFromInput(StringMan.join(entry.getValue(), ','), context);
} else {
if (dispatcher.get(command) == null) {
// Legacy patterns
char char0 = command.charAt(0);
boolean charMask = input.length() > 1 && input.charAt(1) != '[';
if (charMask && input.charAt(0) == '=') {
return parseFromInput(char0 + "[" + input.substring(1) + "]", context);
}
if (charMask) {
switch (char0) {
case '$': {
command = command.substring(1);
String value = command + ((entry.getValue().isEmpty()) ? "" : "[" + StringMan.join(entry.getValue(), "][") + "]");
if (value.contains(":")) {
if (value.charAt(0) == ':') value.replaceFirst(":", "");
value= value.replaceAll(":", "][");
}
pattern = parseFromInput(char0 + "[" + value + "]", context);
break;
}
}
}
if (pattern == null) {
int percentIndex = command.indexOf('%');
if (percentIndex != -1) { // Legacy percent pattern
chance = Expression.compile(command.substring(0, percentIndex)).evaluate();
command = command.substring(percentIndex + 1);
if (!entry.getValue().isEmpty()) {
if (!command.isEmpty()) command += " ";
command += StringMan.join(entry.getValue(), " ");
}
pattern = parseFromInput(command, context);
} else { // legacy block pattern
try {
pattern = worldEdit.getBlockFactory().parseFromInput(command, context);
} catch (NoMatchException e) {
throw new NoMatchException(e.getMessage() + " See: //patterns");
}
}
}
} else {
List<String> args = entry.getValue();
if (!args.isEmpty()) {
command += " " + StringMan.join(args, " ");
}
pattern = (Pattern) dispatcher.call(command, locals, new String[0]);
} else if (dispatcher.get(command) == null) {
// Legacy patterns
char char0 = command.charAt(0);
boolean charMask = input.length() > 1 && input.charAt(1) != '[';
if (charMask && input.charAt(0) == '=') {
return parseFromInput(char0 + "[" + input.substring(1) + "]", context);
}
if (charMask) {
switch (char0) {
case '$': {
command = command.substring(1);
String value = command + ((entry.getValue().isEmpty()) ? "" : "[" + StringMan.join(entry.getValue(), "][") + "]");
if (value.contains(":")) {
if (value.charAt(0) == ':') value.replaceFirst(":", "");
value= value.replaceAll(":", "][");
}
pattern = parseFromInput(char0 + "[" + value + "]", context);
break;
}
}
}
if (pattern == null) {
int percentIndex = command.indexOf('%');
if (percentIndex != -1) { // Legacy percent pattern
chance = Expression.compile(command.substring(0, percentIndex)).evaluate();
command = command.substring(percentIndex + 1);
if (!entry.getValue().isEmpty()) {
if (!command.isEmpty()) command += " ";
command += StringMan.join(entry.getValue(), " ");
}
pattern = parseFromInput(command, context);
} else { // legacy block pattern
try {
pattern = worldEdit.getBlockFactory().parseFromInput(command, context);
} catch (NoMatchException e) {
throw new NoMatchException(e.getMessage() + " See: //patterns");
}
}
}
} else {
List<String> args = entry.getValue();
if (!args.isEmpty()) {
command += " " + StringMan.join(args, " ");
}
pattern = (Pattern) dispatcher.call(command, locals, new String[0]);
}
patterns.add(pattern);
chances.add(chance);