Removed dependency on lang3
This commit is contained in:
parent
f372eb3b98
commit
7ac8998e5a
2 changed files with 11 additions and 3 deletions
|
@ -19,7 +19,6 @@ repositories {
|
|||
|
||||
dependencies {
|
||||
api 'com.google.guava:guava:21.0'
|
||||
api 'org.apache.commons:commons-lang3:3.5'
|
||||
testImplementation 'junit:junit-dep:4.10'
|
||||
testImplementation 'org.hamcrest:hamcrest-library:1.2.1'
|
||||
testImplementation 'org.mockito:mockito-core:1.8.5'
|
||||
|
|
|
@ -2,9 +2,12 @@ package com.mojang.brigadier.exceptions;
|
|||
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import org.apache.commons.lang3.text.StrSubstitutor;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class ParameterizedCommandExceptionType implements CommandExceptionType {
|
||||
private static Pattern PATTERN = Pattern.compile("\\$\\{(\\w+)}");
|
||||
private static final Joiner JOINER = Joiner.on(", ");
|
||||
|
||||
private final String name;
|
||||
|
@ -24,7 +27,13 @@ public class ParameterizedCommandExceptionType implements CommandExceptionType {
|
|||
|
||||
@Override
|
||||
public String getErrorMessage(CommandException exception) {
|
||||
return new StrSubstitutor(exception.getData()).replace(message);
|
||||
final Matcher matcher = PATTERN.matcher(message);
|
||||
final StringBuffer result = new StringBuffer();
|
||||
while (matcher.find()) {
|
||||
matcher.appendReplacement(result, exception.getData().get(matcher.group(1)).toString());
|
||||
}
|
||||
matcher.appendTail(result);
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
public CommandException create(Object... values) {
|
||||
|
|
Loading…
Reference in a new issue